Interface HazelcastInstance


public interface HazelcastInstance
Hazelcast instance. Each instance is a member and/or client in a Hazelcast cluster. When you want to use Hazelcast's distributed data structures, you must first create an instance. Multiple Hazelcast instances can be created on a single JVM.

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 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

      @Nonnull String getName()
      Returns the name of this Hazelcast instance.
      Returns:
      name of this Hazelcast instance
    • getInstanceName

      @Nonnull String getInstanceName()
      Returns the name of this Hazelcast instance.
      Returns:
      name of this Hazelcast instance
    • getList

      @Nonnull <E> IList<E> getList(@Nonnull String name)
      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

      @Nonnull <K, V> IMap<K,V> getMap(@Nonnull String name)
      Creates or returns the distributed map instance with the specified name.
      Type Parameters:
      K - key type
      V - value type
      Parameters:
      name - name of the distributed map
      Returns:
      distributed map instance with the specified name
    • getReplicatedMap

      @Nonnull <K, V> ReplicatedMap<K,V> getReplicatedMap(@Nonnull String name)
      Creates or returns the replicated map instance with the specified name.
      Type Parameters:
      K - the type of keys maintained by the replicated map
      V - 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

      @Nonnull Client getLocalEndpoint()
    • getRingbuffer

      @Nonnull <E> Ringbuffer<E> getRingbuffer(@Nonnull String name)
      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

      @Nonnull <E> ITopic<E> getReliableTopic(@Nonnull String name)
      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

      @Nonnull LoggingService 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

      @Nonnull IScheduledExecutorService getScheduledExecutorService(@Nonnull String name)
    • getFlakeIdGenerator

      @Nonnull FlakeIdGenerator getFlakeIdGenerator(@Nonnull String name)
      Creates or returns a cluster-wide unique ID generator. Generated IDs are long primitive values and are k-ordered (roughly ordered). IDs are in the range from 0 to Long.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 the FlakeIdGenerator
      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 service
      name - 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

      @Nonnull CPSubsystem 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

      UUID addDistributedObjectListener(@Nonnull DistributedObjectListener distributedObjectListener)
    • removeDistributedObjectListener

      boolean removeDistributedObjectListener(@Nonnull UUID registrationId)
    • getQueue

      @Nonnull <E> IQueue<E> getQueue(@Nonnull String name)
      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

      @Nonnull <E> ITopic<E> getTopic(@Nonnull String name)
      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

      @Nonnull Cluster 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

      @Nonnull LifecycleService 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

      @Nonnull IExecutorService getExecutorService(@Nonnull String name)
    • getPNCounter

      @Nonnull PNCounter getPNCounter(@Nonnull String name)
      Creates or returns a PNCounter 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

      @Nonnull PartitionService 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

      @Nonnull ConcurrentMap<String,Object> getUserContext()
    • getCPGroupViewService

      com.hazelcast.client.impl.spi.impl.listener.ClientCPGroupViewService getCPGroupViewService()
      Get CP group view service