|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface HazelcastInstance
Hazelcast instance. Each Hazelcast instance is a member. Multiple Hazelcast instances can be created on a JVM. Each Hazelcast instance has its own socket, threads.
Hazelcast.newHazelcastInstance(Config config)
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. |
|
AtomicNumber |
getAtomicNumber(String name)
Creates cluster-wide atomic long. |
|
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. |
|
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. |
|
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 key)
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 |
|
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. |
|
void |
removeInstanceListener(InstanceListener instanceListener)
Removes the specified instance listener. |
|
void |
restart()
Deprecated. as of version 1.9 |
|
void |
shutdown()
Deprecated. as of version 1.9 |
Method Detail |
---|
String getName()
<E> IQueue<E> getQueue(String name)
name
- name of the distributed queue
<E> ITopic<E> getTopic(String name)
name
- name of the distributed topic
<E> ISet<E> getSet(String name)
name
- name of the distributed set
<E> IList<E> getList(String name)
name
- name of the distributed list
<K,V> IMap<K,V> getMap(String name)
name
- name of the distributed map
<K,V> MultiMap<K,V> getMultiMap(String name)
name
- name of the distributed multimap
ILock getLock(Object key)
Lock lock = Hazelcast.getLock("PROCESS_LOCK"); lock.lock(); try { // process } finally { lock.unlock(); }
key
- key of the lock instance
Cluster getCluster()
ExecutorService getExecutorService()
ExecutorService getExecutorService(String name)
name
- name of the executor service
Transaction getTransaction()
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.
IdGenerator getIdGenerator(String name)
name
- name of the IdGenerator
AtomicNumber getAtomicNumber(String name)
name
- name of the AtomicNumber proxy
ICountDownLatch getCountDownLatch(String name)
name
- name of the ICountDownLatch proxy
ISemaphore getSemaphore(String name)
name
- name of the ISemaphore proxy
void shutdown()
getLifecycleService()
void restart()
getLifecycleService()
Collection<Instance> getInstances()
void addInstanceListener(InstanceListener instanceListener)
instanceListener
- instance listenervoid removeInstanceListener(InstanceListener instanceListener)
instanceListener
- instance listener to removeConfig getConfig()
PartitionService getPartitionService()
ClientService getClientService()
LoggingService getLoggingService()
LifecycleService getLifecycleService()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |