|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hazelcast.core.Hazelcast
public final class Hazelcast
Factory for all of the Hazelcast data and execution components such as maps, queues, multimaps, topics and executor service.
If not started already, Hazelcast member (HazelcastInstance) will start automatically if any of the functions is called on Hazelcast.
Method Summary | ||
---|---|---|
static 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. |
|
static Set<HazelcastInstance> |
getAllHazelcastInstances()
Returns all active/running HazelcastInstances on this JVM. |
|
static AtomicNumber |
getAtomicNumber(String name)
Creates cluster-wide atomic long. |
|
static Cluster |
getCluster()
Returns the Cluster that this Hazelcast instance is part of. |
|
static Config |
getConfig()
Returns the configuration of this Hazelcast instance. |
|
static ICountDownLatch |
getCountDownLatch(String name)
Creates a cluster-wide CountDownLatch. |
|
static HazelcastInstance |
getDefaultInstance()
Returns the default Hazelcast instance, starts it with the default configuration, if not already started. |
|
static ExecutorService |
getExecutorService()
Returns the default distributed executor service. |
|
static ExecutorService |
getExecutorService(String name)
Returns the distributed executor service for the given name. |
|
static HazelcastInstance |
getHazelcastInstanceByName(String instanceName)
Returns an existing HazelcastInstance with instanceName. |
|
static IdGenerator |
getIdGenerator(String name)
Creates cluster-wide unique IDs. |
|
static Collection<Instance> |
getInstances()
Returns all queue, map, set, list, topic, lock, multimap instances created by Hazelcast. |
|
static LifecycleService |
getLifecycleService()
Returns the lifecycle service for this instance. |
|
static
|
getList(String name)
Returns the distributed list instance with the specified name. |
|
static ILock |
getLock(Object key)
Returns the distributed lock instance for the specified key object. |
|
static LoggingService |
getLoggingService()
Returns the logging service of this Hazelcast instance. |
|
static
|
getMap(String name)
Returns the distributed map instance with the specified name. |
|
static
|
getMultiMap(String name)
Returns the distributed multimap instance with the specified name. |
|
static PartitionService |
getPartitionService()
Returns the partition service of this Hazelcast instance. |
|
static
|
getQueue(String name)
Returns the distributed queue instance with the specified name. |
|
static ISemaphore |
getSemaphore(String name)
Creates a cluster-wide semaphore. |
|
static
|
getSet(String name)
Returns the distributed set instance with the specified name. |
|
static
|
getTopic(String name)
Returns the distributed topic instance with the specified name. |
|
static Transaction |
getTransaction()
Returns the transaction instance associated with the current thread, creates a new one if it wasn't already. |
|
static HazelcastInstance |
init(Config config)
Initializes the default Hazelcast instance with the specified configuration. |
|
static HazelcastInstance |
newHazelcastInstance(Config config)
Creates a new HazelcastInstance (a new node in a cluster). |
|
static void |
removeInstanceListener(InstanceListener instanceListener)
Removes the specified instance listener. |
|
static void |
restart()
Deprecated. as of version 1.9 |
|
static void |
shutdown()
Deprecated. as of version 1.9 |
|
static void |
shutdownAll()
Shuts down all running Hazelcast Instances on this JVM, including the default one if it is running. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static HazelcastInstance init(Config config)
config
- configuration for this Hazelcast instance.
IllegalStateException
- if this instance is already initializedpublic static HazelcastInstance getDefaultInstance()
public static <E> IQueue<E> getQueue(String name)
name
- name of the distributed queue
public static <E> ITopic<E> getTopic(String name)
name
- name of the distributed topic
public static <E> ISet<E> getSet(String name)
name
- name of the distributed set
public static <E> IList<E> getList(String name)
name
- name of the distributed list
public static <K,V> IMap<K,V> getMap(String name)
name
- name of the distributed map
public static <K,V> MultiMap<K,V> getMultiMap(String name)
name
- name of the distributed multimap
public static ILock getLock(Object key)
Lock lock = Hazelcast.getLock("PROCESS_LOCK"); lock.lock(); try { // process } finally { lock.unlock(); }
key
- key of the lock instance
public static Cluster getCluster()
public static ExecutorService getExecutorService()
public static ExecutorService getExecutorService(String name)
name
- name of the executor service
public static 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.
public static AtomicNumber getAtomicNumber(String name)
name
- of the AtomicNumber proxy
public static ICountDownLatch getCountDownLatch(String name)
name
- of the distributed CountDownLatch
public static ISemaphore getSemaphore(String name)
name
- of the distributed Semaphore
public static IdGenerator getIdGenerator(String name)
name
-
public static void shutdown()
getLifecycleService()
public static void shutdownAll()
newHazelcastInstance(Config)
public static void restart()
getLifecycleService()
public static Collection<Instance> getInstances()
public static void addInstanceListener(InstanceListener instanceListener)
instanceListener
- instance listenerpublic static void removeInstanceListener(InstanceListener instanceListener)
instanceListener
- instance listener to removepublic static HazelcastInstance newHazelcastInstance(Config config)
shutdownAll()
.
config
- Configuration for the new HazelcastInstance (member)
shutdownAll()
public static HazelcastInstance getHazelcastInstanceByName(String instanceName)
shutdownAll()
.
instanceName
- Name of the HazelcastInstance (member)
newHazelcastInstance(Config)
,
shutdownAll()
public static Set<HazelcastInstance> getAllHazelcastInstances()
shutdownAll()
.
newHazelcastInstance(Config)
,
getHazelcastInstanceByName(String)
,
shutdownAll()
public static Config getConfig()
public static PartitionService getPartitionService()
public static LoggingService getLoggingService()
public static LifecycleService getLifecycleService()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |