public class IgniteSpringBean extends Object implements Ignite, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.SmartInitializingSingleton, 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 SmartInitializingSingleton
interfaces, IgniteSpringBean automatically starts and stops underlying
grid instance.
A note should be taken that Ignite instance is started after all other
Spring beans have been initialized and right before Spring context is refreshed.
That implies that it's not valid to reference IgniteSpringBean from
any kind of Spring bean init methods like PostConstruct.
If it's required to reference IgniteSpringBean for other bean
initialization purposes, it should be done from a ContextRefreshedEvent
listener method declared in that bean.
<bean id="mySpringBean" class="org.apache.ignite.IgniteSpringBean">
<property name="configuration">
<bean id="grid.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="igniteInstanceName" value="mySpringGrid"/>
</bean>
</property>
</bean>
Or use default configuration:
<bean id="mySpringBean" class="org.apache.ignite.IgniteSpringBean"/>
AbstractApplicationContext ctx = new FileSystemXmlApplicationContext("/path/to/spring/file");
// Register Spring hook to destroy bean automatically.
ctx.registerShutdownHook();
Ignite ignite = (Ignite)ctx.getBean("mySpringBean");
| Constructor and Description |
|---|
IgniteSpringBean() |
public IgniteConfiguration configuration()
configuration in interface Ignitepublic IgniteConfiguration getConfiguration()
This method is required for proper Spring integration and is the same as
configuration().
See https://issues.apache.org/jira/browse/IGNITE-1102 for details.
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()public void setConfiguration(IgniteConfiguration cfg)
cfg - Ignite configuration.public org.springframework.context.ApplicationContext getApplicationContext()
throws org.springframework.beans.BeansException
org.springframework.beans.BeansExceptionpublic 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 afterSingletonsInstantiated()
afterSingletonsInstantiated in interface org.springframework.beans.factory.SmartInitializingSingletonpublic IgniteLogger log()
public IgniteProductVersion version()
public IgniteCompute compute()
public IgniteServices services()
public IgniteMessaging message()
public IgniteEvents events()
public ExecutorService executorService()
executorService in interface Ignitepublic IgniteCluster cluster()
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 Ignitepublic IgniteScheduler scheduler()
public void resetLostPartitions(Collection<String> cacheNames)
resetLostPartitions in interface Ignitepublic Collection<DataRegionMetrics> dataRegionMetrics()
dataRegionMetrics in interface Ignite@Nullable public DataRegionMetrics dataRegionMetrics(String memPlcName)
dataRegionMetrics in interface Ignitepublic DataStorageMetrics dataStorageMetrics()
dataStorageMetrics in interface Ignitepublic Collection<MemoryMetrics> memoryMetrics()
memoryMetrics in interface Ignite@Nullable public MemoryMetrics memoryMetrics(String memPlcName)
memoryMetrics in interface Ignitepublic PersistenceMetrics persistentStoreMetrics()
persistentStoreMetrics in interface Ignitepublic <K,V> IgniteCache<K,V> cache(@Nullable String name)
public Collection<String> cacheNames()
cacheNames in interface Ignitepublic <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg)
createCache in interface Ignitepublic <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg)
getOrCreateCache in interface Ignitepublic <K,V> IgniteCache<K,V> createCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
createCache in interface Ignitepublic Collection<IgniteCache> createCaches(Collection<CacheConfiguration> cacheCfgs)
createCaches in interface Ignitepublic <K,V> IgniteCache<K,V> getOrCreateCache(CacheConfiguration<K,V> cacheCfg, NearCacheConfiguration<K,V> nearCfg)
getOrCreateCache in interface Ignitepublic <K,V> IgniteCache<K,V> createNearCache(String cacheName, NearCacheConfiguration<K,V> nearCfg)
createNearCache in interface Ignitepublic <K,V> IgniteCache<K,V> getOrCreateNearCache(@Nullable String cacheName, NearCacheConfiguration<K,V> nearCfg)
getOrCreateNearCache in interface Ignitepublic <K,V> IgniteCache<K,V> getOrCreateCache(String cacheName)
getOrCreateCache in interface Ignitepublic Collection<IgniteCache> getOrCreateCaches(Collection<CacheConfiguration> cacheCfgs)
getOrCreateCaches in interface Ignitepublic <K,V> IgniteCache<K,V> createCache(String cacheName)
createCache in interface Ignitepublic <K,V> void addCacheConfiguration(CacheConfiguration<K,V> cacheCfg)
addCacheConfiguration in interface Ignitepublic void destroyCache(String cacheName)
destroyCache in interface Ignitepublic void destroyCaches(Collection<String> cacheNames)
destroyCaches in interface Ignitepublic IgniteTransactions transactions()
transactions in interface Ignitepublic <K,V> IgniteDataStreamer<K,V> dataStreamer(@Nullable String cacheName)
dataStreamer in interface Ignitepublic IgniteFileSystem fileSystem(String name)
fileSystem in interface Ignitepublic Collection<IgniteFileSystem> fileSystems()
fileSystems in interface Ignitepublic <T extends IgnitePlugin> T plugin(String name) throws PluginNotFoundException
plugin in interface IgnitePluginNotFoundExceptionpublic IgniteBinary binary()
public void close()
throws IgniteException
close in interface AutoCloseableclose in interface IgniteIgniteException@Nullable public IgniteAtomicSequence atomicSequence(String name, long initVal, boolean create)
atomicSequence in interface Ignitepublic IgniteAtomicSequence atomicSequence(String name, AtomicConfiguration cfg, long initVal, boolean create) throws IgniteException
atomicSequence in interface IgniteIgniteException@Nullable public IgniteAtomicLong atomicLong(String name, long initVal, boolean create)
atomicLong in interface Ignitepublic IgniteAtomicLong atomicLong(String name, AtomicConfiguration cfg, long initVal, boolean create) throws IgniteException
atomicLong in interface IgniteIgniteException@Nullable public <T> IgniteAtomicReference<T> atomicReference(String name, @Nullable T initVal, boolean create)
atomicReference in interface Ignitepublic <T> IgniteAtomicReference<T> atomicReference(String name, AtomicConfiguration cfg, @Nullable T initVal, boolean create) throws IgniteException
atomicReference in interface IgniteIgniteException@Nullable public <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, @Nullable T initVal, @Nullable S initStamp, boolean create)
atomicStamped in interface Ignitepublic <T,S> IgniteAtomicStamped<T,S> atomicStamped(String name, AtomicConfiguration cfg, @Nullable T initVal, @Nullable S initStamp, boolean create) throws IgniteException
atomicStamped in interface IgniteIgniteException@Nullable public IgniteCountDownLatch countDownLatch(String name, int cnt, boolean autoDel, boolean create)
countDownLatch in interface Ignite@Nullable public IgniteSemaphore semaphore(String name, int cnt, boolean failoverSafe, boolean create)
@Nullable public IgniteLock reentrantLock(String name, boolean failoverSafe, boolean fair, boolean create)
reentrantLock in interface Ignite@Nullable public <T> IgniteQueue<T> queue(String name, int cap, CollectionConfiguration cfg)
@Nullable public <T> IgniteSet<T> set(String name, CollectionConfiguration cfg)
public void writeExternal(ObjectOutput out) throws IOException
writeExternal in interface ExternalizableIOExceptionpublic void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionprotected void checkIgnite()
throws IllegalStateException
IllegalStateException - If bean is not valid, i.e. Ignite has already been stopped
or has not yet been started.
Follow @ApacheIgnite
Ignite Fabric : ver. 2.4.5-p3 Release Date : August 21 2018