com.hazelcast.cluster.impl
Class ClusterServiceImpl

java.lang.Object
  extended by com.hazelcast.cluster.impl.ClusterServiceImpl
All Implemented Interfaces:
ClusterService, ConnectionListener, CoreService, EventPublishingService<MembershipEvent,MembershipListener>, ManagedService

public final class ClusterServiceImpl
extends Object
implements ClusterService, ConnectionListener, ManagedService, EventPublishingService<MembershipEvent,MembershipListener>


Field Summary
static String SERVICE_NAME
           
protected  Address thisAddress
           
protected  MemberImpl thisMember
           
 
Constructor Summary
ClusterServiceImpl(Node node)
           
 
Method Summary
 void acceptMasterConfirmation(MemberImpl member)
           
 String addMembershipListener(MembershipListener listener)
           
 void answerMasterQuestion(JoinMessage joinMessage)
           
 JoinRequest checkJoinInfo(Address target)
           
 void connectionAdded(Connection connection)
           
 void connectionRemoved(Connection connection)
           
protected  MemberImpl createMember(Address address, String nodeUuid, String ipV6ScopeId, Map<String,Object> attributes)
           
 void dispatchEvent(MembershipEvent event, MembershipListener listener)
           
 Cluster getClusterProxy()
           
 long getClusterTime()
          Returns the cluster-time.
 long getClusterTimeFor(long localTime)
           
 Member getLocalMember()
           
 Address getMasterAddress()
          Returns the address of the master member.
 MemberImpl getMember(Address address)
          Gets the member for the given address.
 MemberImpl getMember(String uuid)
          Gets the member with the given uuid.
 Collection<MemberImpl> getMemberList()
          Gets the collection of members.
 Set<Member> getMembers()
          Returns a collection of all members part of the cluster.
 NodeEngineImpl getNodeEngine()
           
 int getSize()
          Gets the current number of members.
 Address getThisAddress()
          Gets the address of this member.
 void handleJoinRequest(JoinRequest joinRequest, Connection connection)
           
 void handleMaster(Address masterAddress, Address callerAddress)
           
 void init(NodeEngine nodeEngine, Properties properties)
          Initializes this ManagedService
 boolean isJoinInProgress()
           
 boolean isMaster()
          Checks if this member is the master.
 String membersString()
           
 void merge(Address newTargetAddress)
           
 void prepareToMerge(Address newTargetAddress)
           
 void removeAddress(Address deadAddress)
           
 boolean removeMembershipListener(String registrationId)
           
 void reset()
          reset this ManagedService back to initial state.
 boolean sendJoinRequest(Address toAddress, boolean withCredentials)
           
 boolean sendMasterQuestion(Address toAddress)
           
 void sendShutdownMessage()
           
 void setMasterTime(long masterTime)
           
 void shutdown(boolean terminate)
          Shuts down this ManagedService.
 String toString()
           
 void updateMemberAttribute(String uuid, MemberAttributeOperationType operationType, String key, Object value)
           
 void updateMembers(Collection<MemberInfo> members)
           
 boolean validateJoinMessage(JoinMessage joinMessage)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SERVICE_NAME

public static final String SERVICE_NAME
See Also:
Constant Field Values

thisAddress

protected final Address thisAddress

thisMember

protected final MemberImpl thisMember
Constructor Detail

ClusterServiceImpl

public ClusterServiceImpl(Node node)
Method Detail

init

public void init(NodeEngine nodeEngine,
                 Properties properties)
Description copied from interface: ManagedService
Initializes this ManagedService

Specified by:
init in interface ManagedService
Parameters:
nodeEngine - the NodeEngine this ManagedService belongs to.
properties - the Properties. Can be used to pass settings to the service.

isJoinInProgress

public boolean isJoinInProgress()

checkJoinInfo

public JoinRequest checkJoinInfo(Address target)

validateJoinMessage

public boolean validateJoinMessage(JoinMessage joinMessage)
                            throws Exception
Throws:
Exception

removeAddress

public void removeAddress(Address deadAddress)

answerMasterQuestion

public void answerMasterQuestion(JoinMessage joinMessage)

handleJoinRequest

public void handleJoinRequest(JoinRequest joinRequest,
                              Connection connection)

handleMaster

public void handleMaster(Address masterAddress,
                         Address callerAddress)

acceptMasterConfirmation

