Class TcpIgniteClient
- java.lang.Object
-
- org.apache.ignite.internal.client.thin.TcpIgniteClient
-
- All Implemented Interfaces:
AutoCloseable,IgniteClient
public class TcpIgniteClient extends Object implements IgniteClient
Implementation ofIgniteClientover TCP protocol.
-
-
Method Summary
All Methods Static 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.<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.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.static IgniteClientstart(ClientConfiguration cfg)Initializes new instance ofIgniteClient.voidstopWarmUp()Stops cache warmup.ClientTransactionstransactions()Gets client transactions facade.
-
-
-
Method Detail
-
close
public void close()
Closes this client's open connections and relinquishes all underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceIgniteClient
-
getOrCreateCache
public <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 interfaceIgniteClient- 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
public <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 interfaceIgniteClient- 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
public <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 interfaceIgniteClient- 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
public <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 interfaceIgniteClient- 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
public <K,V> ClientCache<K,V> cache(String name)
Get existing cache.- Specified by:
cachein interfaceIgniteClient- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
name- Cache name.- Returns:
- Client cache instance.
-
cacheNames
public Collection<String> cacheNames() throws ClientException
Gets the names of all available caches.- Specified by:
cacheNamesin interfaceIgniteClient- Returns:
- Collection of names of currently available caches or an empty collection if no caches are available.
- Throws:
ClientException
-
cacheNamesAsync
public IgniteClientFuture<Collection<String>> cacheNamesAsync() throws ClientException
Gets the names of all available caches.- Specified by:
cacheNamesAsyncin interfaceIgniteClient- 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
public void destroyCache(String name) throws ClientException
Destroys the cache with the given name. ThrowsClientExceptionif the cache does not exist.- Specified by:
destroyCachein interfaceIgniteClient- Parameters:
name- Name of the cache to destroy.- Throws:
ClientException
-
destroyCacheAsync
public IgniteClientFuture<Void> destroyCacheAsync(String name) throws ClientException
Destroys the cache with the given name. ThrowsClientExceptionif the cache does not exist.- Specified by:
destroyCacheAsyncin interfaceIgniteClient- Parameters:
name- Name of the cache to destroy.- Returns:
- a Future representing pending completion of the operation.
- Throws:
ClientException
-
createCache
public <K,V> ClientCache<K,V> createCache(String name) throws ClientException
Creates a cache with a default configuration.- Specified by:
createCachein interfaceIgniteClient- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
name- Cache name.- Returns:
- Resulting cache.
- Throws:
ClientException
-
createCacheAsync
public <K,V> IgniteClientFuture<ClientCache<K,V>> createCacheAsync(String name) throws ClientException
Creates a cache with a default configuration.- Specified by:
createCacheAsyncin interfaceIgniteClient- 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
public <K,V> ClientCache<K,V> createCache(ClientCacheConfiguration cfg) throws ClientException
Creates a cache with the specified configuration.- Specified by:
createCachein interfaceIgniteClient- Type Parameters:
K- Type of the cache key.V- Type of the cache value.- Parameters:
cfg- Cache configuration.- Returns:
- Resulting cache.
- Throws:
ClientException
-
createCacheAsync
public <K,V> IgniteClientFuture<ClientCache<K,V>> createCacheAsync(ClientCacheConfiguration cfg) throws ClientException
Creates a cache with the specified configuration.- Specified by:
createCacheAsyncin interfaceIgniteClient- 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
public IgniteBinary binary()
- Specified by:
binaryin interfaceIgniteClient- Returns:
- Instance of
IgniteBinaryinterface.
-
query
public FieldsQueryCursor<List<?>> query(SqlFieldsQuery qry)
Execute SQL query and get cursor to iterate over results.- Specified by:
queryin interfaceIgniteClient- Parameters:
qry- SQL query.- Returns:
- Cursor.
-
transactions
public ClientTransactions transactions()
Gets client transactions facade.- Specified by:
transactionsin interfaceIgniteClient- Returns:
- Client transactions facade.
-
compute
public ClientCompute compute()
Gets compute facade over all cluster nodes started in server mode.- Specified by:
computein interfaceIgniteClient- Returns:
- Compute instance over all cluster nodes started in server mode.
-
compute
public 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 interfaceIgniteClient- Parameters:
grp- Cluster group.- Returns:
- Compute instance over given cluster group.
-
cluster
public ClientCluster cluster()
Gets client cluster facade.- Specified by:
clusterin interfaceIgniteClient- Returns:
- Client cluster facade.
-
services
public ClientServices services()
Getsservicesfacade over all cluster nodes started in server mode.- Specified by:
servicesin interfaceIgniteClient- Returns:
- Services facade over all cluster nodes started in server mode.
-
services
public 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 interfaceIgniteClient- Parameters:
grp- Cluster group.- Returns:
Servicesfunctionality over given cluster group.
-
atomicLong
public 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 interfaceIgniteClient- Parameters:
name- Name of atomic long.initVal- Initial value for atomic long. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if it does not exist.- Returns:
- Atomic long.
-
atomicLong
public 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 interfaceIgniteClient- Parameters:
name- Name of atomic long.cfg- Configuration.initVal- Initial value for atomic long. Ignored ifcreateflag isfalse.create- Boolean flag indicating whether data structure should be created if it does not exist.- Returns:
- Atomic long.
-
set
public <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 interfaceIgniteClient- 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.
-
stopWarmUp
public void stopWarmUp()
Stops cache warmup.
-
start
public static IgniteClient start(ClientConfiguration cfg) throws ClientException
Initializes new instance ofIgniteClient.- Parameters:
cfg- Thin client configuration.- Returns:
- Client with successfully opened thin client connection.
- Throws:
ClientException
-
-