Class IndexMetadataUpdater
java.lang.Object
org.elasticsearch.cluster.routing.RoutingChangesObserver.AbstractRoutingChangesObserver
org.elasticsearch.cluster.routing.allocation.IndexMetadataUpdater
- All Implemented Interfaces:
RoutingChangesObserver
Observer that tracks changes made to RoutingNodes in order to update the primary terms and in-sync allocation ids in
IndexMetadata
once the allocation round has completed.
Primary terms are updated on primary initialization or when an active primary fails.
Allocation ids are added for shards that become active and removed for shards that stop being active.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.cluster.routing.RoutingChangesObserver
RoutingChangesObserver.AbstractRoutingChangesObserver, RoutingChangesObserver.DelegatingRoutingChangesObserver
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapplyChanges(Metadata oldMetadata, RoutingTable newRoutingTable)
Updates the currentMetadata
based on the changes of this RoutingChangesObserver.void
relocationCompleted(ShardRouting removedRelocationSource)
Called on relocation source when relocation completes after relocation target is started.static ClusterState
removeStaleIdsWithoutRoutings(ClusterState clusterState, List<StaleShard> staleShards, org.apache.logging.log4j.Logger logger)
Removes allocation ids from the in-sync set for shard copies for which there is no routing entries in the routing table.void
shardFailed(ShardRouting failedShard, UnassignedInfo unassignedInfo)
Called when a shard is failed or cancelled.void
shardInitialized(ShardRouting unassignedShard, ShardRouting initializedShard)
Called when unassigned shard is initialized.void
shardStarted(ShardRouting initializingShard, ShardRouting startedShard)
Called when an initializing shard is started.Methods inherited from class org.elasticsearch.cluster.routing.RoutingChangesObserver.AbstractRoutingChangesObserver
initializedReplicaReinitialized, relocationSourceRemoved, relocationStarted, replicaPromoted, unassignedInfoUpdated
-
Constructor Details
-
IndexMetadataUpdater
public IndexMetadataUpdater()
-
-
Method Details
-
shardInitialized
Description copied from interface:RoutingChangesObserver
Called when unassigned shard is initialized. Does not include initializing relocation target shards.- Specified by:
shardInitialized
in interfaceRoutingChangesObserver
- Overrides:
shardInitialized
in classRoutingChangesObserver.AbstractRoutingChangesObserver
-
shardStarted
Description copied from interface:RoutingChangesObserver
Called when an initializing shard is started.- Specified by:
shardStarted
in interfaceRoutingChangesObserver
- Overrides:
shardStarted
in classRoutingChangesObserver.AbstractRoutingChangesObserver
-
shardFailed
Description copied from interface:RoutingChangesObserver
Called when a shard is failed or cancelled.- Specified by:
shardFailed
in interfaceRoutingChangesObserver
- Overrides:
shardFailed
in classRoutingChangesObserver.AbstractRoutingChangesObserver
-
relocationCompleted
Description copied from interface:RoutingChangesObserver
Called on relocation source when relocation completes after relocation target is started.- Specified by:
relocationCompleted
in interfaceRoutingChangesObserver
- Overrides:
relocationCompleted
in classRoutingChangesObserver.AbstractRoutingChangesObserver
-
applyChanges
Updates the currentMetadata
based on the changes of this RoutingChangesObserver. Specifically we updateIndexMetadata.getInSyncAllocationIds()
andIndexMetadata.primaryTerm(int)
based on the changes made during this allocation.- Parameters:
oldMetadata
-Metadata
object from before the routing nodes was changed.newRoutingTable
-RoutingTable
object after routing changes were applied.- Returns:
- adapted
Metadata
, potentially the original one if no change was needed.
-
removeStaleIdsWithoutRoutings
public static ClusterState removeStaleIdsWithoutRoutings(ClusterState clusterState, List<StaleShard> staleShards, org.apache.logging.log4j.Logger logger)Removes allocation ids from the in-sync set for shard copies for which there is no routing entries in the routing table. This method is called in AllocationService before any changes to the routing table are made.
-