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()
HazelcastInstancegetConfig in interface HazelcastInstancepublic PartitionService getPartitionService()
HazelcastInstancegetPartitionService in interface HazelcastInstancepublic ClientService getClientService()
HazelcastInstancegetClientService in interface HazelcastInstancepublic LoggingService getLoggingService()
HazelcastInstancegetLoggingService in interface HazelcastInstancepublic <K,V> IMap<K,V> getMap(String name)
HazelcastInstancegetMap in interface HazelcastInstancename - 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 HazelcastInstancepublic ConnectionManager getConnectionManager()
public void addInstanceListener(InstanceListener instanceListener)
HazelcastInstanceaddInstanceListener in interface HazelcastInstanceinstanceListener - instance listenerpublic Cluster getCluster()
HazelcastInstancegetCluster in interface HazelcastInstancepublic ExecutorService getExecutorService()
HazelcastInstancegetExecutorService in interface HazelcastInstancepublic ExecutorService getExecutorService(String name)
HazelcastInstancegetExecutorService in interface HazelcastInstancename - name of the executor servicepublic IdGenerator getIdGenerator(String name)
HazelcastInstancegetIdGenerator in interface HazelcastInstancename - name of the IdGeneratorpublic AtomicNumber getAtomicNumber(String name)
HazelcastInstancegetAtomicNumber in interface HazelcastInstancename - name of the AtomicNumber proxypublic ICountDownLatch getCountDownLatch(String name)
HazelcastInstancegetCountDownLatch in interface HazelcastInstancename - name of the ICountDownLatch proxypublic ISemaphore getSemaphore(String name)
HazelcastInstancegetSemaphore in interface HazelcastInstancename - name of the ISemaphore proxypublic Collection<Instance> getInstances()
HazelcastInstancegetInstances in interface HazelcastInstancepublic <E> IList<E> getList(String name)
HazelcastInstancegetList in interface HazelcastInstancename - 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 HazelcastInstanceobj - key of the lock instancepublic <K,V> MultiMap<K,V> getMultiMap(String name)
HazelcastInstancegetMultiMap in interface HazelcastInstancename - name of the distributed multimappublic String getName()
HazelcastInstancegetName in interface HazelcastInstancepublic <E> IQueue<E> getQueue(String name)
HazelcastInstancegetQueue in interface HazelcastInstancename - name of the distributed queuepublic <E> ISet<E> getSet(String name)
HazelcastInstancegetSet in interface HazelcastInstancename - name of the distributed setpublic <E> ITopic<E> getTopic(String name)
HazelcastInstancegetTopic in interface HazelcastInstancename - name of the distributed topicpublic void removeInstanceListener(InstanceListener instanceListener)
HazelcastInstanceremoveInstanceListener in interface HazelcastInstanceinstanceListener - instance listener to removepublic static void shutdownAll()
public static Collection<HazelcastClient> getAllHazelcastClients()
public void shutdown()
HazelcastInstanceshutdown in interface HazelcastInstanceHazelcastInstance.getLifecycleService()public boolean isActive()
protected void destroy(String proxyName)
public void restart()
HazelcastInstancerestart in interface HazelcastInstanceHazelcastInstance.getLifecycleService()public LifecycleService getLifecycleService()
HazelcastInstancegetLifecycleService in interface HazelcastInstancepublic ClientConfig getClientConfig()
Copyright © 2008-2013 Hazelcast, Inc. All Rights Reserved.