com.hazelcast.cluster.impl
Class ClusterProxy

java.lang.Object
  extended by com.hazelcast.cluster.impl.ClusterProxy
All Implemented Interfaces:
Cluster

public class ClusterProxy
extends Object
implements Cluster


Constructor Summary
ClusterProxy(ClusterServiceImpl clusterService)
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClusterProxy

public ClusterProxy(ClusterServiceImpl clusterService)
Method Detail

getLocalMember

public Member getLocalMember()
Description copied from interface: Cluster
Returns this Hazelcast instance member.

Specified by:
getLocalMember in interface Cluster
Returns:
this Hazelcast instance member

getMembers

public Set<Member> getMembers()
Description copied from interface: Cluster
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()'.

Specified by:
getMembers in interface Cluster
Returns:
current members in the cluster

getClusterTime

public long getClusterTime()
Description copied from interface: Cluster
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.

Specified by:
getClusterTime in interface Cluster
Returns:
cluster-wide time

addMembershipListener

public String addMembershipListener(MembershipListener listener)
Description copied from interface: Cluster
Adds MembershipListener to listen for membership updates.

The addMembershipListener method returns a register-id. This id is needed to remove the MembershipListener using the Cluster.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.

Specified by:
addMembershipListener in interface Cluster
Parameters:
listener - membership listener
Returns:
the registration id.
See Also:
Cluster.removeMembershipListener(String)

removeMembershipListener

public boolean removeMembershipListener(String registrationId)
Description copied from interface: Cluster
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.

Specified by:
removeMembershipListener in interface Cluster
Parameters:
registrationId - the registrationId of MembershipListener to remove.
Returns:
true if the registration is removed, false otherwise.
See Also:
Cluster.addMembershipListener(MembershipListener)


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