public class HazelcastClient extends Object implements HazelcastInstance
Modifier and Type | Method and Description |
---|---|
void |
addInstanceListener(InstanceListener instanceListener)
Add a instance listener which will be notified when a
new instance such as map, queue, multimap, topic, lock is
added or removed.
|
protected void |
destroy(String proxyName) |
static Collection<HazelcastClient> |
getAllHazelcastClients() |
AtomicNumber |
getAtomicNumber(String name)
Creates cluster-wide atomic long.
|
ClientConfig |
getClientConfig() |
<K,V,E> Object |
getClientProxy(Object o) |
ClientService |
getClientService()
Returns the client service of this Hazelcast instance.
|
Cluster |
getCluster()
Returns the Cluster that this Hazelcast instance is part of.
|
Config |
getConfig()
Returns the configuration of this Hazelcast instance.
|
ConnectionManager |
getConnectionManager() |
ICountDownLatch |
getCountDownLatch(String name)
Creates cluster-wide CountDownLatch.
|
ExecutorService |
getExecutorService()
Returns the default distributed executor service.
|
ExecutorService |
getExecutorService(String name)
Returns the distributed executor service for the given
name.
|
IdGenerator |
getIdGenerator(String name)
Creates cluster-wide unique IDs.
|
InRunnable |
getInRunnable() |
Collection<Instance> |
getInstances()
Returns all queue, map, set, list, topic, lock, multimap
instances created by Hazelcast.
|
LifecycleService |
getLifecycleService()
Returns the lifecycle service for this instance.
|
<E> IList<E> |
getList(String name)
Returns the distributed list instance with the specified name.
|
ILock |
getLock(Object obj)
Returns the distributed lock instance for the specified key object.
|
LoggingService |
getLoggingService()
Returns the logging service of this Hazelcast instance.
|
<K,V> IMap<K,V> |
getMap(String name)
Returns the distributed map instance with the specified name.
|
<K,V> MultiMap<K,V> |
getMultiMap(String name)
Returns the distributed multimap instance with the specified name.
|
String |
getName()
Returns the name of this Hazelcast instance
|
OutRunnable |
getOutRunnable() |
PartitionService |
getPartitionService()
Returns the partition service of this Hazelcast instance.
|
<E> IQueue<E> |
getQueue(String name)
Returns the distributed queue instance with the specified name.
|
ISemaphore |
getSemaphore(String name)
Creates cluster-wide semaphore.
|
<E> ISet<E> |
getSet(String name)
Returns the distributed set instance with the specified name.
|
<E> ITopic<E> |
getTopic(String name)
Returns the distributed topic instance with the specified name.
|
Transaction |
getTransaction()
Returns the transaction instance associated with the current thread,
creates a new one if it wasn't already.
|
boolean |
isActive() |
static HazelcastClient |
newHazelcastClient(ClientConfig config) |
void |
removeInstanceListener(InstanceListener instanceListener)
Removes the specified instance listener.
|
void |
restart()
Detaches this member from the cluster first and then restarts it
as a new member.
|
void |
shutdown()
Detaches this member from the cluster.
|
static void |
shutdownAll() |
public InRunnable getInRunnable()
public OutRunnable getOutRunnable()
public static HazelcastClient newHazelcastClient(ClientConfig config)
config
- public Config getConfig()
HazelcastInstance
getConfig
in interface HazelcastInstance
public PartitionService getPartitionService()
HazelcastInstance
getPartitionService
in interface HazelcastInstance
public ClientService getClientService()
HazelcastInstance
getClientService
in interface HazelcastInstance
public LoggingService getLoggingService()
HazelcastInstance
getLoggingService
in interface HazelcastInstance
public <K,V> IMap<K,V> getMap(String name)
HazelcastInstance
getMap
in interface HazelcastInstance
name
- name of the distributed mappublic Transaction getTransaction()
HazelcastInstance
Map map = Hazelcast.getMap("mymap"); Transaction txn = Hazelcast.getTransaction(); txn.begin(); try { map.put ("key", "value"); txn.commit(); }catch (Exception e) { txn.rollback(); }Isolation is always REPEATABLE_READ . If you are in a transaction, you can read the data in your transaction and the data that is already committed and if not in a transaction, you can only read the committed data. Implementation is different for queue and map/set. For queue operations (offer,poll), offered and/or polled objects are copied to the next member in order to safely commit/rollback. For map/set, Hazelcast first acquires the locks for the write operations (put, remove) and holds the differences (what is added/removed/updated) locally for each transaction. When transaction is set to commit, Hazelcast will release the locks and apply the differences. When rolling back, Hazelcast will simply releases the locks and discard the differences. Transaction instance is attached to the current thread and each Hazelcast operation checks if the current thread holds a transaction, if so, operation will be transaction aware. When transaction is committed, rolled back or timed out, it will be detached from the thread holding it.
getTransaction
in interface HazelcastInstance
public ConnectionManager getConnectionManager()
public void addInstanceListener(InstanceListener instanceListener)
HazelcastInstance
addInstanceListener
in interface HazelcastInstance
instanceListener
- instance listenerpublic Cluster getCluster()
HazelcastInstance
getCluster
in interface HazelcastInstance
public ExecutorService getExecutorService()
HazelcastInstance
getExecutorService
in interface HazelcastInstance
public ExecutorService getExecutorService(String name)
HazelcastInstance
getExecutorService
in interface HazelcastInstance
name
- name of the executor servicepublic IdGenerator getIdGenerator(String name)
HazelcastInstance
getIdGenerator
in interface HazelcastInstance
name
- name of the IdGeneratorpublic AtomicNumber getAtomicNumber(String name)
HazelcastInstance
getAtomicNumber
in interface HazelcastInstance
name
- name of the AtomicNumber proxypublic ICountDownLatch getCountDownLatch(String name)
HazelcastInstance
getCountDownLatch
in interface HazelcastInstance
name
- name of the ICountDownLatch proxypublic ISemaphore getSemaphore(String name)
HazelcastInstance
getSemaphore
in interface HazelcastInstance
name
- name of the ISemaphore proxypublic Collection<Instance> getInstances()
HazelcastInstance
getInstances
in interface HazelcastInstance
public <E> IList<E> getList(String name)
HazelcastInstance
getList
in interface HazelcastInstance
name
- name of the distributed listpublic ILock getLock(Object obj)
HazelcastInstance
Lock lock = Hazelcast.getLock("PROCESS_LOCK"); lock.lock(); try { // process } finally { lock.unlock(); }
getLock
in interface HazelcastInstance
obj
- key of the lock instancepublic <K,V> MultiMap<K,V> getMultiMap(String name)
HazelcastInstance
getMultiMap
in interface HazelcastInstance
name
- name of the distributed multimappublic 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> ISet<E> getSet(String name)
HazelcastInstance
getSet
in interface HazelcastInstance
name
- name of the distributed setpublic <E> ITopic<E> getTopic(String name)
HazelcastInstance
getTopic
in interface HazelcastInstance
name
- name of the distributed topicpublic void removeInstanceListener(InstanceListener instanceListener)
HazelcastInstance
removeInstanceListener
in interface HazelcastInstance
instanceListener
- instance listener to removepublic static void shutdownAll()
public static Collection<HazelcastClient> getAllHazelcastClients()
public void shutdown()
HazelcastInstance
shutdown
in interface HazelcastInstance
HazelcastInstance.getLifecycleService()
public boolean isActive()
protected void destroy(String proxyName)
public void restart()
HazelcastInstance
restart
in interface HazelcastInstance
HazelcastInstance.getLifecycleService()
public LifecycleService getLifecycleService()
HazelcastInstance
getLifecycleService
in interface HazelcastInstance
public ClientConfig getClientConfig()
Copyright © 2008-2013 Hazelcast, Inc. All Rights Reserved.