com.hazelcast.core
Interface Cluster

All Known Implementing Classes:
ClientClusterProxy, ClusterProxy

public interface Cluster

Hazelcast cluster interface. It provides access to the members in the cluster and one can register for changes in the cluster members.

All the methods on the Cluster are thread-safe.


Method Summary
 String addMembershipListener(MembershipListener listener)
          Adds MembershipListener to listen for membership updates.
 long getClusterTime()
          Returns the cluster-wide time in milliseconds.
 Member getLocalMember()
          Returns this Hazelcast instance member.
 Set<Member> getMembers()
          Set of the current members in the cluster.
 boolean removeMembershipListener(String registrationId)
          Removes the specified MembershipListener.
 

Method Detail

addMembershipListener

String addMembershipListener(MembershipListener listener)
Adds MembershipListener to listen for membership updates.

The addMembershipListener method returns a register-id. This id is needed to remove the MembershipListener using the removeMembershipListener(String) method.

If the MembershipListener implements the InitialMembershipListener interface, it will also receive the InitialMembershipEvent.

There is no check for duplicate registrations, so if you register the listener twice, it will get events twice.

Parameters:
listener - membership listener
Returns:
the registration id.
Throws:
NullPointerException - if listener is null.
See Also:
removeMembershipListener(String)

removeMembershipListener

boolean removeMembershipListener(String registrationId)
Removes the specified MembershipListener.

If the same MembershipListener is registered multiple times, it needs to be removed multiple times. This method can safely be called multiple times for the same registration-id; subsequent calls are ignored.

Parameters:
registrationId - the registrationId of MembershipListener to remove.
Returns:
true if the registration is removed, false otherwise.
Throws:
NullPointerException - if the registration id is null.
See Also:
addMembershipListener(MembershipListener)

getMembers

Set<Member> getMembers()
Set of the current members in the cluster. The returned set is an immutable set; it can't be modified.

The returned set is backed by an ordered set. Every member in the cluster returns the 'members' in the same order. To obtain the oldest member (the master) in the cluster, you can retrieve the first item in the set using 'getMembers().iterator().next()'.

Returns:
current members in the cluster

getLocalMember

Member getLocalMember()
Returns this Hazelcast instance member.

Returns:
this Hazelcast instance member

getClusterTime

long getClusterTime()
Returns the cluster-wide time in milliseconds.

Cluster tries to keep a cluster-wide time which might be different than the member's own system time. Cluster-wide time is -almost- the same on all members of the cluster.

Returns:
cluster-wide time


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.