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 SummaryNested classes/interfaces inherited from interface org.elasticsearch.cluster.routing.RoutingChangesObserverRoutingChangesObserver.AbstractRoutingChangesObserver, RoutingChangesObserver.DelegatingRoutingChangesObserver
- 
Constructor SummaryConstructors
- 
Method SummaryModifier 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.AbstractRoutingChangesObserverinitializedReplicaReinitialized, relocationSourceRemoved, relocationStarted, replicaPromoted, unassignedInfoUpdated
- 
Constructor Details- 
IndexMetadataUpdaterpublic IndexMetadataUpdater()
 
- 
- 
Method Details- 
shardInitializedDescription copied from interface:RoutingChangesObserverCalled when unassigned shard is initialized. Does not include initializing relocation target shards.- Specified by:
- shardInitializedin interface- RoutingChangesObserver
- Overrides:
- shardInitializedin class- RoutingChangesObserver.AbstractRoutingChangesObserver
 
- 
shardStartedDescription copied from interface:RoutingChangesObserverCalled when an initializing shard is started.- Specified by:
- shardStartedin interface- RoutingChangesObserver
- Overrides:
- shardStartedin class- RoutingChangesObserver.AbstractRoutingChangesObserver
 
- 
shardFailedDescription copied from interface:RoutingChangesObserverCalled when a shard is failed or cancelled.- Specified by:
- shardFailedin interface- RoutingChangesObserver
- Overrides:
- shardFailedin class- RoutingChangesObserver.AbstractRoutingChangesObserver
 
- 
relocationCompletedDescription copied from interface:RoutingChangesObserverCalled on relocation source when relocation completes after relocation target is started.- Specified by:
- relocationCompletedin interface- RoutingChangesObserver
- Overrides:
- relocationCompletedin class- RoutingChangesObserver.AbstractRoutingChangesObserver
 
- 
applyChangesUpdates 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.
 
- 
removeStaleIdsWithoutRoutingspublic 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.
 
-