public class IgniteSpringBean extends Object implements Ignite, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, Externalizable
Ignition methods.
In other words, this bean class allows to inject new grid instance from
Spring configuration file directly without invoking static
Ignition methods. This class can be wired directly from
Spring and can be referenced from within other Spring beans.
By virtue of implementing DisposableBean and InitializingBean
interfaces, GridSpringBean automatically starts and stops underlying
grid instance.
<bean id="mySpringBean" class="org.apache.ignite.GridSpringBean">
<property name="configuration">
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="gridName" value="mySpringGrid"/>
</bean>
</property>
</bean>
Or use default configuration:
<bean id="mySpringBean" class="org.apache.ignite.GridSpringBean"/>
AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("/path/to/spring/file");
// Register Spring hook to destroy bean automatically.
ctx.registerShutdownHook();
Grid grid = (Grid)ctx.getBean("mySpringBean");
| Constructor and Description |
|---|
IgniteSpringBean() |
| Modifier and Type | Method and Description |
|---|---|
<K,V> void |
addCacheConfiguration(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.
|
void |
afterPropertiesSet() |
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 and
create flag
is true. |
<T> 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 and
create flag
is true. |
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 and
create flag
is true. |
<T,S> 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 and
create flag
is true. |
IgniteBinary |
binary()
Gets an instance of
IgniteBinary interface. |
<K,V> IgniteCache<K,V> |
cache(String name)
Gets an instance of
IgniteCache API. |
Collection<String> |
cacheNames()
Gets the collection of names of currently available caches.
|
void |
close()
Closes
this instance of grid. |
IgniteCluster |
cluster()
Gets an instance of
IgniteCluster interface. |
IgniteCompute |
compute()
Gets
compute facade over all cluster nodes started in server mode. |
IgniteCompute |
compute(ClusterGroup grp)
Gets
compute facade over the specified cluster group. |
IgniteConfiguration |
configuration()
Gets the configuration of this grid instance.
|
IgniteCountDownLatch |
countDownLatch(String name,
int cnt,
boolean autoDel,
boolean create)
Gets or creates count down latch.
|
<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.
|
<K,V> IgniteCache<K,V> |
createCache(String cacheName)
Dynamically starts new cache using template configuration.
|
<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 the
Ignite.createCache(CacheConfiguration) or Ignite.createCache(CacheConfiguration, NearCacheConfiguration)
methods. |
<K,V> IgniteDataStreamer<K,V> |
dataStreamer(String cacheName)
Gets a new instance of data streamer associated with given cache name.
|
void |
destroy() |
void |
destroyCache(String cacheName)
Stops dynamically started cache.
|
IgniteEvents |
events()
Gets
events facade over all cluster nodes. |
IgniteEvents |
events(ClusterGroup grp)
Gets
events facade over nodes within the cluster group. |
ExecutorService |
executorService()
Creates a new
ExecutorService which will execute all submitted
Callable and Runnable jobs on all cluster nodes. |
ExecutorService |
executorService(ClusterGroup grp)
Creates a new
ExecutorService which will execute all submitted
Callable and Runnable jobs on nodes in the specified cluster group. |
IgniteFileSystem |
fileSystem(String name)
Gets an instance of IGFS (Ignite In-Memory File System).
|
Collection<IgniteFileSystem> |
fileSystems()
Gets all instances of IGFS (Ignite In-Memory File System).
|
<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> 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> |
getOrCreateNearCache(String cacheName,
NearCacheConfiguration<K,V> nearCfg)
Gets existing near cache with the given name or creates a new one.
|
IgniteLogger |
log()
Gets grid's logger.
|
IgniteMessaging |
message()
Gets
messaging facade over all cluster nodes. |
IgniteMessaging |
message(ClusterGroup prj)
Gets
messaging facade over nodes within the cluster group. |
String |
name()
Gets the name of the grid this grid instance (and correspondingly its local node) belongs to.
|
<T extends IgnitePlugin> |
plugin(String name)
Gets an instance of deployed Ignite plugin.
|
<T> 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 and
cfg is not
null. |
void |
readExternal(ObjectInput in) |
IgniteScheduler |
scheduler()
Gets an instance of cron-based scheduler.
|
IgniteSemaphore |
semaphore(String name,
int cnt,
boolean failoverSafe,
boolean create)
Gets or creates semaphore.
|
IgniteServices |
services()
Gets
services facade over all cluster nodes started in server mode. |
IgniteServices |
services(ClusterGroup grp)
Gets
services facade over nodes within the cluster group. |
<T> IgniteSet<T> |
set(String name,
CollectionConfiguration cfg)
Will get a named set from cache and create one if it has not been created yet and
cfg is not
null. |
void |
setApplicationContext(org.springframework.context.ApplicationContext ctx) |
void |
setConfiguration(IgniteConfiguration cfg)
Sets grid configuration.
|
String |
toString() |
IgniteTransactions |
transactions()
Gets grid transactions facade.
|
IgniteProductVersion |
version()
Gets Ignite version.
|
void |
writeExternal(ObjectOutput out) |
public IgniteConfiguration configuration()
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.
configuration in interface Ignitepublic void setConfiguration(IgniteConfiguration cfg)
cfg - Grid configuration.public void setApplicationContext(org.springframework.context.ApplicationContext ctx)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionpublic void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionpublic void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic IgniteLogger log()
public IgniteProductVersion version()
public IgniteCompute compute()
compute facade over all cluster nodes started in server mode.public IgniteServices services()
services facade over all cluster nodes started in server mode.public IgniteMessaging message()
messaging facade over all cluster nodes.public IgniteEvents events()
events facade over all cluster nodes.public ExecutorService executorService()
ExecutorService which will execute all submitted
Callable and Runnable jobs on all cluster nodes.
This essentially creates a Distributed Thread Pool that can
be used as a replacement for local thread pools.executorService in interface IgniteExecutorService.public IgniteCluster cluster()
IgniteCluster interface.cluster in interface IgniteIgniteCluster interface.public IgniteCompute compute(ClusterGroup grp)
compute facade over the specified cluster group. All operations
on the returned IgniteCompute instance will only include nodes from
this cluster group.public IgniteMessaging message(ClusterGroup prj)
messaging facade over nodes within the cluster group. All operations
on the returned IgniteMessaging instance will only include nodes from
the specified cluster group.public IgniteEvents events(ClusterGroup grp)
events facade over nodes within the cluster group. All operations
on the returned IgniteEvents instance will only include nodes from
the specified cluster group.public IgniteServices services(ClusterGroup grp)
services facade over nodes within the cluster group. All operations
on the returned IgniteMessaging instance will only include nodes from
the specified cluster group.public ExecutorService executorService(ClusterGroup grp)
ExecutorService which will execute all submitted
Callable and Runnable jobs 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.executorService in interface Ignitegrp - Cluster group.ExecutorService which will execute jobs on nodes in given cluster group.public IgniteScheduler scheduler()
public String name()
If default grid instance is used, then
null is returned. Refer to Ignition documentation
for information on how to start named grids.
public <K,V> IgniteCache<K,V> cache(@Nullable String name)
IgniteCache API. IgniteCache is a fully-compatible
implementation of JCache (JSR 107) specification.public Collection<String> cacheNames()
null as a value for a cache name. Refer to CacheConfiguration.getName()
for more info.cacheNames in interface Ignitepublic <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg)
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.
createCache in interface IgnitecacheCfg - Cache configuration to use.public <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg)
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.
getOrCreateCache in interface IgnitecacheCfg - Cache configuration to use.public <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
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.
createCache in interface IgnitecacheCfg - Cache configuration to use.nearCfg - Near cache configuration to use on local node in case it is not an
affinity node.public <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
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.
getOrCreateCache in interface IgnitecacheCfg - Cache configuration.nearCfg - Near cache configuration for client.IgniteCache instance.public <K,V> IgniteCache<K,V> createNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)
Ignite.createCache(CacheConfiguration) or Ignite.createCache(CacheConfiguration, NearCacheConfiguration)
methods.createNearCache in interface IgnitecacheName - Cache name.nearCfg - Near cache configuration.public <K,V> IgniteCache<K,V> getOrCreateNearCache(@Nullable String cacheName, NearCacheConfiguration<K,V> nearCfg)
getOrCreateNearCache in interface IgnitecacheName - Cache name.nearCfg - Near configuration.IgniteCache instance.public <K,V> IgniteCache<K,V> getOrCreateCache(String cacheName)
getOrCreateCache in interface IgnitecacheName - Cache name.public <K,V> IgniteCache<K,V> createCache(String cacheName)
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.
createCache in interface IgnitecacheName - Cache name.public <K,V> void addCacheConfiguration(CacheConfiguration<K,V> cacheCfg)
addCacheConfiguration in interface IgnitecacheCfg - Cache configuration template.public void destroyCache(String cacheName)
destroyCache in interface IgnitecacheName - Cache name to stop.public IgniteTransactions transactions()
transactions in interface Ignitepublic <K,V> IgniteDataStreamer<K,V> dataStreamer(@Nullable String cacheName)
IgniteDataStreamer documentation.dataStreamer in interface IgnitecacheName - Cache name (null for default cache).public IgniteFileSystem fileSystem(String name)
IllegalArgumentException will be thrown.
IGFS is fully compliant with Hadoop FileSystem APIs and can
be plugged into Hadoop installations. For more information refer to
documentation on Hadoop integration shipped with Ignite.
fileSystem in interface Ignitename - IGFS name.public Collection<IgniteFileSystem> fileSystems()
fileSystems in interface Ignitepublic <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException
plugin in interface IgniteT - Plugin type.name - Plugin name.PluginNotFoundException - If plugin for the given name was not found.public IgniteBinary binary()
IgniteBinary interface.binary in interface IgniteIgniteBinary interface.public void close()
throws IgniteException
this instance of grid. This method is identical to calling
G.stop(gridName, true).
The method is invoked automatically on objects managed by the
try-with-resources statement.
close in interface AutoCloseableclose in interface IgniteIgniteException - If failed to stop grid.@Nullable public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
create flag
is true.atomicSequence in interface Ignitename - Sequence name.initVal - Initial value for sequence. Ignored if create flag is false.create - Boolean flag indicating whether data structure should be created if does not exist.@Nullable public IgniteAtomicLong atomicLong(String name, long initVal, boolean create)
create flag
is true.atomicLong in interface Ignitename - Name of atomic long.initVal - Initial value for atomic long. Ignored if create flag is false.create - Boolean flag indicating whether data structure should be created if does not exist.@Nullable public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, boolean create)
create flag
is true.atomicReference in interface Ignitename - Atomic reference name.initVal - Initial value for atomic reference. Ignored if create flag is false.create - Boolean flag indicating whether data structure should be created if does not exist.@Nullable public <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp, boolean create)
create flag
is true.atomicStamped in interface Ignitename - Atomic stamped name.initVal - Initial value for atomic stamped. Ignored if create flag is false.initStamp - Initial stamp for atomic stamped. Ignored if create flag is false.create - Boolean flag indicating whether data structure should be created if does not exist.@Nullable public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, boolean create)
create flag
is true, it is created using provided name and count parameter.countDownLatch in interface Ignitename - Name of the latch.cnt - Count for new latch creation. Ignored if create flag is false.autoDel - True to automatically delete latch from cache when its count reaches zero.
Ignored if create flag is false.create - Boolean flag indicating whether data structure should be created if does not exist.@Nullable public IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe, boolean create)
create flag
is true, it is created using provided name and count parameter.semaphore in interface Ignitename - Name of the semaphore.cnt - Count for new semaphore creation. Ignored if create flag is false.failoverSafe - True to 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 is false then
all threads waiting for available permits get interrupted.create - Boolean flag indicating whether data structure should be created if does not exist.@Nullable public <T> IgniteQueue<T> queue(String name, int cap, CollectionConfiguration cfg)
cfg is not
null.
If queue is present already, queue properties will not be changed. Use
collocation for CacheMode.PARTITIONED caches 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.@Nullable public <T> IgniteSet<T> set(String name, CollectionConfiguration cfg)
cfg is not
null.public <K> Affinity<K> affinity(String cacheName)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundException
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016