Package org.apache.ignite
Class IgniteClientSpringBean
- java.lang.Object
- 
- org.apache.ignite.IgniteClientSpringBean
 
- 
- All Implemented Interfaces:
- AutoCloseable,- IgniteClient,- org.springframework.context.Lifecycle,- org.springframework.context.Phased,- org.springframework.context.SmartLifecycle
 
 public class IgniteClientSpringBean extends Object implements IgniteClient, org.springframework.context.SmartLifecycle Represents Ignite client Spring bean that provides the ability to automatically start Ignite client during Spring Context initialization. It requiresClientConfigurationto be set before bean use (seesetClientConfiguration(ClientConfiguration)}). A note should be taken that Ignite client 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 referenceIgniteClientSpringBeanfrom any kind of Spring bean init methods likePostConstruct. If it's required to referenceIgniteClientSpringBeanfor other bean initialization purposes, it should be done from aContextRefreshedEventlistener method declared in that bean.Spring XML Configuration Example<bean id="igniteClient" class="org.apache.ignite.IgniteClientSpringBean"> <property name="clientConfiguration"> <bean class="org.apache.ignite.configuration.ClientConfiguration"> <property name="addresses"> <list> <value>127.0.0.1:10800</value> </list> </property> </bean> </property> </bean>
- 
- 
Field SummaryFields Modifier and Type Field Description static intDFLT_IGNITE_CLI_LIFECYCLE_PHASEDefault Ignite clientSmartLifecyclephase.
 - 
Constructor SummaryConstructors Constructor Description IgniteClientSpringBean()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ClientAtomicLongatomicLong(String name, long initVal, boolean create)Gets an atomic long from cache and creates one if it has not been created yet andcreateflag istrue.ClientAtomicLongatomicLong(String name, ClientAtomicConfiguration cfg, long initVal, boolean create)Gets an atomic long from cache and creates one if it has not been created yet andcreateflag istrue.IgniteBinarybinary()<K,V>
 ClientCache<K,V>cache(String name)Get existing cache.Collection<String>cacheNames()Gets the names of all available caches.IgniteClientFuture<Collection<String>>cacheNamesAsync()Gets the names of all available caches.voidclose()Closes this client's open connections and relinquishes all underlying resources.ClientClustercluster()Gets client cluster facade.ClientComputecompute()Gets compute facade over all cluster nodes started in server mode.ClientComputecompute(ClientClusterGroup grp)Gets compute facade over the specified cluster group.<K,V>
 ClientCache<K,V>createCache(String name)Creates a cache with a default configuration.<K,V>
 ClientCache<K,V>createCache(ClientCacheConfiguration cfg)Creates a cache with the specified configuration.<K,V>
 IgniteClientFuture<ClientCache<K,V>>createCacheAsync(String name)Creates a cache with a default configuration.<K,V>
 IgniteClientFuture<ClientCache<K,V>>createCacheAsync(ClientCacheConfiguration cfg)Creates a cache with the specified configuration.voiddestroyCache(String name)Destroys the cache with the given name.IgniteClientFuture<Void>destroyCacheAsync(String name)Destroys the cache with the given name.ClientConfigurationgetClientConfiguration()<K,V>
 ClientCache<K,V>getOrCreateCache(String name)Gets the existing cache or creates a new cache with default configuration if it does not exist.<K,V>
 ClientCache<K,V>getOrCreateCache(ClientCacheConfiguration cfg)Gets the existing cache or creates a new cache if it does not exist.<K,V>
 IgniteClientFuture<ClientCache<K,V>>getOrCreateCacheAsync(String name)Gets the existing cache or creates a new cache with default configuration if it does not exist.<K,V>
 IgniteClientFuture<ClientCache<K,V>>getOrCreateCacheAsync(ClientCacheConfiguration cfg)Gets the existing cache or creates a new cache if it does not exist.intgetPhase()booleanisAutoStartup()booleanisRunning()FieldsQueryCursor<List<?>>query(SqlFieldsQuery qry)Execute SQL query and get cursor to iterate over results.ClientServicesservices()Getsservicesfacade over all cluster nodes started in server mode.ClientServicesservices(ClientClusterGroup grp)Getsservicesfacade over nodes within the cluster group.<T> ClientIgniteSet<T>set(String name, @Nullable ClientCollectionConfiguration cfg)Gets a distributed set from cache.IgniteClientSpringBeansetClientConfiguration(ClientConfiguration cfg)Sets Ignite client configuration.IgniteClientSpringBeansetPhase(int phase)SetsSmartLifecyclephase during which the current bean will be initialized.voidstart()voidstop()voidstop(Runnable callback)ClientTransactionstransactions()Gets client transactions facade.
 
- 
- 
- 
Field Detail- 
DFLT_IGNITE_CLI_LIFECYCLE_PHASEpublic static final int DFLT_IGNITE_CLI_LIFECYCLE_PHASE Default Ignite clientSmartLifecyclephase.- See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
isAutoStartuppublic boolean isAutoStartup() - Specified by:
- isAutoStartupin interface- org.springframework.context.SmartLifecycle
 
 - 
