Class DataStructuresProcessor
- java.lang.Object
-
- org.apache.ignite.internal.processors.GridProcessorAdapter
-
- org.apache.ignite.internal.processors.datastructures.DataStructuresProcessor
-
- All Implemented Interfaces:
GridComponent,IgniteChangeGlobalStateSupport,GridProcessor
public final class DataStructuresProcessor extends GridProcessorAdapter implements IgniteChangeGlobalStateSupport
Manager of data structures.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.ignite.internal.GridComponent
GridComponent.DiscoveryDataExchangeType
-
-
Field Summary
Fields Modifier and Type Field Description static StringATOMICS_CACHE_NAMEAtomics system cache name.static StringDEFAULT_DS_GROUP_NAMEstatic StringDEFAULT_VOLATILE_DS_GROUP_NAMEstatic StringLATCHES_VIEWstatic StringLOCKS_VIEWstatic StringLONGS_VIEWstatic StringQUEUES_VIEWstatic StringREFERENCES_VIEWstatic StringSEMAPHORES_VIEWstatic StringSEQUENCES_VIEWstatic StringSETS_VIEWstatic StringSTAMPED_VIEWstatic StringVOLATILE_DATA_REGION_NAMEDataRegionConfiguration name reserved for volatile caches.-
Fields inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
ctx, diagnosticLog, log
-
-
Constructor Summary
Constructors Constructor Description DataStructuresProcessor(GridKernalContext ctx)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description IgniteAtomicLongatomicLong(String name, @Nullable AtomicConfiguration cfg, long initVal, boolean create)Gets an atomic long from cache or creates one if it's not cached.<T> IgniteAtomicReference<T>atomicReference(String name, @Nullable AtomicConfiguration cfg, T initVal, boolean create)Gets an atomic reference from cache or creates one if it's not cached.<T,S>
IgniteAtomicStamped<T,S>atomicStamped(String name, @Nullable AtomicConfiguration cfg, T initVal, S initStamp, boolean create)Gets an atomic stamped from cache or creates one if it's not cached.IgniteCountDownLatchcountDownLatch(String name, @Nullable AtomicConfiguration cfg, int cnt, boolean autoDel, boolean create)Gets or creates count down latch.static booleanisDataStructureCache(String cacheName)static booleanisReservedGroup(@Nullable String grpName)voidonActivate(GridKernalContext ctx)Called when cluster performing activation.voidonBeforeActivate()voidonDeActivate(GridKernalContext ctx)Called when cluster performing deactivation.voidonKernalStart(boolean active)Callback that notifies that kernal has successfully started, including all managers and processors.voidonKernalStop(boolean cancel)Callback to notify that kernal is about to stop.IgniteInternalFuture<?>onReconnected(boolean clusterRestarted)Client reconnected callback.voidprintMemoryStats()Prints memory statistics (sizes of internal structures, etc.).<T> IgniteQueue<T>queue(String name, @Nullable String grpName, int cap, @Nullable CollectionConfiguration cfg)Gets a queue from cache or creates one if it's not cached.IgniteLockreentrantLock(String name, @Nullable AtomicConfiguration cfg, boolean failoverSafe, boolean fair, boolean create)Gets or creates reentrant lock.voidremoveCountDownLatch(String name, String grpName)Removes count down latch from cache.voidremoveQueue(String name, GridCacheContext cctx)voidremoveReentrantLock(String name, String grpName, boolean broken)Removes reentrant lock from cache.voidremoveSemaphore(String name, String grpName)Removes semaphore from cache.voidremoveSet(String name, GridCacheContext cctx)voidrestart(String cacheName, IgniteInternalCache cache)Would return this cache to normal work if it was suspened (and if it is atomics cache).voidrestoreStructuresState(GridKernalContext ctx)static <R> Rretry(IgniteLogger log, Callable<R> call)IgniteSemaphoresemaphore(String name, @Nullable AtomicConfiguration cfg, int cnt, boolean failoverSafe, boolean create)Gets or creates semaphore.IgniteAtomicSequencesequence(String name, @Nullable AtomicConfiguration cfg, long initVal, boolean create)Gets a sequence from cache or creates one if it's not cached.<T> @Nullable IgniteSet<T>set(String name, int cacheId, boolean collocated, boolean separated)Gets a set from cache by known cache id.<T> @Nullable IgniteSet<T>set(String name, @Nullable String grpName, @Nullable CollectionConfiguration cfg)Gets a set from cache or creates one if it's not cached.voidstart()Starts grid component.voidsuspend(String cacheName)Would suspend calls for this cache if it is atomics cache.-
Methods inherited from class org.apache.ignite.internal.processors.GridProcessorAdapter
assertParameter, collectGridNodeData, collectJoiningNodeData, discoveryDataType, onDisconnected, onGridDataReceived, onJoiningNodeDataReceived, stop, toString, validateNode, validateNode
-
-
-
-
Field Detail
-
VOLATILE_DATA_REGION_NAME
public static final String VOLATILE_DATA_REGION_NAME
DataRegionConfiguration name reserved for volatile caches.- See Also:
- Constant Field Values
-
DEFAULT_VOLATILE_DS_GROUP_NAME
public static final String DEFAULT_VOLATILE_DS_GROUP_NAME
- See Also:
- Constant Field Values
-
DEFAULT_DS_GROUP_NAME
public static final String DEFAULT_DS_GROUP_NAME
- See Also:
- Constant Field Values
-
ATOMICS_CACHE_NAME
public static final String ATOMICS_CACHE_NAME
Atomics system cache name.- See Also:
- Constant Field Values
-
QUEUES_VIEW
public static final String QUEUES_VIEW
-
SETS_VIEW
public static final String SETS_VIEW
-
LOCKS_VIEW
public static final String LOCKS_VIEW
-
SEMAPHORES_VIEW
public static final String SEMAPHORES_VIEW
-
LATCHES_VIEW
public static final String LATCHES_VIEW
-
STAMPED_VIEW
public static final String STAMPED_VIEW
-
REFERENCES_VIEW
public static final String REFERENCES_VIEW
-
LONGS_VIEW
public static final String LONGS_VIEW
-
SEQUENCES_VIEW
public static final String SEQUENCES_VIEW
-
-
Constructor Detail
-
DataStructuresProcessor
public DataStructuresProcessor(GridKernalContext ctx)
- Parameters:
ctx- Context.
-
-
Method Detail
-
start
public void start()
Starts grid component.- Specified by:
startin interfaceGridComponent- Overrides:
startin classGridProcessorAdapter
-
onKernalStart
public void onKernalStart(boolean active)
Callback that notifies that kernal has successfully started, including all managers and processors.- Specified by:
onKernalStartin interfaceGridComponent- Overrides:
onKernalStartin classGridProcessorAdapter- Parameters:
active- Cluster active flag (note: should be used carefully since state can change concurrently).
-
onBeforeActivate
public void onBeforeActivate()
-
onKernalStop
public void onKernalStop(boolean cancel)
Callback to notify that kernal is about to stop.- Specified by:
onKernalStopin interfaceGridComponent- Overrides:
onKernalStopin classGridProcessorAdapter- Parameters:
cancel- Flag indicating whether jobs should be canceled.
-
onActivate
public void onActivate(GridKernalContext ctx)
Called when cluster performing activation.- Specified by:
onActivatein interfaceIgniteChangeGlobalStateSupport- Parameters:
ctx- Kernal context.
-
restoreStructuresState
public void restoreStructuresState(GridKernalContext ctx)
- Parameters:
ctx- Context.
-
onDeActivate
public void onDeActivate(GridKernalContext ctx)
Called when cluster performing deactivation.- Specified by:
onDeActivatein interfaceIgniteChangeGlobalStateSupport- Parameters:
ctx- Kernal context.
-
onReconnected
public IgniteInternalFuture<?> onReconnected(boolean clusterRestarted) throws IgniteCheckedException
Client reconnected callback.- Specified by:
onReconnectedin interfaceGridComponent- Overrides:
onReconnectedin classGridProcessorAdapter- Parameters:
clusterRestarted- Cluster restarted flag.- Returns:
- Future to wait before completing reconnect future.
- Throws:
IgniteCheckedException- If failed.
-
isDataStructureCache
public static boolean isDataStructureCache(String cacheName)
- Parameters:
cacheName- Cache name.- Returns:
Trueif cache with such name is used to store data structures.
-
isReservedGroup
public static boolean isReservedGroup(@Nullable @Nullable String grpName)- Parameters:
grpName- Group name.- Returns:
Trueif group name is reserved to store data structures.
-
sequence
public final IgniteAtomicSequence sequence(String name, @Nullable @Nullable AtomicConfiguration cfg, long initVal, boolean create) throws IgniteCheckedException
Gets a sequence from cache or creates one if it's not cached.- Parameters:
name- Sequence name.cfg- Configuration.initVal- Initial value for sequence. If sequence already cached,initValwill be ignored.create- Iftruesequence will be created in case it is not in cache.- Returns:
- Sequence.
- Throws:
IgniteCheckedException- If loading failed.
-
atomicLong
public final IgniteAtomicLong atomicLong(String name, @Nullable @Nullable AtomicConfiguration cfg, long initVal, boolean create) throws IgniteCheckedException
Gets an atomic long from cache or creates one if it's not cached.- Parameters:
name- Name of atomic long.cfg- Configuration.initVal- Initial value for atomic long. If atomic long already cached,initValwill be ignored.create- Iftrueatomic long will be created in case it is not in cache.- Returns:
- Atomic long.
- Throws:
IgniteCheckedException- If loading failed.
-
suspend
public void suspend(String cacheName)
Would suspend calls for this cache if it is atomics cache.- Parameters:
cacheName- To suspend.
-
restart
public void restart(String cacheName, IgniteInternalCache cache)
Would return this cache to normal work if it was suspened (and if it is atomics cache).- Parameters:
cacheName- To restart.
-
atomicReference
public final <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable @Nullable AtomicConfiguration cfg, T initVal, boolean create) throws IgniteCheckedException
Gets an atomic reference from cache or creates one if it's not cached.- Parameters:
name- Name of atomic reference.cfg- Configuration.initVal- Initial value for atomic reference. If atomic reference already cached,initValwill be ignored.create- Iftrueatomic reference will be created in case it is not in cache.- Returns:
- Atomic reference.
- Throws:
IgniteCheckedException- If loading failed.
-
atomicStamped
public final <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, @Nullable @Nullable AtomicConfiguration cfg, T initVal, S initStamp, boolean create) throws IgniteCheckedException
Gets an atomic stamped from cache or creates one if it's not cached.- Parameters:
name- Name of atomic stamped.cfg- Configuration.initVal- Initial value for atomic stamped. If atomic stamped already cached,initValwill be ignored.initStamp- Initial stamp for atomic stamped. If atomic stamped already cached,initStampwill be ignored.create- Iftrueatomic stamped will be created in case it is not in cache.- Returns:
- Atomic stamped.
- Throws:
IgniteCheckedException- If loading failed.
-
queue
public final <T> IgniteQueue<T> queue(String name, @Nullable @Nullable String grpName, int cap, @Nullable @Nullable CollectionConfiguration cfg) throws IgniteCheckedException
Gets a queue from cache or creates one if it's not cached.- Parameters:
name- Name of queue.grpName- Group name. If present, will override groupName from configuration.cap- Max size of queue.cfg- Non-null queue configuration if new queue should be created.- Returns:
- Instance of queue.
- Throws:
IgniteCheckedException- If failed.
-
removeQueue
public void removeQueue(String name, GridCacheContext cctx) throws IgniteCheckedException
- Parameters:
name- Queue name.cctx- Queue cache context.- Throws:
IgniteCheckedException- If failed.
-
countDownLatch
public IgniteCountDownLatch countDownLatch(String name, @Nullable @Nullable AtomicConfiguration cfg, int cnt, boolean autoDel, boolean create) throws IgniteCheckedException
Gets or creates count down latch. If count down latch is not found in cache, it is created using provided name and count parameter.- Parameters:
name- Name of the latch.cfg- Configuration.cnt- Initial count.autoDel-Trueto automatically delete latch from cache when its count reaches zero.create- Iftruelatch will be created in case it is not in cache, if it isfalseall parameters exceptnameare ignored.- Returns:
- Count down latch for the given name or
nullif it is not found andcreateis false. - Throws:
IgniteCheckedException- If operation failed.
-
removeCountDownLatch
public void removeCountDownLatch(String name, String grpName) throws IgniteCheckedException
Removes count down latch from cache.- Parameters:
name- Name of the latch.grpName- Cache group name.- Throws:
IgniteCheckedException- If operation failed.
-
semaphore
public IgniteSemaphore semaphore(String name, @Nullable @Nullable AtomicConfiguration cfg, int cnt, boolean failoverSafe, boolean create) throws IgniteCheckedException
Gets or creates semaphore. If semaphore is not found in cache, it is created using provided name and count parameter.- Parameters:
name- Name of the semaphore.cfg- Configuration.cnt- Initial count.failoverSafe-TrueFailoverSafe parameter.create- Iftruesemaphore will be created in case it is not in cache, if it isfalseall parameters exceptnameare ignored.- Returns:
- Semaphore for the given name or
nullif it is not found andcreateis false. - Throws:
IgniteCheckedException- If operation failed.
-
removeSemaphore
public void removeSemaphore(String name, String grpName) throws IgniteCheckedException
Removes semaphore from cache.- Parameters:
name- Name of the semaphore.grpName- Group name.- Throws:
IgniteCheckedException- If operation failed.
-
reentrantLock
public IgniteLock reentrantLock(String name, @Nullable @Nullable AtomicConfiguration cfg, boolean failoverSafe, boolean fair, boolean create) throws IgniteCheckedException
Gets or creates reentrant lock. If reentrant lock is not found in cache, it is created using provided name, failover mode, and fairness mode parameters.- Parameters:
name- Name of the reentrant lock.cfg- Configuration.failoverSafe- Flag indicating behaviour in case of failure.fair- Flag indicating fairness policy of this lock.create- Iftruereentrant lock will be created in case it is not in cache.- Returns:
- ReentrantLock for the given name or
nullif it is not found andcreateis false. - Throws:
IgniteCheckedException- If operation failed.
-
removeReentrantLock
public void removeReentrantLock(String name, String grpName, boolean broken) throws IgniteCheckedException
Removes reentrant lock from cache.- Parameters:
name- Name of the reentrant lock.grpName- Group name.broken- Flag indicating the reentrant lock is broken and should be removed unconditionally.- Throws:
IgniteCheckedException- If operation failed.
-
set
@Nullable public <T> @Nullable IgniteSet<T> set(String name, @Nullable @Nullable String grpName, @Nullable @Nullable CollectionConfiguration cfg) throws IgniteCheckedException
Gets a set from cache or creates one if it's not cached.- Parameters:
name- Set name.grpName- Group name. If present, will override groupName from configuration.cfg- Set configuration if new set should be created.- Returns:
- Set instance.
- Throws:
IgniteCheckedException- If failed.
-
set
@Nullable public <T> @Nullable IgniteSet<T> set(String name, int cacheId, boolean collocated, boolean separated) throws IgniteCheckedException
Gets a set from cache by known cache id. Does not create new sets.- Parameters:
name- Set name.cacheId- Cache id.collocated- Colocated mode flag.separated- Separated cache flag.- Returns:
- Set instance.
- Throws:
IgniteCheckedException- If failed.
-
removeSet
public void removeSet(String name, GridCacheContext cctx) throws IgniteCheckedException
- Parameters:
name- Set name.cctx- Set cache context.- Throws:
IgniteCheckedException- If failed.
-
retry
public static <R> R retry(IgniteLogger log, Callable<R> call) throws IgniteCheckedException
- Parameters:
log- Logger.call- Callable.- Returns:
- Callable result.
- Throws:
IgniteCheckedException- If all retries failed.
-
printMemoryStats
public void printMemoryStats()
Prints memory statistics (sizes of internal structures, etc.). NOTE: this method is for testing and profiling purposes only.- Specified by:
printMemoryStatsin interfaceGridComponent- Overrides:
printMemoryStatsin classGridProcessorAdapter
-
-