|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.client.HazelcastClient
public class HazelcastClient
Hazelcast Client enables you to do all Hazelcast operations without being a member of the cluster. It connects to one of the cluster members and delegates all cluster wide operations to it. When the connected cluster member dies, client will automatically switch to another live member.
Method Summary | ||
---|---|---|
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()
|
|
|
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. |
|
|
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. |
|
|
getMap(String name)
Returns the distributed map instance with the specified name. |
|
|
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. |
|
|
getQueue(String name)
Returns the distributed queue instance with the specified name. |
|
ISemaphore |
getSemaphore(String name)
Creates cluster-wide semaphore. |
|
|
getSet(String name)
Returns the distributed set instance with the specified name. |
|
|
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
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 map
public <K,V,E> Object getClientProxy(Object o)
public 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 READ_COMMITTED . 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 service
public IdGenerator getIdGenerator(String name)
HazelcastInstance
getIdGenerator
in interface HazelcastInstance
name
- name of the IdGenerator
public AtomicNumber getAtomicNumber(String name)
HazelcastInstance
getAtomicNumber
in interface HazelcastInstance
name
- name of the AtomicNumber proxy
public ICountDownLatch getCountDownLatch(String name)
HazelcastInstance
getCountDownLatch
in interface HazelcastInstance
name
- name of the ICountDownLatch proxy
public ISemaphore getSemaphore(String name)
HazelcastInstance
getSemaphore
in interface HazelcastInstance
name
- name of the ISemaphore proxy
public 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 list
public 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 instance
public <K,V> MultiMap<K,V> getMultiMap(String name)
HazelcastInstance
getMultiMap
in interface HazelcastInstance
name
- name of the distributed multimap
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 queue
public <E> ISet<E> getSet(String name)
HazelcastInstance
getSet
in interface HazelcastInstance
name
- name of the distributed set
public <E> ITopic<E> getTopic(String name)
HazelcastInstance
getTopic
in interface HazelcastInstance
name
- name of the distributed topic
public 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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |