public class HazelcastClientInstanceImpl extends Object implements HazelcastInstance, SerializationServiceSupport
Constructor and Description |
---|
HazelcastClientInstanceImpl(String instanceName,
ClientConfig clientConfig,
ClientFailoverConfig clientFailoverConfig,
ClientConnectionManagerFactory clientConnectionManagerFactory,
AddressProvider externalAddressProvider) |
Modifier and Type | Method and Description |
---|---|
String |
addDistributedObjectListener(DistributedObjectListener distributedObjectListener)
Adds a Distributed Object listener which will be notified when a
new
DistributedObject will be created or destroyed. |
void |
doShutdown() |
<T> T |
executeTransaction(TransactionalTask<T> task)
Executes the given transactional task in current thread using default options
and returns the result of the task.
|
<T> T |
executeTransaction(TransactionOptions options,
TransactionalTask<T> task)
Executes the given transactional task in current thread using given options
and returns the result of the task.
|
IAtomicLong |
getAtomicLong(String name)
Creates or returns a cluster-wide atomic long.
|
<E> IAtomicReference<E> |
getAtomicReference(String name)
Creates or returns a cluster-wide atomic reference.
|
ClientICacheManager |
getCacheManager()
Obtain the
ICacheManager that provides access to JSR-107 (JCache) caches configured on a Hazelcast cluster. |
CardinalityEstimator |
getCardinalityEstimator(String name)
Obtain a
CardinalityEstimator with the given name. |
ClientClusterService |
getClientClusterService() |
ClientConfig |
getClientConfig() |
ClientDiscoveryService |
getClientDiscoveryService() |
ClientExceptionFactory |
getClientExceptionFactory() |
ClientExecutionService |
getClientExecutionService() |
ClientExtension |
getClientExtension() |
ClientPartitionService |
getClientPartitionService() |
ClientService |
getClientService()
Returns the client service of this Hazelcast instance.
|
Cluster |
getCluster()
Returns the Cluster that this Hazelcast instance is part of.
|
ClusterConnectorService |
getClusterConnectorService() |
Config |
getConfig()
Returns the configuration of this Hazelcast instance.
|
ClientConnectionManager |
getConnectionManager() |
ClientConnectionStrategy |
getConnectionStrategy() |
ICountDownLatch |
getCountDownLatch(String name)
Creates or returns a cluster-wide CountDownLatch.
|
CPSubsystem |
getCPSubsystem()
Returns the CP subsystem that offers a set of in-memory linearizable data structures
|
<T extends DistributedObject> |
getDistributedObject(String serviceName,
String name) |
Collection<DistributedObject> |
getDistributedObjects()
Returns all
DistributedObject s, that is all maps, queues,
topics, locks etc. |
DurableExecutorService |
getDurableExecutorService(String name)
Creates or returns the durable executor service for the given name.
|
IExecutorService |
getExecutorService(String name)
Creates or returns the distributed executor service for the given name.
|
ClientFailoverConfig |
getFailoverConfig() |
FlakeIdGenerator |
getFlakeIdGenerator(String name)
Creates or returns a cluster-wide unique ID generator.
|
int |
getId() |
IdGenerator |
getIdGenerator(String name)
Creates or returns a cluster-wide unique ID generator.
|
ClientInvocationService |
getInvocationService() |
JobTracker |
getJobTracker(String name)
Creates or returns the job tracker instance with the specified name.
|
LifecycleService |
getLifecycleService()
Returns the lifecycle service for this instance.
|
<E> IList<E> |
getList(String name)
Creates or returns the distributed list instance with the specified name.
|
ClientListenerService |
getListenerService() |
LoadBalancer |
getLoadBalancer() |
Client |
getLocalEndpoint()
Returns the local Endpoint which this HazelcastInstance belongs to.
|
ILock |
getLock(String key)
Creates or returns the distributed lock instance for the specified key object.
|
ClientLockReferenceIdGenerator |
getLockReferenceIdGenerator() |
LoggingService |
getLoggingService()
Returns the logging service of this Hazelcast instance.
|
<K,V> IMap<K,V> |
getMap(String name)
Creates or returns the distributed map instance with the specified name.
|
MetricsRegistryImpl |
getMetricsRegistry() |
<K,V> MultiMap<K,V> |
getMultiMap(String name)
Creates or returns the distributed multimap instance with the specified name.
|
String |
getName()
Returns the name of this Hazelcast instance.
|
NearCacheManager |
getNearCacheManager() |
PartitionService |
getPartitionService()
Returns the partition service of this Hazelcast instance.
|
PNCounter |
getPNCounter(String name)
Creates or returns a
PNCounter with the given
name. |
HazelcastProperties |
getProperties() |
short |
getProtocolVersion() |
ProxyManager |
getProxyManager() |
ClientProxySessionManager |
getProxySessionManager() |
ClientQueryCacheContext |
getQueryCacheContext() |
<E> IQueue<E> |
getQueue(String name)
Creates or returns the distributed queue instance with the specified name.
|
QuorumService |
getQuorumService()
Returns the quorum service of this Hazelcast instance.
|
<E> ITopic<E> |
getReliableTopic(String name)
Creates or returns the reliable topic instance with the specified name.
|
<K,V> ReplicatedMap<K,V> |
getReplicatedMap(String name)
Creates or returns the replicated map instance with the specified name.
|
<E> Ringbuffer<E> |
getRingbuffer(String name)
Creates or returns the distributed Ringbuffer instance with the specified name.
|
IScheduledExecutorService |
getScheduledExecutorService(String name)
Creates or returns the
IScheduledExecutorService scheduled executor service for the given name. |
ISemaphore |
getSemaphore(String name)
Creates or returns a cluster-wide semaphore.
|
InternalSerializationService |
getSerializationService() |
<E> ISet<E> |
getSet(String name)
Creates or returns the distributed set instance with the specified name.
|
<E> ITopic<E> |
getTopic(String name)
Creates or returns the distributed topic instance with the specified name.
|
ClientTransactionManagerService |
getTransactionManager() |
ClientUserCodeDeploymentService |
getUserCodeDeploymentService() |
ConcurrentMap<String,Object> |
getUserContext()
Returns a ConcurrentMap that can be used to add user-context to the HazelcastInstance.
|
HazelcastXAResource |
getXAResource()
Gets xaResource which will participate in XATransaction.
|
TransactionContext |
newTransactionContext()
Creates a new TransactionContext associated with the current thread using default options.
|
TransactionContext |
newTransactionContext(TransactionOptions options)
Creates a new TransactionContext associated with the current thread with given options.
|
void |
onClusterConnect(Connection ownerConnection) |
void |
onClusterDisconnect() |
boolean |
removeDistributedObjectListener(String registrationId)
Removes the specified Distributed Object listener.
|
void |
shutdown()
Shuts down this HazelcastInstance.
|
void |
start() |
public HazelcastClientInstanceImpl(String instanceName, ClientConfig clientConfig, ClientFailoverConfig clientFailoverConfig, ClientConnectionManagerFactory clientConnectionManagerFactory, AddressProvider externalAddressProvider)
public int getId()
public void start()
public void onClusterConnect(Connection ownerConnection) throws Exception
Exception
public void onClusterDisconnect()
public MetricsRegistryImpl getMetricsRegistry()
public HazelcastXAResource getXAResource()
HazelcastInstance
getXAResource
in interface HazelcastInstance
public Config getConfig()
HazelcastInstance
getConfig
in interface HazelcastInstance
public HazelcastProperties getProperties()
public String getName()
HazelcastInstance
getName
in interface HazelcastInstance
public <E> IQueue<E> getQueue(String name)
HazelcastInstance
getQueue
in interface HazelcastInstance
name
- name of the distributed queuepublic <E> ITopic<E> getTopic(String name)
HazelcastInstance
getTopic
in interface HazelcastInstance
name
- name of the distributed topicpublic <E> ISet<E> getSet(String name)
HazelcastInstance
getSet
in interface HazelcastInstance
name
- name of the distributed setpublic <E> IList<E> getList(String name)
HazelcastInstance
getList
in interface HazelcastInstance
name
- name of the distributed listpublic <K,V> IMap<K,V> getMap(String name)
HazelcastInstance
getMap
in interface HazelcastInstance
name
- name of the distributed mappublic <K,V> MultiMap<K,V> getMultiMap(String name)
HazelcastInstance
getMultiMap
in interface HazelcastInstance
name
- name of the distributed multimappublic <K,V> ReplicatedMap<K,V> getReplicatedMap(String name)
HazelcastInstance
getReplicatedMap
in interface HazelcastInstance
name
- name of the distributed mappublic JobTracker getJobTracker(String name)
HazelcastInstance
getJobTracker
in interface HazelcastInstance
name
- name of the job trackerpublic ILock getLock(String key)
HazelcastInstance
Lock lock = hazelcastInstance.getLock("PROCESS_LOCK"); lock.lock(); try { // process } finally { lock.unlock(); }
getLock
in interface HazelcastInstance
key
- key of the lock instancepublic <E> ITopic<E> getReliableTopic(String name)
HazelcastInstance
getReliableTopic
in interface HazelcastInstance
name
- name of the reliable topicpublic <E> Ringbuffer<E> getRingbuffer(String name)
HazelcastInstance
getRingbuffer
in interface HazelcastInstance
name
- name of the distributed Ringbufferpublic ClientICacheManager getCacheManager()
HazelcastInstance
ICacheManager
that provides access to JSR-107 (JCache) caches configured on a Hazelcast cluster.
Note that this method does not return a JCache CacheManager
; to obtain a JCache
CacheManager
use JCache standard API.
getCacheManager
in interface HazelcastInstance
ICacheManager
ICacheManager
public Cluster getCluster()
HazelcastInstance
getCluster
in interface HazelcastInstance
public Client getLocalEndpoint()
HazelcastInstance
Returned endpoint will be a Member
instance for cluster nodes
and a Client
instance for clients.
getLocalEndpoint
in interface HazelcastInstance
Endpoint
which this HazelcastInstance belongs toMember
,
Client
public IExecutorService getExecutorService(String name)
HazelcastInstance
Note: Note that it doesn't support invokeAll/Any
and doesn't have standard shutdown behavior
getExecutorService
in interface HazelcastInstance
name
- name of the executor servicepublic DurableExecutorService getDurableExecutorService(String name)
HazelcastInstance
Note: Note that it doesn't support invokeAll/Any
and doesn't have standard shutdown behavior
getDurableExecutorService
in interface HazelcastInstance
name
- name of the executor servicepublic <T> T executeTransaction(TransactionalTask<T> task) throws TransactionException
HazelcastInstance
executeTransaction
in interface HazelcastInstance
T
- return type of tasktask
- the transactional task to be executedTransactionException
- if an error occurs during transaction.public <T> T executeTransaction(TransactionOptions options, TransactionalTask<T> task) throws TransactionException
HazelcastInstance
executeTransaction
in interface HazelcastInstance
T
- return type of taskoptions
- options for this transactional tasktask
- task to be executedTransactionException
- if an error occurs during transaction.public TransactionContext newTransactionContext()
HazelcastInstance
newTransactionContext
in interface HazelcastInstance
public TransactionContext newTransactionContext(TransactionOptions options)
HazelcastInstance
newTransactionContext
in interface HazelcastInstance
options
- options for this transactionpublic ClientTransactionManagerService getTransactionManager()
public IdGenerator getIdGenerator(String name)
HazelcastInstance
long
primitive values
between 0 and Long.MAX_VALUE. ID generation occurs almost at the speed of
local AtomicLong.incrementAndGet(). Generated IDs are unique during the life
cycle of the cluster. If the entire cluster is restarted, IDs start from 0 again.getIdGenerator
in interface HazelcastInstance
name
- name of the IdGenerator
public FlakeIdGenerator getFlakeIdGenerator(String name)
HazelcastInstance
long
primitive values
and are k-ordered (roughly ordered). IDs are in the range from 0
to Long.MAX_VALUE
.
The IDs contain timestamp component and a node ID component, which is assigned when the member
joins the cluster. This allows the IDs to be ordered and unique without any coordination between
members, which makes the generator safe even in split-brain scenario (for caveats,
see here
).
For more details and caveats, see class documentation for FlakeIdGenerator
.
Note: this implementation doesn't share namespace with HazelcastInstance.getIdGenerator(String)
.
That is, getIdGenerator("a")
is distinct from getFlakeIdGenerator("a")
.
getFlakeIdGenerator
in interface HazelcastInstance
name
- name of the FlakeIdGenerator
public IAtomicLong getAtomicLong(String name)
HazelcastInstance
IAtomicLong
is distributed
implementation of java.util.concurrent.atomic.AtomicLong.getAtomicLong
in interface HazelcastInstance
name
- name of the IAtomicLong
proxypublic CardinalityEstimator getCardinalityEstimator(String name)
HazelcastInstance
CardinalityEstimator
with the given name.
The estimator can be used to efficiently estimate the cardinality of unique entities in big data sets, without the need of storing them.
The estimator is based on a HyperLogLog++ data-structure.
getCardinalityEstimator
in interface HazelcastInstance
name
- the name of the estimatorCardinalityEstimator
public PNCounter getPNCounter(String name)
HazelcastInstance
PNCounter
with the given
name.
The PN counter can be used as a counter with strong eventual consistency guarantees - if operations to the counters stop, the counter values of all replicas that can communicate with each other should eventually converge to the same value.
getPNCounter
in interface HazelcastInstance
name
- the name of the PN counterPNCounter
public <E> IAtomicReference<E> getAtomicReference(String name)
HazelcastInstance
IAtomicReference
is distributed
implementation of java.util.concurrent.atomic.AtomicReference.getAtomicReference
in interface HazelcastInstance
name
- name of the IAtomicReference
proxyIAtomicReference
proxy for the given namepublic ICountDownLatch getCountDownLatch(String name)
HazelcastInstance
ICountDownLatch
is distributed
implementation of java.util.concurrent.CountDownLatch.getCountDownLatch
in interface HazelcastInstance
name
- name of the ICountDownLatch
proxyICountDownLatch
proxy for the given namepublic ISemaphore getSemaphore(String name)
HazelcastInstance
ISemaphore
is distributed
implementation of java.util.concurrent.Semaphore.getSemaphore
in interface HazelcastInstance
name
- name of the ISemaphore
proxyISemaphore
proxy for the given namepublic IScheduledExecutorService getScheduledExecutorService(String name)
HazelcastInstance
IScheduledExecutorService
scheduled executor service for the given name.
ScheduledExecutor service enables you to schedule your Runnables and Callables
on the Hazelcast cluster.getScheduledExecutorService
in interface HazelcastInstance
name
- name of the executor servicepublic Collection<DistributedObject> getDistributedObjects()
HazelcastInstance
DistributedObject
s, that is all maps, queues,
topics, locks etc.
The results are returned on a best-effort basis. The result might miss just-created objects and contain just-deleted objects. An existing object can also be missing from the list occasionally. One cluster member is queried to obtain the list.
getDistributedObjects
in interface HazelcastInstance
public String addDistributedObjectListener(DistributedObjectListener distributedObjectListener)
HazelcastInstance
DistributedObject
will be created or destroyed.addDistributedObjectListener
in interface HazelcastInstance
distributedObjectListener
- instance listenerpublic boolean removeDistributedObjectListener(String registrationId)
HazelcastInstance
removeDistributedObjectListener
in interface HazelcastInstance
registrationId
- ID of listener registrationtrue
if registration is removed, false
otherwisepublic PartitionService getPartitionService()
HazelcastInstance
getPartitionService
in interface HazelcastInstance
public QuorumService getQuorumService()
HazelcastInstance
Quorum service can be used to retrieve quorum callbacks which let you to notify quorum results of your own to the cluster quorum service. IMPORTANT: The term "quorum" simply refers to the count of members in the cluster required for an operation to succeed. It does NOT refer to an implementation of Paxos or Raft protocols as used in many NoSQL and distributed systems. The mechanism it provides in Hazelcast protects the user in case the number of nodes in a cluster drops below the specified one.
getQuorumService
in interface HazelcastInstance
public ClientService getClientService()
HazelcastInstance
getClientService
in interface HazelcastInstance
ClientService
of this Hazelcast instance.public LoggingService getLoggingService()
HazelcastInstance
LoggingService allows you to listen for LogEvents generated by Hazelcast runtime. You can log the events somewhere or take action based on the message.
getLoggingService
in interface HazelcastInstance
public LifecycleService getLifecycleService()
HazelcastInstance
LifecycleService allows you to shutdown this HazelcastInstance and listen for the lifecycle events.
getLifecycleService
in interface HazelcastInstance
public <T extends DistributedObject> T getDistributedObject(String serviceName, String name)
getDistributedObject
in interface HazelcastInstance
T
- type of the DistributedObjectserviceName
- name of the servicename
- name of the objectpublic CPSubsystem getCPSubsystem()
HazelcastInstance
getCPSubsystem
in interface HazelcastInstance
public ConcurrentMap<String,Object> getUserContext()
HazelcastInstance
HazelcastInstanceAware
interface when submitting a Runnable/Callable to
Hazelcast ExecutorService. By storing the dependencies in the user-context, they can be retrieved as soon
as you have a reference to the HazelcastInstance.
This structure is purely local and Hazelcast remains agnostic abouts its content.
getUserContext
in interface HazelcastInstance
public ClientConfig getClientConfig()
public InternalSerializationService getSerializationService()
getSerializationService
in interface SerializationServiceSupport
public ClientUserCodeDeploymentService getUserCodeDeploymentService()
public ClientProxySessionManager getProxySessionManager()
public ProxyManager getProxyManager()
public ClientConnectionManager getConnectionManager()
public ClientClusterService getClientClusterService()
public ClientExecutionService getClientExecutionService()
public ClientPartitionService getClientPartitionService()
public ClientInvocationService getInvocationService()
public ClientListenerService getListenerService()
public NearCacheManager getNearCacheManager()
public LoadBalancer getLoadBalancer()
public ClientExtension getClientExtension()
public short getProtocolVersion()
public void shutdown()
HazelcastInstance
LifecycleService.shutdown()
.shutdown
in interface HazelcastInstance
public void doShutdown()
public ClientLockReferenceIdGenerator getLockReferenceIdGenerator()
public ClientExceptionFactory getClientExceptionFactory()
public ClusterConnectorService getClusterConnectorService()
public ClientDiscoveryService getClientDiscoveryService()
public ClientConnectionStrategy getConnectionStrategy()
public ClientFailoverConfig getFailoverConfig()
public ClientQueryCacheContext getQueryCacheContext()
Copyright © 2020 Hazelcast, Inc.. All Rights Reserved.