Interface HazelcastInstance
Instances should be shut down explicitly. See the shutdown()
method.
If the instance is a client, and you don't shut it down explicitly, it will continue to run and
even connect to another live member if the one it was connected to fails.
Each Hazelcast instance has its own socket and threads.
-
Method Summary
Modifier and TypeMethodDescriptionaddDistributedObjectListener
(DistributedObjectListener distributedObjectListener) com.hazelcast.client.impl.spi.ClientClusterService
Get cluster serviceReturns the Cluster that this Hazelcast instance is part of.com.hazelcast.client.impl.connection.ClientConnectionManager
Get connection managercom.hazelcast.client.impl.spi.impl.listener.ClientCPGroupViewService
Get CP group view serviceReturns the CP subsystem that offers a set of in-memory linearizable data structures<T extends DistributedObject>
TgetDistributedObject
(String serviceName, String name) getExecutorService
(String name) getFlakeIdGenerator
(String name) Creates or returns a cluster-wide unique ID generator.Returns the name of this Hazelcast instance.com.hazelcast.client.impl.spi.ClientInvocationService
Get invocation serviceReturns the lifecycle service for this instance.<E> IList<E>
Creates or returns the distributed list instance with the specified name.com.hazelcast.client.impl.spi.ClientListenerService
Get listener serviceReturns the logging service of this Hazelcast instance.<K,
V> IMap<K, V> Creates or returns the distributed map instance with the specified name.getName()
Returns the name of this Hazelcast instance.Returns the partition service of this Hazelcast instance.getPNCounter
(String name) Creates or returns aPNCounter
with the given name.<E> IQueue<E>
Creates or returns the distributed queue instance with the specified name.<E> ITopic<E>
getReliableTopic
(String name) Creates or returns the reliable topic instance with the specified name.<K,
V> ReplicatedMap<K, V> getReplicatedMap
(String name) Creates or returns the replicated map instance with the specified name.<E> Ringbuffer<E>
getRingbuffer
(String name) Creates or returns the distributed Ringbuffer instance with the specified name.com.hazelcast.spi.impl.executionservice.TaskScheduler
Get task scheduler<E> ITopic<E>
Creates or returns the distributed topic instance with the specified name.boolean
removeDistributedObjectListener
(UUID registrationId) void
shutdown()
Shuts down this HazelcastInstance.
-
Method Details
-
getConnectionManager
com.hazelcast.client.impl.connection.ClientConnectionManager getConnectionManager()Get connection manager -
getTaskScheduler
com.hazelcast.spi.impl.executionservice.TaskScheduler getTaskScheduler()Get task scheduler -
getInvocationService
com.hazelcast.client.impl.spi.ClientInvocationService getInvocationService()Get invocation service -
getListenerService
com.hazelcast.client.impl.spi.ClientListenerService getListenerService()Get listener service -
getClientClusterService
com.hazelcast.client.impl.spi.ClientClusterService getClientClusterService()Get cluster service -
getName
Returns the name of this Hazelcast instance.- Returns:
- name of this Hazelcast instance
-
getInstanceName
Returns the name of this Hazelcast instance.- Returns:
- name of this Hazelcast instance
-
getList
Creates or returns the distributed list instance with the specified name. Index based operations on the list are not supported.- Type Parameters:
E
- the type of elements maintained by the list- Parameters:
name
- name of the distributed list- Returns:
- distributed list instance with the specified name
-
getMap
Creates or returns the distributed map instance with the specified name.- Type Parameters:
K
- key typeV
- value type- Parameters:
name
- name of the distributed map- Returns:
- distributed map instance with the specified name
-
getReplicatedMap
Creates or returns the replicated map instance with the specified name.- Type Parameters:
K
- the type of keys maintained by the replicated mapV
- the type of mapped values- Parameters:
name
- name of the distributed map- Returns:
- replicated map instance with specified name
- Throws:
ReplicatedMapCantBeCreatedOnLiteMemberException
- if it is called on a lite member- Since:
- 3.2
-
getLocalEndpoint
-
getRingbuffer
Creates or returns the distributed Ringbuffer instance with the specified name.- Type Parameters:
E
- the type of the elements that the Ringbuffer contains- Parameters:
name
- name of the distributed Ringbuffer- Returns:
- distributed RingBuffer instance with the specified name
-
getReliableTopic
Creates or returns the reliable topic instance with the specified name.- Type Parameters:
E
- the type of the topic message- Parameters:
name
- name of the reliable topic- Returns:
- the reliable topic
-
getLoggingService
Returns the logging service of this Hazelcast instance.LoggingService allows you to listen for LogEvents generated by Hazelcast runtime. You can log the events somewhere or take action based on the message.
- Returns:
- the logging service of this Hazelcast instance
-
getScheduledExecutorService
-
getFlakeIdGenerator
Creates or returns a cluster-wide unique ID generator. Generated IDs arelong
primitive values and are k-ordered (roughly ordered). IDs are in the range from0
toLong.MAX_VALUE
.The IDs contain timestamp component and a node ID component, which is assigned when the member joins the cluster. This allows the IDs to be ordered and unique without any coordination between members, which makes the generator safe even in split-brain scenario.
For more details and caveats, see class documentation for
FlakeIdGenerator
.- Parameters:
name
- name of theFlakeIdGenerator
- Returns:
- FlakeIdGenerator for the given name
-
getDistributedObject
@Nonnull <T extends DistributedObject> T getDistributedObject(@Nonnull String serviceName, @Nonnull String name) - Type Parameters:
T
- type of the DistributedObject- Parameters:
serviceName
- name of the servicename
- name of the object- Returns:
- DistributedObject created by the service
-
shutdown
void shutdown()Shuts down this HazelcastInstance. For more information see { com.hazelcast.core.LifecycleService#shutdown()}. -
getDistributedObjects
Collection<DistributedObject> getDistributedObjects() -
getCPSubsystem
Returns the CP subsystem that offers a set of in-memory linearizable data structures- Returns:
- the CP subsystem that offers a set of in-memory linearizable data structures
-
addDistributedObjectListener
-
removeDistributedObjectListener
-
getQueue
Creates or returns the distributed queue instance with the specified name.- Type Parameters:
E
- queue item type- Parameters:
name
- name of the distributed queue- Returns:
- distributed queue instance with the specified name
-
getTopic
Creates or returns the distributed topic instance with the specified name.- Type Parameters:
E
- the type of the topic message- Parameters:
name
- name of the distributed topic- Returns:
- distributed topic instance with the specified name
-
getCluster
Returns the Cluster that this Hazelcast instance is part of. Cluster interface allows you to add a listener for membership events and to learn more about the cluster that this Hazelcast instance is part of.- Returns:
- the cluster that this Hazelcast instance is part of
-
getLifecycleService
Returns the lifecycle service for this instance.LifecycleService allows you to shutdown this HazelcastInstance and listen for the lifecycle events.
- Returns:
- the lifecycle service for this instance
-
getExecutorService
-
getPNCounter
Creates or returns aPNCounter
with the given name.The PN counter can be used as a counter with strong eventual consistency guarantees - if operations to the counters stop, the counter values of all replicas that can communicate with each other should eventually converge to the same value.
- Parameters:
name
- the name of the PN counter- Returns:
- a
PNCounter
-
getPartitionService
Returns the partition service of this Hazelcast instance. InternalPartitionService allows you to introspect current partitions in the cluster, partition the owner members, and listen for partition migration events.- Returns:
- the partition service of this Hazelcast instance
-
getUserContext
-
getCPGroupViewService
com.hazelcast.client.impl.spi.impl.listener.ClientCPGroupViewService getCPGroupViewService()Get CP group view service
-