Class IndexBuildStatusStorage
- java.lang.Object
-
- org.apache.ignite.internal.processors.query.aware.IndexBuildStatusStorage
-
- All Implemented Interfaces:
CheckpointListener,MetastorageLifecycleListener
public class IndexBuildStatusStorage extends Object implements MetastorageLifecycleListener, CheckpointListener
Holder of up-to-date information about cache index building operations (rebuilding indexes, building new indexes). Avoids index inconsistency when operations have completed, a checkpoint has not occurred, and the node has been restarted. For rebuild indexes, useonStartRebuildIndexes(org.apache.ignite.internal.processors.cache.GridCacheContext, boolean)andonFinishRebuildIndexes(java.lang.String). For build new indexes, useonStartBuildNewIndex(org.apache.ignite.internal.processors.cache.GridCacheContext)andonFinishBuildNewIndex(java.lang.String). UserebuildCompleted(java.lang.String)to check that the index rebuild is complete.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointListener
CheckpointListener.Context
-
-
Field Summary
Fields Modifier and Type Field Description static StringKEY_PREFIXKey prefix for the MetaStorage.
-
Constructor Summary
Constructors Constructor Description IndexBuildStatusStorage(GridKernalContext ctx)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterCheckpointEnd(CheckpointListener.Context ctx)Do some actions after checkpoint end.voidbeforeCheckpointBegin(CheckpointListener.Context ctx)Do some actions before checkpoint write lock.voidmarkIndexRecreate(GridCacheContext<?,?> cacheCtx)Mark that index.bin recreate in progress.voidonCacheKernalStart()Callback on start ofGridCacheProcessor.voidonCheckpointBegin(CheckpointListener.Context ctx)voidonFinishBuildNewIndex(String cacheName)Callback on the finish of building a new cache index.voidonFinishRebuildIndexes(String cacheName)Callback on the finish of rebuilding cache indexes.voidonMarkCheckpointBegin(CheckpointListener.Context ctx)voidonReadyForRead(ReadOnlyMetastorage metastorage)Is called when metastorage is made ready for read-only operations very early on node startup phase.voidonReadyForReadWrite(ReadWriteMetastorage metastorage)Fully functional metastore capable of performing reading and writing operations.voidonStartBuildNewIndex(GridCacheContext cacheCtx)Callback on the start of building a new cache index.voidonStartRebuildIndexes(GridCacheContext cacheCtx, boolean recreate)Callback on the start of rebuilding cache indexes.booleanrebuildCompleted(String cacheName)Check if rebuilding of indexes for the cache has been completed.booleanrecreateCompleted(String cacheName)Check if index.bin recreating for the cache has been completed.voidstart()Callback on start ofGridQueryProcessor.voidstop()Callback on kernel stop.
-
-
-
Field Detail
-
KEY_PREFIX
public static final String KEY_PREFIX
Key prefix for the MetaStorage.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
IndexBuildStatusStorage
public IndexBuildStatusStorage(GridKernalContext ctx)
Constructor.- Parameters:
ctx- Kernal context.
-
-
Method Detail
-
start
public void start()
Callback on start ofGridQueryProcessor.
-
onCacheKernalStart
public void onCacheKernalStart()
Callback on start ofGridCacheProcessor.
-
stop
public void stop()
Callback on kernel stop.
-
onStartRebuildIndexes
public void onStartRebuildIndexes(GridCacheContext cacheCtx, boolean recreate)
Callback on the start of rebuilding cache indexes. Registers the start of rebuilding cache indexes, for persistent cache writes a entry to the MetaStorage so that if a failure occurs, the indexes are automatically rebuilt.- Parameters:
cacheCtx- Cache context.recreate-Trueif index.bin recreating, otherwise building a new index.- See Also:
onFinishRebuildIndexes(java.lang.String)
-
onStartBuildNewIndex
public void onStartBuildNewIndex(GridCacheContext cacheCtx)
Callback on the start of building a new cache index. Registers the start of building a new cache index, for persistent cache writes a entry to the MetaStorage so that if a failure occurs, the indexes are automatically rebuilt.- Parameters:
cacheCtx- Cache context.- See Also:
onFinishBuildNewIndex(java.lang.String)
-
markIndexRecreate
public void markIndexRecreate(GridCacheContext<?,?> cacheCtx)
Mark that index.bin recreate in progress.
-
onFinishRebuildIndexes
public void onFinishRebuildIndexes(String cacheName)
Callback on the finish of rebuilding cache indexes. Registers the finish of rebuilding cache indexes, if all operations have been completed for persistent cache, then the entry will be deleted from the MetaStorage at the end of the checkpoint, otherwise for the in-memory cache the status will be deleted immediately.- Parameters:
cacheName- Cache name.- See Also:
onStartRebuildIndexes(org.apache.ignite.internal.processors.cache.GridCacheContext, boolean)
-
onFinishBuildNewIndex
public void onFinishBuildNewIndex(String cacheName)
Callback on the finish of building a new cache index. Registers the finish of building a new cache index, if all operations have been completed for persistent cache, then the entry will be deleted from the MetaStorage at the end of the checkpoint, otherwise for the in-memory cache the status will be deleted immediately.- Parameters:
cacheName- Cache name.- See Also:
onStartBuildNewIndex(org.apache.ignite.internal.processors.cache.GridCacheContext)
-
rebuildCompleted
public boolean rebuildCompleted(String cacheName)
Check if rebuilding of indexes for the cache has been completed.- Parameters:
cacheName- Cache name.- Returns:
Trueif completed.
-
recreateCompleted
public boolean recreateCompleted(String cacheName)
Check if index.bin recreating for the cache has been completed.- Parameters:
cacheName- Cache name.- Returns:
Trueif index.bin recreate completed.
-
onReadyForReadWrite
public void onReadyForReadWrite(ReadWriteMetastorage metastorage)
Fully functional metastore capable of performing reading and writing operations. Components interested in using metastore are allowed to keep reference passed into the method in their fields.- Specified by:
onReadyForReadWritein interfaceMetastorageLifecycleListener- Parameters:
metastorage- Fully functional meta storage.
-
onReadyForRead
public void onReadyForRead(ReadOnlyMetastorage metastorage)
Is called when metastorage is made ready for read-only operations very early on node startup phase. Reference for read-only metastorage should be used only within this method and shouldn't be stored to any field.- Specified by:
onReadyForReadin interfaceMetastorageLifecycleListener- Parameters:
metastorage- Read-only meta storage.
-
onMarkCheckpointBegin
public void onMarkCheckpointBegin(CheckpointListener.Context ctx)
- Specified by:
onMarkCheckpointBeginin interfaceCheckpointListener
-
onCheckpointBegin
public void onCheckpointBegin(CheckpointListener.Context ctx)
- Specified by:
onCheckpointBeginin interfaceCheckpointListener
-
beforeCheckpointBegin
public void beforeCheckpointBegin(CheckpointListener.Context ctx)
Do some actions before checkpoint write lock.- Specified by:
beforeCheckpointBeginin interfaceCheckpointListener
-
afterCheckpointEnd
public void afterCheckpointEnd(CheckpointListener.Context ctx)
Do some actions after checkpoint end.- Specified by:
afterCheckpointEndin interfaceCheckpointListener
-
-