Package org.apache.ignite.client
Interface IgniteClient
-
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
IgniteClientSpringBean
public interface IgniteClient extends AutoCloseable
Ignite thin client.Unlike Ignite client nodes, thin clients do not start Ignite infrastructure and communicate with Ignite cluster over a fast and lightweight protocol.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description ClientAtomicLong
atomicLong(String name, long initVal, boolean create)
Gets an atomic long from cache and creates one if it has not been created yet andcreate
flag istrue
.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 andcreate
flag istrue
.IgniteBinary
binary()
<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.void
close()
Closes this client's open connections and relinquishes all underlying resources.ClientCluster
cluster()
Gets client cluster facade.ClientCompute
compute()
Gets compute facade over all cluster nodes started in server mode.ClientCompute
compute(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.void
destroyCache(String name)
Destroys the cache with the given name.IgniteClientFuture<Void>
destroyCacheAsync(String name)
Destroys the cache with the given name.<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.FieldsQueryCursor<List<?>>
query(SqlFieldsQuery qry)
Execute SQL query and get cursor to iterate over results.ClientServices
services()
Getsservices
facade over all cluster nodes started in server mode.ClientServices
services(ClientClusterGroup grp)
Getsservices
facade over nodes within the cluster group.<T> ClientIgniteSet<T>
set(String name, @Nullable ClientCollectionConfiguration cfg)
Gets a distributed set from cache.ClientTransactions
transactions()
Gets client transactions facade.
-
-
-
Method Detail
-
getOrCreateCache
<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.- Type Parameters:
K
- Type of the cache key.V
- Type of the cache value.- Parameters:
name
- Cache name.- Returns:
- Client cache instance.
- Throws:
ClientException
-
getOrCreateCacheAsync
<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.- 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
-
getOrCreateCache
<K,V> ClientCache<K,V> getOrCreateCache(ClientCacheConfiguration cfg) throws ClientException
Gets the existing cache or creates a new cache if it does not exist.- 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
-
getOrCreateCacheAsync
<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.- 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
-
cache
<K,V> ClientCache<K,V> cache(String name)
Get existing cache.- Type Parameters:
K
- Type of the cache key.V
- Type of the cache value.- Parameters:
name
- Cache name.- Returns:
- Client cache instance.
-
cacheNames
Collection<String> cacheNames() throws ClientException
Gets the names of all available caches.- Returns:
- Collection of names of currently available caches or an empty collection if no caches are available.
- Throws:
ClientException
-
cacheNamesAsync
IgniteClientFuture<Collection<String>> cacheNamesAsync() throws ClientException
Gets the names of all available caches.- 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
-
destroyCache
void destroyCache(String name) throws ClientException
Destroys the cache with the given name. ThrowsClientException
if the cache does not exist.- Parameters:
name
- Name of the cache to destroy.- Throws:
ClientException
-
destroyCacheAsync
IgniteClientFuture<Void> destroyCacheAsync(String name) throws ClientException
Destroys the cache with the given name. ThrowsClientException
if the cache does not exist.- Parameters:
name
- Name of the cache to destroy.- Returns:
- a Future representing pending completion of the operation.
- Throws:
ClientException
-
createCache
<K,V> ClientCache<K,V> createCache(String name) throws ClientException
Creates a cache with a default configuration.- Type Parameters:
K
- Type of the cache key.V
- Type of the cache value.- Parameters:
name
- Cache name.- Returns:
- Resulting cache.
- Throws:
ClientException
-
createCacheAsync
<K,V> IgniteClientFuture<ClientCache<K,V>> createCacheAsync(String name) throws ClientException
Creates a cache with a default configuration.- 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
-
createCache
<K,V> ClientCache<K,V> createCache(ClientCacheConfiguration cfg) throws ClientException
Creates a cache with the specified configuration.- Type Parameters:
K
- Type of the cache key.V
- Type of the cache value.- Parameters:
cfg
- Cache configuration.- Returns:
- Resulting cache.
- Throws:
ClientException
-
createCacheAsync
<K,V> IgniteClientFuture<ClientCache<K,V>> createCacheAsync(ClientCacheConfiguration cfg) throws ClientException
Creates a cache with the specified configuration.- 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
-
binary
IgniteBinary binary()
- Returns:
- Instance of
IgniteBinary
interface.
-
query
FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry)
Execute SQL query and get cursor to iterate over results.- Parameters:
qry
- SQL query.- Returns:
- Cursor.
-
transactions
ClientTransactions transactions()
Gets client transactions facade.- Returns:
- Client transactions facade.
-
compute
ClientCompute compute()
Gets compute facade over all cluster nodes started in server mode.- Returns:
- Compute instance over all cluster nodes started in server mode.
-
compute
ClientCompute compute(ClientClusterGroup grp)
Gets compute facade over the specified cluster group. All operations on the returnedClientCompute
instance will only include nodes from this cluster group.- Parameters:
grp
- Cluster group.- Returns:
- Compute instance over given cluster group.
-
cluster
ClientCluster cluster()
Gets client cluster facade.- Returns:
- Client cluster facade.
-
services
ClientServices services()
Getsservices
facade over all cluster nodes started in server mode.- Returns:
- Services facade over all cluster nodes started in server mode.
-
services
ClientServices services(ClientClusterGroup grp)
Getsservices
facade over nodes within the cluster group. All operations on the returnedClientServices
instance 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.- Parameters:
grp
- Cluster group.- Returns:
Services
functionality over given cluster group.
-
atomicLong
ClientAtomicLong atomicLong(String name, long initVal, boolean create)
Gets an atomic long from cache and creates one if it has not been created yet andcreate
flag istrue
.- Parameters:
name
- Name of atomic long.initVal
- Initial value for atomic long. Ignored ifcreate
flag isfalse
.create
- Boolean flag indicating whether data structure should be created if it does not exist.- Returns:
- Atomic long.
-
atomicLong
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 andcreate
flag istrue
.- Parameters:
name
- Name of atomic long.cfg
- Configuration.initVal
- Initial value for atomic long. Ignored ifcreate
flag isfalse
.create
- Boolean flag indicating whether data structure should be created if it does not exist.- Returns:
- Atomic long.
-
set
<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 andcfg
is notnull
.- 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.
- Throws:
IgniteException
- If set could not be fetched or created.
-
close
void close()
Closes this client's open connections and relinquishes all underlying resources.- Specified by:
close
in interfaceAutoCloseable
-
-