stoppublic void stop(Runnable callback) - Specified by:
- stopin interface- org.springframework.context.SmartLifecycle
 
 - 
stoppublic void stop() - Specified by:
- stopin interface- org.springframework.context.Lifecycle
 
 - 
isRunningpublic boolean isRunning() - Specified by:
- isRunningin interface- org.springframework.context.Lifecycle
 
 - 
startpublic void start() - Specified by:
- startin interface- org.springframework.context.Lifecycle
 
 - 
getPhasepublic int getPhase() - Specified by:
- getPhasein interface- org.springframework.context.Phased
- Specified by:
- getPhasein interface- org.springframework.context.SmartLifecycle
 
 - 
getOrCreateCachepublic <K,V> ClientCache<K,V> getOrCreateCache(String name) throws ClientException Gets the existing cache or creates a new cache with default configuration if it does not exist.- Specified by:
- getOrCreateCachein interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- name- Cache name.
- Returns:
- Client cache instance.
- Throws:
- ClientException
 
 - 
getOrCreateCacheAsyncpublic <K,V> IgniteClientFuture<ClientCache<K,V>> getOrCreateCacheAsync(String name) throws ClientException Gets the existing cache or creates a new cache with default configuration if it does not exist.- Specified by:
- getOrCreateCacheAsyncin interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- name- Cache name.
- Returns:
- a Future representing pending completion of the operation, which wraps the resulting cache.
- Throws:
- ClientException
 
 - 
getOrCreateCachepublic <K,V> ClientCache<K,V> getOrCreateCache(ClientCacheConfiguration cfg) throws ClientException Gets the existing cache or creates a new cache if it does not exist.- Specified by:
- getOrCreateCachein interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- cfg- Cache configuration. If the cache exists, this configuration is ignored.
- Returns:
- Client cache instance.
- Throws:
- ClientException
 
 - 
getOrCreateCacheAsyncpublic <K,V> IgniteClientFuture<ClientCache<K,V>> getOrCreateCacheAsync(ClientCacheConfiguration cfg) throws ClientException Gets the existing cache or creates a new cache if it does not exist.- Specified by:
- getOrCreateCacheAsyncin interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- cfg- Cache configuration. If the cache exists, this configuration is ignored.
- Returns:
- a Future representing pending completion of the operation, which wraps the resulting cache.
- Throws:
- ClientException
 
 - 
cachepublic <K,V> ClientCache<K,V> cache(String name) Get existing cache.- Specified by:
- cachein interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- name- Cache name.
- Returns:
- Client cache instance.
 
 - 
cacheNamespublic Collection<String> cacheNames() throws ClientException Gets the names of all available caches.- Specified by:
- cacheNamesin interface- IgniteClient
- Returns:
- Collection of names of currently available caches or an empty collection if no caches are available.
- Throws:
- ClientException
 
 - 
cacheNamesAsyncpublic IgniteClientFuture<Collection<String>> cacheNamesAsync() throws ClientException Gets the names of all available caches.- Specified by:
- cacheNamesAsyncin interface- IgniteClient
- Returns:
- a Future representing pending completion of the operation, which wraps the Ńollection of names of currently available caches or an empty collection if no caches are available.
- Throws:
- ClientException
 
 - 
destroyCachepublic void destroyCache(String name) throws ClientException Destroys the cache with the given name. ThrowsClientExceptionif the cache does not exist.- Specified by:
- destroyCachein interface- IgniteClient
- Parameters:
- name- Name of the cache to destroy.
- Throws:
- ClientException
 
 - 
destroyCacheAsyncpublic IgniteClientFuture<Void> destroyCacheAsync(String name) throws ClientException Destroys the cache with the given name. ThrowsClientExceptionif the cache does not exist.- Specified by:
- destroyCacheAsyncin interface- IgniteClient
- Parameters:
- name- Name of the cache to destroy.
- Returns:
- a Future representing pending completion of the operation.
- Throws:
- ClientException
 
 - 
createCachepublic <K,V> ClientCache<K,V> createCache(String name) throws ClientException Creates a cache with a default configuration.- Specified by:
- createCachein interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- name- Cache name.
- Returns:
- Resulting cache.
- Throws:
- ClientException
 
 - 
createCacheAsyncpublic <K,V> IgniteClientFuture<ClientCache<K,V>> createCacheAsync(String name) throws ClientException Creates a cache with a default configuration.- Specified by:
- createCacheAsyncin interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- name- Cache name.
- Returns:
- a Future representing pending completion of the operation, which wraps the resulting cache.
- Throws:
- ClientException
 
 - 
createCachepublic <K,V> ClientCache<K,V> createCache(ClientCacheConfiguration cfg) throws ClientException Creates a cache with the specified configuration.- Specified by:
- createCachein interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- cfg- Cache configuration.
- Returns:
- Resulting cache.
- Throws:
- ClientException
 
 - 
