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> CacheAffinity<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 . |
void |
close()
Closes
this instance of grid. |
IgniteCluster |
cluster()
Gets an instance of
IgniteCluster interface. |
IgniteCompute |
compute()
Gets
compute functionality over this grid projection. |
IgniteCompute |
compute(ClusterGroup grp) |
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> IgniteDataLoader<K,V> |
dataLoader(String cacheName)
Gets a new instance of data loader associated with given cache name.
|
void |
destroy() |
IgniteEvents |
events()
Gets
events functionality over this grid projection. |
IgniteEvents |
events(ClusterGroup grp) |
ExecutorService |
executorService()
Creates new
ExecutorService which will execute all submitted
Callable and Runnable jobs on nodes in this grid projection. |
ExecutorService |
executorService(ClusterGroup grp) |
IgniteFs |
fileSystem(String name)
Gets an instance of IGFS - Ignite In-Memory File System, if one is not
configured then
IllegalArgumentException will be thrown. |
Collection<IgniteFs> |
fileSystems()
Gets all instances of the grid file systems.
|
<K,V> IgniteCache<K,V> |
jcache(String name)
Gets an instance of
IgniteCache API. |
IgniteLogger |
log()
Gets grid's logger.
|
IgniteMessaging |
message()
Gets
messaging functionality over this grid projection. |
IgniteMessaging |
message(ClusterGroup prj) |
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.
|
IgniteServices |
services()
Gets
services functionality over this grid projection. |
IgniteServices |
services(ClusterGroup grp) |
<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.
|
IgniteStreamer |
streamer(String name)
Gets an instance of streamer by name, if one does not exist then
IllegalArgumentException will be thrown. |
Collection<IgniteStreamer> |
streamers()
Gets all instances of streamers.
|
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 Ignite
public 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.ApplicationContextAware
org.springframework.beans.BeansException
public void destroy() throws Exception
destroy
in interface org.springframework.beans.factory.DisposableBean
Exception
public void afterPropertiesSet() throws Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
Exception
public IgniteLogger log()
public IgniteProductVersion version()
public Collection<IgniteStreamer> streamers()
public IgniteCompute compute()
compute
functionality over this grid projection. All operations
on the returned IgniteCompute
instance will only include nodes from
this projection.public IgniteServices services()
services
functionality over this grid projection. All operations
on the returned IgniteMessaging
instance will only include nodes from
this projection.public IgniteMessaging message()
messaging
functionality over this grid projection. All operations
on the returned IgniteMessaging
instance will only include nodes from
this projection.public IgniteEvents events()
events
functionality over this grid projection. All operations
on the returned IgniteEvents
instance will only include nodes from
this projection.public ExecutorService executorService()
ExecutorService
which will execute all submitted
Callable
and Runnable
jobs on nodes in this grid projection.
This essentially
creates a Distributed Thread Pool that can be used as a
replacement for local thread pools.executorService
in interface Ignite
ExecutorService
.public IgniteCluster cluster()
IgniteCluster
interface.cluster
in interface Ignite
IgniteCluster
interface.public IgniteCompute compute(ClusterGroup grp)
public IgniteMessaging message(ClusterGroup prj)
public IgniteEvents events(ClusterGroup grp)
public IgniteServices services(ClusterGroup grp)
public ExecutorService executorService(ClusterGroup grp)
executorService
in interface Ignite
grp
- 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> jcache(@Nullable String name)
IgniteCache
API. IgniteCache
is a fully-compatible
implementation of JCache (JSR 107)
specification.public IgniteTransactions transactions()
transactions
in interface Ignite
public <K,V> IgniteDataLoader<K,V> dataLoader(@Nullable String cacheName)
IgniteDataLoader
documentation.dataLoader
in interface Ignite
cacheName
- Cache name (null
for default cache).public IgniteFs 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 Ignite
name
- IGFS name.public Collection<IgniteFs> fileSystems()
fileSystems
in interface Ignite
@Nullable public IgniteStreamer streamer(@Nullable String name)
IllegalArgumentException
will be thrown.public <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException
plugin
in interface Ignite
T
- Plugin type.name
- Plugin name.PluginNotFoundException
- If plugin for the given name was not found.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 AutoCloseable
close
in interface Ignite
IgniteException
- If failed to stop grid.@Nullable public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
create
flag
is true
.atomicSequence
in interface Ignite
name
- 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 Ignite
name
- 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 Ignite
name
- 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 Ignite
name
- 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 Ignite
name
- 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 <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> CacheAffinity<K> affinity(String cacheName)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal
in interface Externalizable
IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal
in interface Externalizable
IOException
ClassNotFoundException
Follow @ApacheIgnite
Apache Ignite Fabric : ver. 1.0.0-RC1 Release Date : February 16 2015