Class IgniteKernal
- java.lang.Object
-
- org.apache.ignite.internal.IgniteKernal
-
- All Implemented Interfaces:
Externalizable,Serializable,AutoCloseable,Ignite,IgniteEx
public class IgniteKernal extends Object implements IgniteEx, Externalizable
This class represents an implementation of the main Ignite APIIgnitewhich is expanded by additional methods ofIgniteExfor the internal Ignite needs. It also controls the Ignite life cycle, checks thread pools state for starvation, detects long JVM pauses and prints out the local node metrics.Please, refer to the wiki http://en.wikipedia.org/wiki/Kernal for the information on the misspelling.
Starting
The main entry point for all the Ignite instances creation is the method -start(org.apache.ignite.configuration.IgniteConfiguration, org.apache.ignite.internal.util.lang.GridAbsClosure, org.apache.ignite.internal.worker.WorkersRegistry, java.lang.Thread.UncaughtExceptionHandler, org.apache.ignite.internal.util.TimeBag).It starts internal Ignite components (see
GridComponent), for instance:GridManager- a layer of indirection between kernal and SPI modules.GridProcessor- an objects responsible for particular internal process implementation.IgnitePlugin- an Ignite addition of user-provided functionality.
startmethod also performs additional validation of the providedIgniteConfigurationand prints some suggestions such as:- Ignite configuration optimizations (e.g. disabling
EventTypeevents). JvmConfigurationSuggestionsoptimizations.OsConfigurationSuggestionsoptimizations.
Stopping
To stop Ignite instance thestop(boolean)method is used. Thecancelargument of this method is used:- With
truevalue. To interrupt all currently acitveGridComponents related to the Ignite node. For instance,ComputeJobwill be interrupted by callingComputeJob.cancel()method. Note that just like withThread.interrupt(), it is up to the actual job to exit from execution. - With
falsevalue. To stop the Ignite node gracefully. All jobs currently running will not be interrupted. The Ignite node will wait for the completion of allGridComponents running on it before stopping.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringCFG_VIEWName of the configuration system view.static StringCFG_VIEW_DESCDescription of the configuration system view.static StringCOORDINATOR_PROPERTIES_SEPARATORThe separator is used for coordinator properties formatted as a string.static booleanDFLT_LOG_CLASSPATH_CONTENT_ON_STARTUPstatic longDFLT_LONG_OPERATIONS_DUMP_TIMEOUTDefault timeout in milliseconds for dumping long running operations.static longDFLT_PERIODIC_STARVATION_CHECK_FREQDefault interval of checking thread pool state for the starvation.static StringNLSystem line separator.static StringSITEIgnite web-site that is shown in log messages.
-
Constructor Summary
Constructors Constructor Description IgniteKernal()No-arg constructor is required by externalization.IgniteKernal(@Nullable GridSpringResourceContext rsrcCtx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanactive()Checks Ignite grid is active or not active.voidactive(boolean active)Changes Ignite grid state to active or inactive.<K,V>
voidaddCacheConfiguration(CacheConfiguration<K,V> cacheCfg)Adds cache configuration template.<K> Affinity<K>affinity(String cacheName)Gets affinity service to provide information about data partitioning and distribution.booleanallEventsUserRecordable(int[] types)Checks whether all provided events are user-recordable.@Nullable IgniteAtomicLongatomicLong(String name, long initVal, boolean create)Will get a atomic long from cache and create one if it has not been created yet andcreateflag istrue.@Nullable IgniteAtomicLongatomicLong(String name, AtomicConfiguration cfg, long initVal, boolean create)Will get a atomic long from cache and create one if it has not been created yet andcreateflag istrue.<T> IgniteAtomicReference<T>atomicReference(String name, AtomicConfiguration cfg, T initVal, boolean create)Will get a atomic reference from cache and create one if it has not been created yet andcreateflag istrue.<T> @Nullable IgniteAtomicReference<T>atomicReference(String name, T initVal, boolean create)Will get a atomic reference from cache and create one if it has not been created yet andcreateflag istrue.@Nullable IgniteAtomicSequenceatomicSequence(String name, long initVal, boolean create)Will get an atomic sequence from cache and create one if it has not been created yet andcreateflag istrue.@Nullable IgniteAtomicSequenceatomicSequence(String name, AtomicConfiguration cfg, long initVal, boolean create)Will get an atomic sequence from cache and create one if it has not been created yet andcreateflag istrue.<T,S>
IgniteAtomicStamped<T,S>atomicStamped(String name, AtomicConfiguration cfg, T initVal, S initStamp, boolean create)Will get a atomic stamped from cache and create one if it has not been created yet andcreateflag istrue.<T,S>
@Nullable IgniteAtomicStamped<T,S>atomicStamped(String name, T initVal, S initStamp, boolean create)Will get a atomic stamped from cache and create one if it has not been created yet andcreateflag istrue.IgniteBinarybinary()Gets an instance ofIgniteBinaryinterface.<K,V>
IgniteCache<K,V>cache(String name)Gets an instance ofIgniteCacheAPI for the given name if one is configured ornullotherwise.Collection<String>cacheNames()Gets the collection of names of currently available caches.Collection<IgniteCacheProxy<?,?>>caches()Collection<IgniteInternalCache<?,?>>cachesx(IgnitePredicate<? super IgniteInternalCache<?,?>>[] p)Gets configured cache instance that satisfy all provided predicates including non-public caches.<K,V>
IgniteInternalCache<K,V>cachex(String name)Gets the cache instance for the given name if one is configured or null otherwise returning even non-public caches.voidclose()Closesthisinstance of grid.IgniteClusterExcluster()Gets an instance ofIgniteClusterinterface.IgniteCommandRegistrycommandsRegistry()IgniteComputecompute()Getscomputefacade over all cluster nodes started in server mode.IgniteComputecompute(ClusterGroup grp)Getscomputefacade over the specified cluster group.IgniteConfigurationconfiguration()Gets the configuration of this Ignite instance.GridKernalContextcontext()It's intended for use by internal marshalling implementation only.@Nullable IgniteCountDownLatchcountDownLatch(String name, int cnt, boolean autoDel, boolean create)Gets or creates count down latch.<K,V>
IgniteCache<K,V>createCache(String cacheName)Dynamically starts new cache using template configuration.<K,V>
IgniteCache<K,V>createCache(CacheConfiguration<K,V> cacheCfg)Dynamically starts new cache with the given cache configuration.<K,V>
IgniteCache<K,V>createCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)Dynamically starts new cache with the given cache configuration.Collection<IgniteCache>createCaches(Collection<CacheConfiguration> cacheCfgs)Dynamically starts new caches with the given cache configurations.<K,V>
IgniteCache<K,V>createNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)Starts a near cache on local node if cache was previously started with one of theIgnite.createCache(CacheConfiguration)orIgnite.createCache(CacheConfiguration, NearCacheConfiguration)methods.Collection<DataRegionMetrics>dataRegionMetrics()Returns a collection ofDataRegionMetricsthat reflects page memory usage on this Apache Ignite node instance.@Nullable DataRegionMetricsdataRegionMetrics(String memPlcName)Returns the latestDataRegionMetricssnapshot for the memory region of the given name.voiddataStorageReport()<K,V>
IgniteDataStreamer<K,V>dataStreamer(String cacheName)Gets a new instance of data streamer associated with given cache name.voiddestroyCache(String cacheName)Destroys a cache with the given name and cleans data that was written to the cache.booleandestroyCache0(String cacheName, boolean sql)Stops dynamically started cache.IgniteInternalFuture<Boolean>destroyCacheAsync(String cacheName, boolean sql, boolean checkThreadTx)voiddestroyCaches(Collection<String> cacheNames)Destroys caches with the given names and cleans data that was written to the caches.IgniteInternalFuture<?>destroyCachesAsync(Collection<String> cacheNames, boolean checkThreadTx)voiddumpDebugInfo()Dumps debug information for the current node.IgniteEncryptionencryption()Gets an instance ofIgniteEncryptioninterface.IgniteEventsevents()Getseventsfacade over all cluster nodes.IgniteEventsevents(ClusterGroup grp)Getseventsfacade over nodes within the cluster group.booleaneventUserRecordable(int type)Checks if the event type is user-recordable.ExecutorServiceexecutorService()Creates a newExecutorServicewhich will execute all submittedCallableandRunnablejobs on all cluster nodes.ExecutorServiceexecutorService(ClusterGroup grp)Creates a newExecutorServicewhich will execute all submittedCallableandRunnablejobs on nodes in the specified cluster group.<K,V>
IgniteInternalCache<K,V>getCache(String name)<K,V>
IgniteCache<K,V>getOrCreateCache(String cacheName)Gets existing cache with the given name or creates new one using template configuration.<K,V>
IgniteCache<K,V>getOrCreateCache(CacheConfiguration<K,V> cacheCfg)Gets existing cache with the given name or creates new one with the given configuration.<K,V>
IgniteCache<K,V>getOrCreateCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)Gets existing cache with the given cache configuration or creates one if it does not exist.<K,V>
IgniteBiTuple<IgniteCache<K,V>,Boolean>getOrCreateCache0(CacheConfiguration<K,V> cacheCfg, boolean sql)Gets existing cache with the given name or creates new one with the given configuration.IgniteInternalFuture<?>getOrCreateCacheAsync(String cacheName, String templateName, CacheConfigurationOverride cfgOverride, boolean checkThreadTx)Collection<IgniteCache>getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs)Gets existing caches with the given name or created one with the given configuration.<K,V>
IgniteCache<K,V>getOrCreateNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)Gets existing near cache with the given name or creates a new one.<K,V>
GridCacheAdapter<K,V>internalCache(String name)USED ONLY FOR TESTING.booleanisJmxRemoteEnabled()Whether or not remote JMX management is enabled for this node.booleanisRebalanceEnabled()Get rebalance enabled flag.booleanisRestartEnabled()Whether or not node restart is enabled.booleanisStopping()StringlatestVersion()Get latest version in string form.ClusterNodelocalNode()Gets local grid node.UUIDlocalNodeId()IgniteLoggerlog()Gets grid's logger.Collection<MemoryMetrics>memoryMetrics()@Nullable MemoryMetricsmemoryMetrics(String memPlcName)IgniteMessagingmessage()Getsmessagingfacade over all cluster nodes.IgniteMessagingmessage(ClusterGroup prj)Getsmessagingfacade over nodes within the cluster group.IgniteMetricsmetrics()Gets custom metrics facade over current node.Stringname()Gets the name of the Ignite instance.voidonDisconnected()Method is responsible for handling theEventType.EVT_CLIENT_NODE_DISCONNECTEDevent.voidonReconnected(boolean clusterRestarted)<T extends IgnitePlugin>
Tplugin(String name)Gets an instance of deployed Ignite plugin.<T> @Nullable IgniteQueue<T>queue(String name, int cap, CollectionConfiguration cfg)Will get a named queue from cache and create one if it has not been created yet andcfgis notnull.voidreadExternal(ObjectInput in)protected ObjectreadResolve()voidrebalanceEnabled(boolean rebalanceEnabled)Set rebalance enable flag on node.@Nullable IgniteLockreentrantLock(String name, boolean failoverSafe, boolean fair, boolean create)Gets or creates reentrant lock.voidresetLostPartitions(Collection<String> cacheNames)Clears partition's lost state and moves caches to a normal mode.IgniteSchedulerscheduler()Gets an instance of cron-based scheduler.@Nullable IgniteSemaphoresemaphore(String name, int cnt, boolean failoverSafe, boolean create)Gets or creates semaphore.IgniteInternalFuturesendIoTest(List<ClusterNode> nodes, byte[] payload, boolean procFromNioThread)IgniteInternalFuturesendIoTest(ClusterNode node, byte[] payload, boolean procFromNioThread)IgniteServicesservices()Getsservicesfacade over all cluster nodes started in server mode.IgniteServicesservices(ClusterGroup grp)Getsservicesfacade over nodes within the cluster group.<T> 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, CollectionConfiguration cfg)Will get a named set from cache and create one if it has not been created yet andcfgis notnull.IgniteSnapshotsnapshot()voidstart(IgniteConfiguration cfg, GridAbsClosure errHnd, WorkersRegistry workerRegistry, Thread.UncaughtExceptionHandler hnd, TimeBag startTimer)voidstop(boolean cancel)Stops Ignite instance.StringtoString()@NotNull TracingConfigurationManagertracingConfiguration()Returns theTracingConfigurationManagerinstance that allows to Configure tracing parameters such as sampling rate for the specific tracing coordinates such as scope and label. Retrieve the most specific tracing parameters for the specified tracing coordinates (scope and label) Restore the tracing parameters for the specified tracing coordinates to the default. List all pairs of tracing configuration coordinates and tracing configuration parameters.IgniteTransactionstransactions()Gets grid transactions facade.StringupTimeFormatted()<K extends GridCacheUtilityKey,V>
IgniteInternalCache<K,V>utilityCache()Gets utility cache.IgniteProductVersionversion()Gets Ignite version.StringvmName()voidwriteExternal(ObjectOutput out)
-
-
-
Field Detail
-
SITE
public static final String SITE
Ignite web-site that is shown in log messages.- See Also:
- Constant Field Values
-
NL
public static final String NL
System line separator.
-
CFG_VIEW
public static final String CFG_VIEW
Name of the configuration system view.- See Also:
- Constant Field Values
-
CFG_VIEW_DESC
public static final String CFG_VIEW_DESC
Description of the configuration system view.- See Also:
- Constant Field Values
-
DFLT_PERIODIC_STARVATION_CHECK_FREQ
public static final long DFLT_PERIODIC_STARVATION_CHECK_FREQ
Default interval of checking thread pool state for the starvation. Will be used only if theIgniteSystemProperties.IGNITE_STARVATION_CHECK_INTERVALsystem property is not set.Value is
30 sec.- See Also:
- Constant Field Values
-
COORDINATOR_PROPERTIES_SEPARATOR
public static final String COORDINATOR_PROPERTIES_SEPARATOR
The separator is used for coordinator properties formatted as a string.- See Also:
- Constant Field Values
-
DFLT_LONG_OPERATIONS_DUMP_TIMEOUT
public static final long DFLT_LONG_OPERATIONS_DUMP_TIMEOUT
Default timeout in milliseconds for dumping long running operations. Will be used if theIgniteSystemProperties.IGNITE_LONG_OPERATIONS_DUMP_TIMEOUTis not set.Value is
60 sec.- See Also:
- Constant Field Values
-
DFLT_LOG_CLASSPATH_CONTENT_ON_STARTUP
public static final boolean DFLT_LOG_CLASSPATH_CONTENT_ON_STARTUP
-
-
Constructor Detail
-
IgniteKernal
public IgniteKernal()
No-arg constructor is required by externalization.
-
IgniteKernal
public IgniteKernal(@Nullable @Nullable GridSpringResourceContext rsrcCtx)- Parameters:
rsrcCtx- Optional Spring application context.
-
-
Method Detail
-
cluster
public IgniteClusterEx cluster()
Gets an instance ofIgniteClusterinterface.- Specified by:
clusterin interfaceIgnite- Specified by:
clusterin interfaceIgniteEx- Returns:
- Instance of
IgniteClusterinterface.
-
localNode
public ClusterNode localNode()
Gets local grid node.
-
compute
public IgniteCompute compute()
Getscomputefacade over all cluster nodes started in server mode.
-
metrics
public IgniteMetrics metrics()
Gets custom metrics facade over current node.- Specified by:
metricsin interfaceIgnite- Returns:
IgniteMetricsinstance for current node.
-
message
public IgniteMessaging message()
Getsmessagingfacade over all cluster nodes.
-
events
public IgniteEvents events()
Getseventsfacade over all cluster nodes.
-
services
public IgniteServices services()
Getsservicesfacade over all cluster nodes started in server mode.
-
executorService
public ExecutorService executorService()
Creates a newExecutorServicewhich will execute all submittedCallableandRunnablejobs on all cluster nodes. This essentially creates a Distributed Thread Pool that can be used as a replacement for local thread pools.- Specified by:
executorServicein interfaceIgnite- Returns:
- Grid-enabled
ExecutorService.
-
compute
public final IgniteCompute compute(ClusterGroup grp)
Getscomputefacade over the specified cluster group. All operations on the returnedIgniteComputeinstance will only include nodes from this cluster group.
-
message
public final IgniteMessaging message(ClusterGroup prj)
Getsmessagingfacade over nodes within the cluster group. All operations on the returnedIgniteMessaginginstance will only include nodes from the specified cluster group.
-
events
public final IgniteEvents events(ClusterGroup grp)
Getseventsfacade over nodes within the cluster group. All operations on the returnedIgniteEventsinstance will only include nodes from the specified cluster group.
-
services
public IgniteServices services(ClusterGroup grp)
Getsservicesfacade over nodes within the cluster group. All operations on the returnedIgniteMessaginginstance will only include nodes from the specified cluster group.
-
executorService
public ExecutorService executorService(ClusterGroup grp)
Creates a newExecutorServicewhich will execute all submittedCallableandRunnablejobs on nodes in the specified cluster group. This essentially creates a Distributed Thread Pool that can be used as a replacement for local thread pools.- Specified by:
executorServicein interfaceIgnite- Parameters:
grp- Cluster group.- Returns:
ExecutorServicewhich will execute jobs on nodes in given cluster group.
-
name
public String name()
Gets the name of the Ignite instance. The name allows having multiple Ignite instances with different names within the same Java VM.If default Ignite instance is used, then
nullis returned. Refer toIgnitiondocumentation for information on how to start named ignite Instances.
-
isRebalanceEnabled
public boolean isRebalanceEnabled()
Get rebalance enabled flag.- Specified by:
isRebalanceEnabledin interfaceIgniteEx- Returns:
Trueif rebalance enabled on node,Falseotherwise.
-
rebalanceEnabled
public void rebalanceEnabled(boolean rebalanceEnabled)
Set rebalance enable flag on node.- Specified by:
rebalanceEnabledin interfaceIgniteEx- Parameters:
rebalanceEnabled- rebalance enabled flag.
-
upTimeFormatted
public String upTimeFormatted()
- Returns:
- String representation of the uptime.
-
vmName
public String vmName()
- Returns:
- Name of the VM.
-
localNodeId
public UUID localNodeId()
- Returns:
- Id of the local node.
-
start
public void start(IgniteConfiguration cfg, GridAbsClosure errHnd, WorkersRegistry workerRegistry, Thread.UncaughtExceptionHandler hnd, TimeBag startTimer) throws IgniteCheckedException
- Parameters:
cfg- Ignite configuration to use.errHnd- Error handler to use for notification about startup problems.workerRegistry- Worker registry.hnd- Default uncaught exception handler used by thread pools.- Throws:
IgniteCheckedException- Thrown in case of any errors.
-
dataStorageReport
public void dataStorageReport()
-
stop
public void stop(boolean cancel)
Stops Ignite instance.- Parameters:
cancel- Whether or not to cancel running jobs.
-
isStopping
public boolean isStopping()
- Returns:
Trueif node started shutdown sequence.
-
internalCache
public <K,V> GridCacheAdapter<K,V> internalCache(String name)
USED ONLY FOR TESTING.- Type Parameters:
K- Key type.V- Value type.- Parameters:
name- Cache name.- Returns:
- Internal cache instance.
-
context
public GridKernalContext context()
It's intended for use by internal marshalling implementation only.
-
isJmxRemoteEnabled
public boolean isJmxRemoteEnabled()
Whether or not remote JMX management is enabled for this node. Remote JMX management is enabled when the following system property is set:com.sun.management.jmxremote
- Specified by:
isJmxRemoteEnabledin interfaceIgniteEx- Returns:
Trueif remote JMX management is enabled -falseotherwise.
-
isRestartEnabled
public boolean isRestartEnabled()
Whether or not node restart is enabled. Node restart us supported when this node was started withbin/ignite.{sh|bat}script using-rargument. Node can be programmatically restarted usingIgnition.restart(boolean)} method.- Specified by:
isRestartEnabledin interfaceIgniteEx- Returns:
Trueif restart mode is enabled,falseotherwise.- See Also:
Ignition.restart(boolean)
-
configuration
public IgniteConfiguration configuration()
Gets the configuration of this Ignite instance.NOTE:
SPIs obtains through this method should never be used directly. SPIs provide internal view on the subsystem and is used internally by Ignite kernal. In rare use cases when access to a specific implementation of this SPI is required - an instance of this SPI can be obtained via this method to check its configuration properties or call other non-SPI methods.- Specified by:
configurationin interfaceIgnite- Returns:
- Ignite configuration instance.
-
log
public IgniteLogger log()
Gets grid's logger.
-
eventUserRecordable
public boolean eventUserRecordable(int type)
Checks if the event type is user-recordable.- Specified by:
eventUserRecordablein interfaceIgniteEx- Parameters:
type- Event type to check.- Returns:
trueif passed event should be recorded,false- otherwise.
-
allEventsUserRecordable
public boolean allEventsUserRecordable(int[] types)
Checks whether all provided events are user-recordable.Note that this method supports only predefined Ignite events.
- Specified by:
allEventsUserRecordablein interfaceIgniteEx- Parameters:
types- Event types.- Returns:
- Whether all events are recordable.
-
transactions
public IgniteTransactions transactions()
Gets grid transactions facade.- Specified by:
transactionsin interfaceIgnite- Returns:
- Grid transactions facade.
-
getCache
public <K,V> IgniteInternalCache<K,V> getCache(String name)
- Parameters:
name- Cache name.- Returns:
- Ignite internal cache instance related to the given name.
-
cache
public <K,V> IgniteCache<K,V> cache(String name)
Gets an instance ofIgniteCacheAPI for the given name if one is configured ornullotherwise.IgniteCacheis a fully-compatible implementation ofJCache (JSR 107)specification.
-
createCache
public <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg)
Dynamically starts new cache with the given cache configuration.If local node is an affinity node, this method will return the instance of started cache. Otherwise, it will create a client cache on local node.
If a cache with the same name already exists in the grid, an exception will be thrown regardless whether the given configuration matches the configuration of the existing cache or not.
- Specified by:
createCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheCfg- Cache configuration to use.- Returns:
- Instance of started cache.
-
createCaches
public Collection<IgniteCache> createCaches(Collection<CacheConfiguration> cacheCfgs)
Dynamically starts new caches with the given cache configurations.If local node is an affinity node, this method will return the instance of started caches. Otherwise, it will create a client caches on local node.
If for one of configurations a cache with the same name already exists in the grid, an exception will be thrown regardless whether the given configuration matches the configuration of the existing cache or not.
- Specified by:
createCachesin interfaceIgnite- Parameters:
cacheCfgs- Collection of cache configuration to use.- Returns:
- Collection of instances of started caches.
-
createCache
public <K,V> IgniteCache<K,V> createCache(String cacheName)
Dynamically starts new cache using template configuration.If local node is an affinity node, this method will return the instance of started cache. Otherwise, it will create a client cache on local node.
If a cache with the same name already exists in the grid, an exception will be thrown.
- Specified by:
createCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheName- Cache name.- Returns:
- Instance of started cache.
-
getOrCreateCache
public <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg)
Gets existing cache with the given name or creates new one with the given configuration.If a cache with the same name already exist, this method will not check that the given configuration matches the configuration of existing cache and will return an instance of the existing cache.
- Specified by:
getOrCreateCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheCfg- Cache configuration to use.- Returns:
- Existing or newly created cache.
-
getOrCreateCache0
public <K,V> IgniteBiTuple<IgniteCache<K,V>,Boolean> getOrCreateCache0(CacheConfiguration<K,V> cacheCfg, boolean sql)
Gets existing cache with the given name or creates new one with the given configuration.If a cache with the same name already exists, this method will not check that the given configuration matches the configuration of existing cache and will return an instance of the existing cache.
- Specified by:
getOrCreateCache0in interfaceIgniteEx- Parameters:
cacheCfg- Cache configuration to use.sql-trueif this call is triggered by SQL commandCREATE TABLE,falseotherwise.- Returns:
- Tuple [Existing or newly created cache;
trueif cache was newly crated,falseotherwise]
-
getOrCreateCaches
public Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs)
Gets existing caches with the given name or created one with the given configuration.If a cache with the same name already exist, this method will not check that the given configuration matches the configuration of existing cache and will return an instance of the existing cache.
- Specified by:
getOrCreateCachesin interfaceIgnite- Parameters:
cacheCfgs- Collection of cache configuration to use.- Returns:
- Collection of existing or newly created caches.
-
createCache
public <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
Dynamically starts new cache with the given cache configuration.If local node is an affinity node, this method will return the instance of started cache. Otherwise, it will create a near cache with the given configuration on local node.
If a cache with the same name already exists in the grid, an exception will be thrown regardless whether the given configuration matches the configuration of the existing cache or not.
- Specified by:
createCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheCfg- Cache configuration to use.nearCfg- Near cache configuration to use on local node in case it is not an affinity node.- Returns:
- Instance of started cache.
-
getOrCreateCache
public <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
Gets existing cache with the given cache configuration or creates one if it does not exist.If a cache with the same name already exist, this method will not check that the given configuration matches the configuration of existing cache and will return an instance of the existing cache.
If local node is not an affinity node and a client cache without near cache has been already started on this node, an exception will be thrown.
- Specified by:
getOrCreateCachein interfaceIgnite- Type Parameters:
K- type.V- type.- Parameters:
cacheCfg- Cache configuration.nearCfg- Near cache configuration for client.- Returns:
IgniteCacheinstance.
-
createNearCache
public <K,V> IgniteCache<K,V> createNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)
Starts a near cache on local node if cache was previously started with one of theIgnite.createCache(CacheConfiguration)orIgnite.createCache(CacheConfiguration, NearCacheConfiguration)methods.- Specified by:
createNearCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheName- Cache name.nearCfg- Near cache configuration.- Returns:
- Cache instance.
-
getOrCreateNearCache
public <K,V> IgniteCache<K,V> getOrCreateNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)
Gets existing near cache with the given name or creates a new one.- Specified by:
getOrCreateNearCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheName- Cache name.nearCfg- Near configuration.- Returns:
IgniteCacheinstance.
-
destroyCache
public void destroyCache(String cacheName)
Destroys a cache with the given name and cleans data that was written to the cache. The call will deallocate all resources associated with the given cache on all nodes in the cluster. There is no way to undo the action and recover destroyed data.All existing instances of
IgniteCachewill be invalidated, subsequent calls to the API will throw exceptions.If a cache with the specified name does not exist in the grid, the operation has no effect.
- Specified by:
destroyCachein interfaceIgnite- Parameters:
cacheName- Cache name to destroy.
-
destroyCache0
public boolean destroyCache0(String cacheName, boolean sql) throws javax.cache.CacheException
Stops dynamically started cache.- Specified by:
destroyCache0in interfaceIgniteEx- Parameters:
cacheName- Cache name to stop.sql-trueif only cache created with SQL commandCREATE TABLEshould be affected,falseotherwise.- Returns:
trueif cache has been stopped as the result of this call,falseotherwise.- Throws:
javax.cache.CacheException- If error occurs.
-
destroyCaches
public void destroyCaches(Collection<String> cacheNames)
Destroys caches with the given names and cleans data that was written to the caches. The call will deallocate all resources associated with the given caches on all nodes in the cluster. There is no way to undo the action and recover destroyed data.All existing instances of
IgniteCachewill be invalidated, subsequent calls to the API will throw exceptions.If the specified collection contains
nullor an empty value, this method will throwIllegalArgumentExceptionand the caches will not be destroyed.If a cache with the specified name does not exist in the grid, the specified value will be skipped.
- Specified by:
destroyCachesin interfaceIgnite- Parameters:
cacheNames- Collection of cache names to destroy.
-
destroyCacheAsync
public IgniteInternalFuture<Boolean> destroyCacheAsync(String cacheName, boolean sql, boolean checkThreadTx)
- Parameters:
cacheName- Cache name.sql- If the cache needs to be destroyed only if it was created by SQLCREATE TABLEcommand.checkThreadTx- Iftruechecks that current thread does not have active transactions.- Returns:
- Ignite future.
-
destroyCachesAsync
public IgniteInternalFuture<?> destroyCachesAsync(Collection<String> cacheNames, boolean checkThreadTx)
- Parameters:
cacheNames- Collection of cache names.checkThreadTx- Iftruechecks that current thread does not have active transactions.- Returns:
- Ignite future which will be completed when cache is destored.
-
getOrCreateCache
public <K,V> IgniteCache<K,V> getOrCreateCache(String cacheName)
Gets existing cache with the given name or creates new one using template configuration.- Specified by:
getOrCreateCachein interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheName- Cache name.- Returns:
- Existing or newly created cache.
-
getOrCreateCacheAsync
public IgniteInternalFuture<?> getOrCreateCacheAsync(String cacheName, String templateName, CacheConfigurationOverride cfgOverride, boolean checkThreadTx)
- Parameters:
cacheName- Cache name.templateName- Template name.cfgOverride- Cache config properties to override.checkThreadTx- Iftruechecks that current thread does not have active transactions.- Returns:
- Future that will be completed when cache is deployed.
-
addCacheConfiguration
public <K,V> void addCacheConfiguration(CacheConfiguration<K,V> cacheCfg)
Adds cache configuration template.- Specified by:
addCacheConfigurationin interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheCfg- Cache configuration template.
-
caches
public Collection<IgniteCacheProxy<?,?>> caches()
- Returns:
- Collection of public cache instances.
-
cacheNames
public Collection<String> cacheNames()
Gets the collection of names of currently available caches.- Specified by:
cacheNamesin interfaceIgnite- Returns:
- Collection of names of currently available caches or an empty collection if no caches are available.
-
utilityCache
public <K extends GridCacheUtilityKey,V> IgniteInternalCache<K,V> utilityCache()
Gets utility cache.- Specified by:
utilityCachein interfaceIgniteEx- Returns:
- Utility cache.
-
cachex
public <K,V> IgniteInternalCache<K,V> cachex(String name)
Gets the cache instance for the given name if one is configured or null otherwise returning even non-public caches.
-
cachesx
public Collection<IgniteInternalCache<?,?>> cachesx(IgnitePredicate<? super IgniteInternalCache<?,?>>[] p)
Gets configured cache instance that satisfy all provided predicates including non-public caches. If no predicates provided - all configured caches will be returned.
-
dataStreamer
public <K,V> IgniteDataStreamer<K,V> dataStreamer(String cacheName)
Gets a new instance of data streamer associated with given cache name. Data streamer is responsible for loading external data into in-memory data grid. For more information refer toIgniteDataStreamerdocumentation.- Specified by:
dataStreamerin interfaceIgnite- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cacheName- Cache name.- Returns:
- Data streamer.
-
plugin
public <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException
Gets an instance of deployed Ignite plugin.- Specified by:
pluginin interfaceIgnite- Type Parameters:
T- Plugin type.- Parameters:
name- Plugin name.- Returns:
- Plugin instance.
- Throws:
PluginNotFoundException- If plugin for the given name was not found.
-
binary
public IgniteBinary binary()
Gets an instance ofIgniteBinaryinterface.- Specified by:
binaryin interfaceIgnite- Returns:
- Instance of
IgniteBinaryinterface.
-
version
public IgniteProductVersion version()
Gets Ignite version.
-
latestVersion
public String latestVersion()
Get latest version in string form.- Specified by:
latestVersionin interfaceIgniteEx- Returns:
- Latest version.
-
scheduler
public IgniteScheduler scheduler()
Gets an instance of cron-based scheduler.
-
close
public void close() throws IgniteExceptionClosesthisinstance of grid. This method is identical to callingG.stop(igniteInstanceName, true).The method is invoked automatically on objects managed by the
try-with-resourcesstatement.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIgnite- Throws:
IgniteException- If failed to stop grid.
-
affinity
public <K> Affinity<K> affinity(String cacheName)
Gets affinity service to provide information about data partitioning and distribution.
-
active
public boolean active()
Checks Ignite grid is active or not active.
-
active
public void active(boolean active)
Changes Ignite grid state to active or inactive.NOTE: Deactivation clears in-memory caches (without persistence) including the system caches.
-
resetLostPartitions
public void resetLostPartitions(Collection<String> cacheNames)
Clears partition's lost state and moves caches to a normal mode.To avoid permanent data loss for persistent caches it's recommended to return all previously failed baseline nodes to the topology before calling this method.
- Specified by:
resetLostPartitionsin interfaceIgnite- Parameters:
cacheNames- Name of the caches for which lost partitions is reset.
-
dataRegionMetrics
public Collection<DataRegionMetrics> dataRegionMetrics()
Returns a collection ofDataRegionMetricsthat reflects page memory usage on this Apache Ignite node instance. Returns the collection that contains the latest snapshots for each memory region configured withconfigurationon this Ignite node instance.- Specified by:
dataRegionMetricsin interfaceIgnite- Returns:
- Collection of
DataRegionMetricssnapshots.
-
dataRegionMetrics
@Nullable public @Nullable DataRegionMetrics dataRegionMetrics(String memPlcName)
Returns the latestDataRegionMetricssnapshot for the memory region of the given name. To get the metrics for the default memory region useDataStorageConfiguration.DFLT_DATA_REG_DEFAULT_NAMEas the name or a custom name if the default memory region has been renamed.- Specified by:
dataRegionMetricsin interfaceIgnite- Parameters:
memPlcName- Name of memory region configured withconfig.- Returns:
DataRegionMetricssnapshot ornullif no memory region is configured under specified name.
-
tracingConfiguration
@NotNull public @NotNull TracingConfigurationManager tracingConfiguration()
Returns theTracingConfigurationManagerinstance that allows to- Configure tracing parameters such as sampling rate for the specific tracing coordinates such as scope and label.
- Retrieve the most specific tracing parameters for the specified tracing coordinates (scope and label)
- Restore the tracing parameters for the specified tracing coordinates to the default.
- List all pairs of tracing configuration coordinates and tracing configuration parameters.
- Specified by:
tracingConfigurationin interfaceIgnite- Returns:
TracingConfigurationManagerinstance.
-
encryption
public IgniteEncryption encryption()
Gets an instance ofIgniteEncryptioninterface.- Specified by:
encryptionin interfaceIgnite- Returns:
- Instance of
IgniteEncryptioninterface.
-
snapshot
public IgniteSnapshot snapshot()
-
memoryMetrics
public Collection<MemoryMetrics> memoryMetrics()
- Specified by:
memoryMetricsin interfaceIgnite- Returns:
- Collection of
MemoryMetricssnapshots.
-
memoryMetrics
@Nullable public @Nullable MemoryMetrics memoryMetrics(String memPlcName)
- Specified by:
memoryMetricsin interfaceIgnite- Parameters:
memPlcName- Name of the data region.- Returns:
MemoryMetricssnapshot ornullif no memory region is configured under specified name.
-
atomicSequence
@Nullable public @Nullable IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
Will get an atomic sequence from cache and create one if it has not been created yet andcreateflag istrue. It will use configuration fromIgniteConfiguration.getAtomicConfiguration().- Specified by:
atomicSequencein interfaceIgnite- Parameters:
name- Sequence name.initVal- Initial value for sequence. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Sequence for the given name.
-
atomicSequence
@Nullable public @Nullable IgniteAtomicSequence atomicSequence(String name, AtomicConfiguration cfg, long initVal, boolean create) throws IgniteException
Will get an atomic sequence from cache and create one if it has not been created yet andcreateflag istrue.- Specified by:
atomicSequencein interfaceIgnite- Parameters:
name- Sequence name.cfg- Configuration.initVal- Initial value for sequence. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Sequence for the given name.
- Throws:
IgniteException- If sequence could not be fetched or created.
-
atomicLong
@Nullable public @Nullable IgniteAtomicLong atomicLong(String name, long initVal, boolean create)
Will get a atomic long from cache and create one if it has not been created yet andcreateflag istrue.- Specified by:
atomicLongin interfaceIgnite- Parameters:
name- Name of atomic long.initVal- Initial value for atomic long. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Atomic long.
-
atomicLong
@Nullable public @Nullable IgniteAtomicLong atomicLong(String name, AtomicConfiguration cfg, long initVal, boolean create) throws IgniteException
Will get a atomic long from cache and create one if it has not been created yet andcreateflag istrue.- Specified by:
atomicLongin interfaceIgnite- Parameters:
name- Name of atomic long.cfg- Configuration.initVal- Initial value for atomic long. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Atomic long.
- Throws:
IgniteException- If atomic long could not be fetched or created.
-
atomicReference
@Nullable public <T> @Nullable IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, boolean create)
Will get a atomic reference from cache and create one if it has not been created yet andcreateflag istrue. It will use configuration fromIgniteConfiguration.getAtomicConfiguration().- Specified by:
atomicReferencein interfaceIgnite- Type Parameters:
T- Type of object referred to by this reference.- Parameters:
name- Atomic reference name.initVal- Initial value for atomic reference. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Atomic reference for the given name.
-
atomicReference
public <T> IgniteAtomicReference<T> atomicReference(String name, AtomicConfiguration cfg, @Nullable T initVal, boolean create) throws IgniteException
Will get a atomic reference from cache and create one if it has not been created yet andcreateflag istrue.- Specified by:
atomicReferencein interfaceIgnite- Type Parameters:
T- Type of object referred to by this reference.- Parameters:
name- Atomic reference name.cfg- Configuration.initVal- Initial value for atomic reference. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Atomic reference for the given name.
- Throws:
IgniteException- If atomic reference could not be fetched or created.
-
atomicStamped
@Nullable public <T,S> @Nullable IgniteAtomicStamped<T,S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp, boolean create)
Will get a atomic stamped from cache and create one if it has not been created yet andcreateflag istrue.- Specified by:
atomicStampedin interfaceIgnite- Type Parameters:
T- Type of object referred to by this atomic.S- Type of stamp object.- Parameters:
name- Atomic stamped name.initVal- Initial value for atomic stamped. Ignored ifcreateflag isfalse.initStamp- Initial stamp for atomic stamped. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Atomic stamped for the given name.
-
atomicStamped
public <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, AtomicConfiguration cfg, @Nullable T initVal, @Nullable S initStamp, boolean create) throws IgniteException
Will get a atomic stamped from cache and create one if it has not been created yet andcreateflag istrue.- Specified by:
atomicStampedin interfaceIgnite- Type Parameters:
T- Type of object referred to by this atomic.S- Type of stamp object.- Parameters:
name- Atomic stamped name.cfg- Configuration.initVal- Initial value for atomic stamped. Ignored ifcreateflag isfalse.initStamp- Initial stamp for atomic stamped. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Atomic stamped for the given name.
- Throws:
IgniteException- If atomic stamped could not be fetched or created.
-
countDownLatch
@Nullable public @Nullable IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, boolean create)
Gets or creates count down latch. If count down latch is not found in cache andcreateflag istrue, it is created using provided name and count parameter.- Specified by:
countDownLatchin interfaceIgnite- Parameters:
name- Name of the latch.cnt- Count for new latch creation. Ignored ifcreateflag isfalse.autoDel-Trueto automatically delete latch from cache when its count reaches zero. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Count down latch for the given name.
-
semaphore
@Nullable public @Nullable IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe, boolean create)
Gets or creates semaphore. If semaphore is not found in cache andcreateflag istrue, it is created using provided name and count parameter.- Specified by:
semaphorein interfaceIgnite- Parameters:
name- Name of the semaphore.cnt- Count for new semaphore creation. Ignored ifcreateflag isfalse.failoverSafe-Trueto create failover safe semaphore which means that if any node leaves topology permits already acquired by that node are silently released and become available for alive nodes to acquire. If flag isfalsethen all threads waiting for available permits get interrupted.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- Semaphore for the given name.
-
reentrantLock
@Nullable public @Nullable IgniteLock reentrantLock(String name, boolean failoverSafe, boolean fair, boolean create)
Gets or creates reentrant lock. If reentrant lock is not found in cache andcreateflag istrue, it is created using provided name.- Specified by:
reentrantLockin interfaceIgnite- Parameters:
name- Name of the lock.failoverSafe-Trueto create failover safe lock which means that if any node leaves topology, all locks already acquired by that node are silently released and become available for other nodes to acquire. If flag isfalsethen all threads on other nodes waiting to acquire lock are interrupted.fair- IfTrue, fair lock will be created.create- Boolean flag indicating whether data structure should be created if does not exist.- Returns:
- ReentrantLock for the given name.
-
queue
@Nullable public <T> @Nullable IgniteQueue<T> queue(String name, int cap, CollectionConfiguration cfg)
Will get a named queue from cache and create one if it has not been created yet andcfgis notnull. If queue is present already, queue properties will not be changed. Use collocation forCacheMode.PARTITIONEDcaches if you have lots of relatively small queues as it will make fetching, querying, and iteration a lot faster. If you have few very large queues, then you should consider turning off collocation as they simply may not fit in a single node's memory.
-
set
@Nullable public <T> @Nullable IgniteSet<T> set(String name, CollectionConfiguration cfg)
Will get a named set from cache and create one if it has not been created yet andcfgis notnull.
-
set
public <T> IgniteSet<T> set(String name, int cacheId, boolean collocated, boolean separated) throws IgniteException
Gets a set from cache by known cache id. Does not create new sets.- Specified by:
setin interfaceIgniteEx- Type Parameters:
T- Type of the elements in set.- Parameters:
name- Set name.cacheId- Cache id.collocated- Colocated mode flag.separated- Separated cache flag.- Returns:
- Set with given properties.
- Throws:
IgniteException- If set could not be fetched or created.
-
commandsRegistry
public IgniteCommandRegistry commandsRegistry()
- Specified by:
commandsRegistryin interfaceIgniteEx- Returns:
- Registry with all management commands known by node.
- See Also:
Command
-
onDisconnected
public void onDisconnected()
Method is responsible for handling theEventType.EVT_CLIENT_NODE_DISCONNECTEDevent. Notify all the GridComponents that the such even has been occurred (e.g. if the local client node disconnected from the cluster components will be notified with a future which will be completed when the client is reconnected).
-
onReconnected
public void onReconnected(boolean clusterRestarted)
- Parameters:
clusterRestarted-Trueif all cluster nodes restarted while client was disconnected.
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Throws:
IOExceptionClassNotFoundException
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternalin interfaceExternalizable- Throws:
IOException
-
readResolve
protected Object readResolve() throws ObjectStreamException
- Returns:
- IgniteKernal instance.
- Throws:
ObjectStreamException- If failed.
-
dumpDebugInfo
public void dumpDebugInfo()
Dumps debug information for the current node.
-
sendIoTest
public IgniteInternalFuture sendIoTest(ClusterNode node, byte[] payload, boolean procFromNioThread)
- Parameters:
node- Node.payload- Message payload.procFromNioThread- Iftruemessage is processed from NIO thread.- Returns:
- Response future.
-
sendIoTest
public IgniteInternalFuture sendIoTest(List<ClusterNode> nodes, byte[] payload, boolean procFromNioThread)
- Parameters:
nodes- Nodes.payload- Message payload.procFromNioThread- Iftruemessage is processed from NIO thread.- Returns:
- Response future.
-
-