public class ClusterServiceImpl extends Object implements ClusterService, ConnectionListener, ManagedService, EventPublishingService<MembershipEvent,MembershipListener>, TransactionalService
| Modifier and Type | Field and Description |
|---|---|
static String |
SERVICE_NAME |
| Constructor and Description |
|---|
ClusterServiceImpl(Node node) |
| Modifier and Type | Method and Description |
|---|---|
String |
addMembershipListener(MembershipListener listener)
Adds MembershipListener to listen for membership updates.
|
void |
changeClusterState(ClusterState newState)
Changes state of the cluster to the given state transactionally.
|
void |
changeClusterState(ClusterState newState,
TransactionOptions options)
Changes state of the cluster to the given state transactionally.
|
void |
connectionAdded(Connection connection) |
void |
connectionRemoved(Connection connection) |
<T extends TransactionalObject> |
createTransactionalObject(String name,
Transaction transaction) |
void |
dispatchEvent(MembershipEvent event,
MembershipListener listener) |
ClusterClockImpl |
getClusterClock()
Returns the
ClusterClock of the cluster. |
ClusterHeartbeatManager |
getClusterHeartbeatManager() |
String |
getClusterId()
Returns UUID for the cluster.
|
ClusterJoinManager |
getClusterJoinManager() |
ClusterState |
getClusterState()
Returns the state of the cluster.
|
ClusterStateManager |
getClusterStateManager() |
long |
getClusterTime()
Returns the cluster-wide time in milliseconds.
|
Member |
getLocalMember()
Gets the local member instance.
|
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<Address> |
getMemberAddresses() |
Collection<MemberImpl> |
getMemberImpls()
Gets the collection of members.
|
Set<Member> |
getMembers()
Set of the current members in the cluster.
|
Collection<Member> |
getMembers(MemberSelector selector)
Returns a collection of the members that satisfy the given
MemberSelector. |
Collection<MemberImpl> |
getMembersRemovedWhileClusterIsNotActive() |
NodeEngineImpl |
getNodeEngine() |
int |
getSize()
Gets the current number of members.
|
int |
getSize(MemberSelector selector)
Gets the number of members that satisfy the given
MemberSelector instance. |
Address |
getThisAddress()
Gets the address of this member.
|
void |
init(NodeEngine nodeEngine,
Properties properties)
Initializes this ManagedService
|
void |
initialClusterState(ClusterState clusterState) |
boolean |
isMaster()
Checks if this member is the master.
|
boolean |
isMemberRemovedWhileClusterIsNotActive(Address target) |
String |
membersString() |
void |
merge(Address newTargetAddress) |
void |
removeAddress(Address deadAddress) |
boolean |
removeMembershipListener(String registrationId)
Removes the specified MembershipListener.
|
void |
reset()
reset this ManagedService back to initial state.
|
void |
rollbackTransaction(String transactionId) |
void |
sendMemberListToMember(Address target) |
void |
sendShutdownMessage() |
void |
setClusterId(String clusterId) |
void |
shutdown()
Changes state of the cluster to the
ClusterState.PASSIVE transactionally,
then triggers the shutdown process on each node. |
void |
shutdown(boolean terminate)
Shuts down this ManagedService.
|
void |
shutdown(TransactionOptions options)
Changes state of the cluster to the
ClusterState.PASSIVE transactionally, then
triggers the shutdown process on each node. |
String |
toString() |
void |
updateMemberAttribute(String uuid,
MemberAttributeOperationType operationType,
String key,
Object value) |
void |
updateMembers(Collection<MemberInfo> members) |
public static final String SERVICE_NAME
public ClusterServiceImpl(Node node)
public ClusterClockImpl getClusterClock()
ClusterServiceClusterClock of the cluster.
The returned value will never be null and will never change.getClusterClock in interface ClusterServicepublic long getClusterTime()
ClustergetClusterTime in interface Clusterpublic String getClusterId()
ClusterServicegetClusterId in interface ClusterServicepublic void setClusterId(String clusterId)
public void init(NodeEngine nodeEngine, Properties properties)
ManagedServiceinit in interface ManagedServicenodeEngine - the NodeEngine that this ManagedService belongs to.properties - the Properties. Can be used to pass settings to the service.public void sendMemberListToMember(Address target)
public void removeAddress(Address deadAddress)
public void merge(Address newTargetAddress)
public void reset()
ManagedServicereset in interface ManagedServicepublic void updateMembers(Collection<MemberInfo> members)
public void updateMemberAttribute(String uuid, MemberAttributeOperationType operationType, String key, Object value)
public void connectionAdded(Connection connection)
connectionAdded in interface ConnectionListenerpublic void connectionRemoved(Connection connection)
connectionRemoved in interface ConnectionListenerpublic NodeEngineImpl getNodeEngine()
public boolean isMemberRemovedWhileClusterIsNotActive(Address target)
public Collection<MemberImpl> getMembersRemovedWhileClusterIsNotActive()
public void sendShutdownMessage()
public MemberImpl getMember(Address address)
ClusterServicegetMember in interface ClusterServiceaddress - the address of the member to lookup.public MemberImpl getMember(String uuid)
ClusterServicegetMember in interface ClusterServiceuuid - the uuid of the memberpublic Collection<MemberImpl> getMemberImpls()
ClusterServicegetMemberImpls in interface ClusterServicepublic Collection<Address> getMemberAddresses()
public Set<Member> getMembers()
ClustergetMembers in interface Clusterpublic Collection<Member> getMembers(MemberSelector selector)
ClusterServiceMemberSelector.getMembers in interface ClusterServiceselector - MemberSelector instance to filter members to returnMemberSelector.public void shutdown(boolean terminate)
ManagedServiceshutdown in interface ManagedServiceterminate - true to shut down the ManagedServicepublic Address getMasterAddress()
ClusterServicegetMasterAddress in interface ClusterServicepublic boolean isMaster()
ClusterServiceisMaster in interface ClusterServicepublic Address getThisAddress()
ClusterServicegetThisAddress in interface ClusterServicepublic Member getLocalMember()
ClusterServicegetLocalMember in interface ClusterServicegetLocalMember in interface Clusterpublic int getSize()
ClusterServicegetSize in interface ClusterServicepublic int getSize(MemberSelector selector)
ClusterServiceMemberSelector instance.getSize in interface ClusterServiceselector - MemberSelector instance that filters members to be counted.MemberSelector instance.public String addMembershipListener(MembershipListener listener)
ClusterCluster.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.addMembershipListener in interface Clusterlistener - membership listenerCluster.removeMembershipListener(String)public boolean removeMembershipListener(String registrationId)
ClusterremoveMembershipListener in interface ClusterregistrationId - the registrationId of MembershipListener to remove.Cluster.addMembershipListener(MembershipListener)public void dispatchEvent(MembershipEvent event, MembershipListener listener)
dispatchEvent in interface EventPublishingService<MembershipEvent,MembershipListener>public String membersString()
public ClusterState getClusterState()
ClusterClusterState.IN_TRANSITION will be returned.
This is a local operation, state will be read directly from local member.getClusterState in interface Clusterpublic <T extends TransactionalObject> T createTransactionalObject(String name, Transaction transaction)
createTransactionalObject in interface TransactionalServicepublic void rollbackTransaction(String transactionId)
rollbackTransaction in interface TransactionalServicepublic void changeClusterState(ClusterState newState)
ClusterTWO_PHASE and will have 1 durability by default. If you want to override
transaction options, use Cluster.changeClusterState(ClusterState, TransactionOptions).
If the given state is already same as
current state of the cluster, then this method will have no effect.
If there's an ongoing state change transaction in the cluster, this method will fail
immediately with a TransactionException.
If a membership change occurs in the cluster during state change, a new member joins or
an existing member leaves, then this method will fail with an IllegalStateException.
If there are ongoing/pending migration/replication operations, because of re-balancing due to
member join or leave, then trying to change from ACTIVE to FROZEN
or PASSIVE will fail with an IllegalStateException.
If transaction timeouts during state change, then this method will fail with a TransactionException.changeClusterState in interface ClusternewState - new state of the clusterpublic void changeClusterState(ClusterState newState, TransactionOptions options)
ClusterTWO_PHASE transaction.
If the given state is already same as
current state of the cluster, then this method will have no effect.
If there's an ongoing state change transaction in the cluster, this method will fail
immediately with a TransactionException.
If a membership change occurs in the cluster during state change, a new member joins or
an existing member leaves, then this method will fail with an IllegalStateException.
If there are ongoing/pending migration/replication operations, because of re-balancing due to
member join or leave, then trying to change from ACTIVE to FROZEN
or PASSIVE will fail with an IllegalStateException.
If transaction timeouts during state change, then this method will fail with a TransactionException.changeClusterState in interface ClusternewState - new state of the clusteroptions - transaction optionspublic void shutdown()
ClusterClusterState.PASSIVE transactionally,
then triggers the shutdown process on each node. Transaction will be TWO_PHASE
and will have 1 durability by default. If you want to override transaction options,
use Cluster.shutdown(TransactionOptions).
If the cluster is already in ClusterState.PASSIVE, shutdown process begins immediately.
All the node join / leave rules described in ClusterState.PASSIVE state also applies here.
Any node can start the shutdown process. A shutdown command is sent to other nodes periodically until
either all other nodes leave the cluster or a configurable timeout occurs. If some of the nodes do not
shutdown before the timeout duration, shutdown can be also invoked on them.public void shutdown(TransactionOptions options)
ClusterClusterState.PASSIVE transactionally, then
triggers the shutdown process on each node. Transaction must be a TWO_PHASE transaction.
If the cluster is already in ClusterState.PASSIVE, shutdown process begins immediately.
All the node join / leave rules described in ClusterState.PASSIVE state also applies here.
Any node can start the shutdown process. A shutdown command is sent to other nodes periodically until
either all other nodes leave the cluster or a configurable timeout occurs. If some of the nodes do not
shutdown before the timeout duration, shutdown can be also invoked on them.public void initialClusterState(ClusterState clusterState)
public ClusterStateManager getClusterStateManager()
public ClusterJoinManager getClusterJoinManager()
public ClusterHeartbeatManager getClusterHeartbeatManager()
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.