Package org.elasticsearch.index.shard
Interface IndexEventListener
-
- All Known Implementing Classes:
PeerRecoverySourceService,PeerRecoveryTargetService,SearchService,SnapshotShardsService,SyncedFlushService
public interface IndexEventListenerAn index event listener is the primary extension point for plugins and build-in services to react / listen to per-index and per-shard events. These listeners are registered per-index viaIndexModule.addIndexEventListener(IndexEventListener). All listeners have the same lifecycle as theIndexServicethey are created for.An IndexEventListener can be used across multiple indices and shards since all callback methods receive sufficient local state via their arguments. Yet, if an instance is shared across indices they might be called concurrently and should not modify local state without sufficient synchronization.
-
-
Method Summary
Modifier and Type Method Description default voidafterIndexCreated(IndexService indexService)Called after the index has been created.default voidafterIndexRemoved(Index index, IndexSettings indexSettings, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)Called after the index has been removed.default voidafterIndexShardClosed(ShardId shardId, IndexShard indexShard, Settings indexSettings)Called after the index shard has been closed.default voidafterIndexShardCreated(IndexShard indexShard)Called after the index shard has been created.default voidafterIndexShardDeleted(ShardId shardId, Settings indexSettings)Called after the index shard has been deleted from disk.default voidafterIndexShardStarted(IndexShard indexShard)Called after the index shard has been started.default voidbeforeIndexAddedToCluster(Index index, Settings indexSettings)Called on the Master node only before theIndexServiceinstances is created to simulate an index creation.default voidbeforeIndexCreated(Index index, Settings indexSettings)Called before the index gets created.default voidbeforeIndexRemoved(IndexService indexService, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)Called before the index get closed.default voidbeforeIndexShardClosed(ShardId shardId, IndexShard indexShard, Settings indexSettings)Called before the index shard gets closed.default voidbeforeIndexShardCreated(ShardId shardId, Settings indexSettings)Called before the index shard gets created.default voidbeforeIndexShardDeleted(ShardId shardId, Settings indexSettings)Called before the index shard gets deleted from disk Note: this method is only executed on the first attempt of deleting the shard.default voidindexShardStateChanged(IndexShard indexShard, IndexShardState previousState, IndexShardState currentState, java.lang.String reason)Called after a shard'sIndexShardStatechanges.default voidonShardInactive(IndexShard indexShard)Called when a shard is marked as inactivedefault voidonStoreClosed(ShardId shardId)Called when the given shards store is closed.default voidonStoreCreated(ShardId shardId)Called when the given shards store is created.default voidshardRoutingChanged(IndexShard indexShard, ShardRouting oldRouting, ShardRouting newRouting)Called when the shard routing has changed state.
-
-
-
Method Detail
-
shardRoutingChanged
default void shardRoutingChanged(IndexShard indexShard, @Nullable ShardRouting oldRouting, ShardRouting newRouting)
Called when the shard routing has changed state.- Parameters:
indexShard- The index shardoldRouting- The old routing state (can be null)newRouting- The new routing state
-
afterIndexShardCreated
default void afterIndexShardCreated(IndexShard indexShard)
Called after the index shard has been created.
-
afterIndexShardStarted
default void afterIndexShardStarted(IndexShard indexShard)
Called after the index shard has been started.
-
beforeIndexShardClosed
default void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, Settings indexSettings)
Called before the index shard gets closed.- Parameters:
indexShard- The index shard
-
afterIndexShardClosed
default void afterIndexShardClosed(ShardId shardId, @Nullable IndexShard indexShard, Settings indexSettings)
Called after the index shard has been closed.- Parameters:
shardId- The shard id
-
indexShardStateChanged
default void indexShardStateChanged(IndexShard indexShard, @Nullable IndexShardState previousState, IndexShardState currentState, @Nullable java.lang.String reason)
Called after a shard'sIndexShardStatechanges. The order of concurrent events is preserved. The execution must be lightweight.- Parameters:
indexShard- the shard the new state was applied topreviousState- the previous index shard state if there was one, null otherwisecurrentState- the new shard statereason- the reason for the state change if there is one, null otherwise
-
onShardInactive
default void onShardInactive(IndexShard indexShard)
Called when a shard is marked as inactive- Parameters:
indexShard- The shard that was marked inactive
-
beforeIndexCreated
default void beforeIndexCreated(Index index, Settings indexSettings)
Called before the index gets created. Note that this is also called when the index is created on data nodes
-
afterIndexCreated
default void afterIndexCreated(IndexService indexService)
Called after the index has been created.
-
beforeIndexRemoved
default void beforeIndexRemoved(IndexService indexService, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)
Called before the index get closed.- Parameters:
indexService- The index servicereason- the reason for index removal
-
afterIndexRemoved
default void afterIndexRemoved(Index index, IndexSettings indexSettings, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)
Called after the index has been removed.- Parameters:
index- The indexreason- the reason for index removal
-
beforeIndexShardCreated
default void beforeIndexShardCreated(ShardId shardId, Settings indexSettings)
Called before the index shard gets created.
-
beforeIndexShardDeleted
default void beforeIndexShardDeleted(ShardId shardId, Settings indexSettings)
Called before the index shard gets deleted from disk Note: this method is only executed on the first attempt of deleting the shard. Retries are will not invoke this method.- Parameters:
shardId- The shard idindexSettings- the shards index settings
-
afterIndexShardDeleted
default void afterIndexShardDeleted(ShardId shardId, Settings indexSettings)
Called after the index shard has been deleted from disk. Note: this method is only called if the deletion of the shard did finish without an exception- Parameters:
shardId- The shard idindexSettings- the shards index settings
-
beforeIndexAddedToCluster
default void beforeIndexAddedToCluster(Index index, Settings indexSettings)
Called on the Master node only before theIndexServiceinstances is created to simulate an index creation. This happens right before the index and it's metadata is registered in the cluster state
-
onStoreCreated
default void onStoreCreated(ShardId shardId)
Called when the given shards store is created. The shard store is created before the shard is created.- Parameters:
shardId- the shard ID the store belongs to
-
onStoreClosed
default void onStoreClosed(ShardId shardId)
Called when the given shards store is closed. The store is closed once all resource have been released on the store. This implies that all index readers are closed and no recoveries are running.- Parameters:
shardId- the shard ID the store belongs to
-
-