Package org.elasticsearch.index.shard
Interface IndexEventListener
- All Known Implementing Classes:
PeerRecoverySourceService
,PeerRecoveryTargetService
,SearchService
,SnapshotShardsService
,SyncedFlushService
public interface IndexEventListener
An 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
via
IndexModule.addIndexEventListener(IndexEventListener)
. All listeners have the same
lifecycle as the IndexService
they 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 TypeMethodDescriptiondefault void
afterIndexCreated(IndexService indexService)
Called after the index has been created.default void
afterIndexRemoved(Index index, IndexSettings indexSettings, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)
Called after the index has been removed.default void
afterIndexShardClosed(ShardId shardId, IndexShard indexShard, Settings indexSettings)
Called after the index shard has been closed.default void
afterIndexShardCreated(IndexShard indexShard)
Called after the index shard has been created.default void
afterIndexShardDeleted(ShardId shardId, Settings indexSettings)
Called after the index shard has been deleted from disk.default void
afterIndexShardStarted(IndexShard indexShard)
Called after the index shard has been started.default void
beforeIndexAddedToCluster(Index index, Settings indexSettings)
Called on the Master node only before theIndexService
instances is created to simulate an index creation.default void
beforeIndexCreated(Index index, Settings indexSettings)
Called before the index gets created.default void
beforeIndexRemoved(IndexService indexService, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)
Called before the index get closed.default void
beforeIndexShardClosed(ShardId shardId, IndexShard indexShard, Settings indexSettings)
Called before the index shard gets closed.default void
beforeIndexShardCreated(ShardRouting routing, Settings indexSettings)
Called before the index shard gets created, before obtaining the shard lock.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.default void
beforeIndexShardRecovery(IndexShard indexShard, IndexSettings indexSettings)
Called before the index shard starts to recover.default void
indexShardStateChanged(IndexShard indexShard, IndexShardState previousState, IndexShardState currentState, String reason)
Called after a shard'sIndexShardState
changes.default void
onShardInactive(IndexShard indexShard)
Called when a shard is marked as inactivedefault void
onStoreClosed(ShardId shardId)
Called when the given shards store is closed.default void
onStoreCreated(ShardId shardId)
Called when the given shards store is created.default void
shardRoutingChanged(IndexShard indexShard, ShardRouting oldRouting, ShardRouting newRouting)
Called when the shard routing has changed state.
-
Method Details
-
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
Called after the index shard has been created. -
afterIndexShardStarted
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 String reason)Called after a shard'sIndexShardState
changes. 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
Called when a shard is marked as inactive- Parameters:
indexShard
- The shard that was marked inactive
-
beforeIndexCreated
Called before the index gets created. Note that this is also called when the index is created on data nodes -
afterIndexCreated
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
Called before the index shard gets created, before obtaining the shard lock.- Parameters:
routing
- the routing entry that caused the shard to be created.indexSettings
- the shards index settings
-
beforeIndexShardDeleted
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
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
Called on the Master node only before theIndexService
instances is created to simulate an index creation. This happens right before the index and it's metadata is registered in the cluster state -
onStoreCreated
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
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
-
beforeIndexShardRecovery
Called before the index shard starts to recover. Note: unlike all other methods in this class, this method is not called using the cluster state update thread. When this method is called the shard already transitioned to the RECOVERING state.- Parameters:
indexShard
- the shard that is about to recoverindexSettings
- the shard's index settings
-