public void acceptMasterConfirmation(MemberImpl member)

prepareToMerge

public void prepareToMerge(Address newTargetAddress)

merge

public void merge(Address newTargetAddress)

reset

public void reset()
Description copied from interface: ManagedService
reset this ManagedService back to initial state. todo: what is the purpose of reset

Specified by:
reset in interface ManagedService

updateMembers

public void updateMembers(Collection<MemberInfo> members)

updateMemberAttribute

public void updateMemberAttribute(String uuid,
                                  MemberAttributeOperationType operationType,
                                  String key,
                                  Object value)

sendJoinRequest

public boolean sendJoinRequest(Address toAddress,
                               boolean withCredentials)

sendMasterQuestion

public boolean sendMasterQuestion(Address toAddress)

connectionAdded

public void connectionAdded(Connection connection)
Specified by:
connectionAdded in interface ConnectionListener

connectionRemoved

public void connectionRemoved(Connection connection)
Specified by:
connectionRemoved in interface ConnectionListener

getNodeEngine

public NodeEngineImpl getNodeEngine()

sendShutdownMessage

public void sendShutdownMessage()

createMember

protected MemberImpl createMember(Address address,
                                  String nodeUuid,
                                  String ipV6ScopeId,
                                  Map<String,Object> attributes)

getMember

public MemberImpl getMember(Address address)
Description copied from interface: ClusterService
Gets the member for the given address.

Specified by:
getMember in interface ClusterService
Parameters:
address - the address of the member to lookup.
Returns:
the found member, or null if not found. If address is null, null is returned.

getMember

public MemberImpl getMember(String uuid)
Description copied from interface: ClusterService
Gets the member with the given uuid.

Specified by:
getMember in interface ClusterService
Parameters:
uuid - the uuid of the member
Returns:
the found member, or null if not found. If uuid is null, null is returned.

getMemberList

public Collection<MemberImpl> getMemberList()
Description copied from interface: ClusterService
Gets the collection of members.

TODO: The name of this method is confusing since it says that a list is returned, but a collection is returned. TODO: This method also is a bit of a duplicate since there already is getMembers. So I think this method can be dropped if we take care of the generics.

Specified by:
getMemberList in interface ClusterService
Returns:
the collection of member. Null will never be returned.

getMembers

public Set<Member> getMembers()
Description copied from interface: ClusterService
Returns a collection of all members part of the cluster.

Specified by:
getMembers in interface ClusterService
Returns:
all members that are part of the cluster.

shutdown

public void shutdown(boolean terminate)
Description copied from interface: ManagedService
Shuts down this ManagedService. todo: what is the purpose of the terminate variable.

Specified by:
shutdown in interface ManagedService

getMasterAddress

public Address getMasterAddress()
Description copied from interface: ClusterService
Returns the address of the master member.

Specified by:
getMasterAddress in interface ClusterService
Returns:
the address of the master member. Could be null if the master is not yet known.

isMaster

public boolean isMaster()
Description copied from interface: ClusterService
Checks if this member is the master.

Specified by:
isMaster in interface ClusterService
Returns:
true if master, false otherwise.

getThisAddress

public Address getThisAddress()
Description copied from interface: ClusterService
Gets the address of this member.

Specified by:
getThisAddress in interface ClusterService
Returns:
the address of this member. The returned value will never be null.

getLocalMember

public Member getLocalMember()

getSize

public int getSize()
Description copied from interface: ClusterService
Gets the current number of members.

Specified by:
getSize in interface ClusterService
Returns:
the current number of members.

getClusterTime

public long getClusterTime()
Description copied from interface: ClusterService
Returns the cluster-time.

TODO: We need to document what cluster time really means and what is can be used for.

Specified by:
getClusterTime in interface ClusterService
Returns:
the cluster-time.

setMasterTime

public void setMasterTime(long masterTime)

getClusterTimeFor

public long getClusterTimeFor(long localTime)

addMembershipListener

public String addMembershipListener(MembershipListener listener)

removeMembershipListener

public boolean removeMembershipListener(String registrationId)

dispatchEvent

public void dispatchEvent(MembershipEvent event,
                          MembershipListener listener)
Specified by:
dispatchEvent in interface EventPublishingService<MembershipEvent,MembershipListener>

getClusterProxy

public Cluster getClusterProxy()

membersString

public String membersString()

toString

public String toString()
Overrides:
toString in class Object


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