createCacheAsyncpublic <K,V> IgniteClientFuture<ClientCache<K,V>> createCacheAsync(ClientCacheConfiguration cfg) throws ClientException Creates a cache with the specified configuration.- Specified by:
- createCacheAsyncin interface- IgniteClient
- Type Parameters:
- K- Type of the cache key.
- V- Type of the cache value.
- Parameters:
- cfg- Cache configuration.
- Returns:
- a Future representing pending completion of the operation, which wraps the resulting cache.
- Throws:
- ClientException
 
 - 
binarypublic IgniteBinary binary() - Specified by:
- binaryin interface- IgniteClient
- Returns:
- Instance of IgniteBinaryinterface.
 
 - 
querypublic FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry) Execute SQL query and get cursor to iterate over results.- Specified by:
- queryin interface- IgniteClient
- Parameters:
- qry- SQL query.
- Returns:
- Cursor.
 
 - 
transactionspublic ClientTransactions transactions() Gets client transactions facade.- Specified by:
- transactionsin interface- IgniteClient
- Returns:
- Client transactions facade.
 
 - 
computepublic ClientCompute compute() Gets compute facade over all cluster nodes started in server mode.- Specified by:
- computein interface- IgniteClient
- Returns:
- Compute instance over all cluster nodes started in server mode.
 
 - 
computepublic ClientCompute compute(ClientClusterGroup grp) Gets compute facade over the specified cluster group. All operations on the returnedClientComputeinstance will only include nodes from this cluster group.- Specified by:
- computein interface- IgniteClient
- Parameters:
- grp- Cluster group.
- Returns:
- Compute instance over given cluster group.
 
 - 
clusterpublic ClientCluster cluster() Gets client cluster facade.- Specified by:
- clusterin interface- IgniteClient
- Returns:
- Client cluster facade.
 
 - 
servicespublic ClientServices services() Getsservicesfacade over all cluster nodes started in server mode.- Specified by:
- servicesin interface- IgniteClient
- Returns:
- Services facade over all cluster nodes started in server mode.
 
 - 
servicespublic ClientServices services(ClientClusterGroup grp) Getsservicesfacade over nodes within the cluster group. All operations on the returnedClientServicesinstance will only include nodes from the specified cluster group. Note: In some cases there will be additional requests for each service invocation from client to server to resolve cluster group.- Specified by:
- servicesin interface- IgniteClient
- Parameters:
- grp- Cluster group.
- Returns:
- Servicesfunctionality over given cluster group.
 
 - 
atomicLongpublic ClientAtomicLong atomicLong(String name, long initVal, boolean create) Gets an atomic long from cache and creates one if it has not been created yet andcreateflag istrue.- Specified by:
- atomicLongin interface- IgniteClient
- Parameters:
- name- Name of atomic long.
- initVal- Initial value for atomic long. Ignored if- createflag is- false.
- create- Boolean flag indicating whether data structure should be created if it does not exist.
- Returns:
- Atomic long.
 
 - 
atomicLongpublic ClientAtomicLong atomicLong(String name, ClientAtomicConfiguration cfg, long initVal, boolean create) Gets an atomic long from cache and creates one if it has not been created yet andcreateflag istrue.- Specified by:
- atomicLongin interface- IgniteClient
- Parameters:
- name- Name of atomic long.
- cfg- Configuration.
- initVal- Initial value for atomic long. Ignored if- createflag is- false.
- create- Boolean flag indicating whether data structure should be created if it does not exist.
- Returns:
- Atomic long.
 
 - 
setpublic <T> ClientIgniteSet<T> set(String name, @Nullable @Nullable ClientCollectionConfiguration cfg) Gets a distributed set from cache. Creates one if it has not been created yet andcfgis notnull.- Specified by:
- setin interface- IgniteClient
- Type Parameters:
- T- Type of the elements in set.
- Parameters:
- name- Set name.
- cfg- Set configuration if new set should be created.
- Returns:
- Set with given properties.
 
 - 
closepublic void close() Closes this client's open connections and relinquishes all underlying resources.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- IgniteClient
 
 - 
setClientConfigurationpublic IgniteClientSpringBean setClientConfiguration(ClientConfiguration cfg) Sets Ignite client configuration.- Parameters:
- cfg- Ignite thin client configuration.
- Returns:
- thisfor chaining.
 
 - 
getClientConfigurationpublic ClientConfiguration getClientConfiguration() - Returns:
- Ignite client configuration.
 
 - 
setPhasepublic IgniteClientSpringBean setPhase(int phase) SetsSmartLifecyclephase during which the current bean will be initialized. Note, underlying Ignite client will be closed during handling ofDisposableBeansinceIgniteClientimplementsAutoCloseableinterface.- Parameters:
- phase-- SmartLifecyclephase.
- Returns:
- thisfor chaining.
 
 
- 
 
-