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
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionapplyChanges(Metadata oldMetadata, RoutingTable newRoutingTable)Updates the currentMetadatabased on the changes of this RoutingChangesObserver.voidrelocationCompleted(ShardRouting removedRelocationSource)Called on relocation source when relocation completes after relocation target is started.static ClusterStateremoveStaleIdsWithoutRoutings(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.voidshardFailed(ShardRouting failedShard, UnassignedInfo unassignedInfo)Called when a shard is failed or cancelled.voidshardInitialized(ShardRouting unassignedShard, ShardRouting initializedShard)Called when unassigned shard is initialized.voidshardStarted(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:RoutingChangesObserverCalled when unassigned shard is initialized. Does not include initializing relocation target shards.- Specified by:
 shardInitializedin interfaceRoutingChangesObserver- Overrides:
 shardInitializedin classRoutingChangesObserver.AbstractRoutingChangesObserver
 - 
shardStarted
Description copied from interface:RoutingChangesObserverCalled when an initializing shard is started.- Specified by:
 shardStartedin interfaceRoutingChangesObserver- Overrides:
 shardStartedin classRoutingChangesObserver.AbstractRoutingChangesObserver
 - 
shardFailed
Description copied from interface:RoutingChangesObserverCalled when a shard is failed or cancelled.- Specified by:
 shardFailedin interfaceRoutingChangesObserver- Overrides:
 shardFailedin classRoutingChangesObserver.AbstractRoutingChangesObserver
 - 
relocationCompleted
Description copied from interface:RoutingChangesObserverCalled on relocation source when relocation completes after relocation target is started.- Specified by:
 relocationCompletedin interfaceRoutingChangesObserver- Overrides:
 relocationCompletedin classRoutingChangesObserver.AbstractRoutingChangesObserver
 - 
applyChanges
Updates the currentMetadatabased on the changes of this RoutingChangesObserver. Specifically we updateIndexMetadata.getInSyncAllocationIds()andIndexMetadata.primaryTerm(int)based on the changes made during this allocation.- Parameters:
 oldMetadata-Metadataobject from before the routing nodes was changed.newRoutingTable-RoutingTableobject 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. 
 -