public interface Cluster
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 transactionOptions)
Changes state of the cluster to the given state transactionally.
|
ClusterState |
getClusterState()
Returns the state of the cluster.
|
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.
|
void |
shutdown()
Changes state of the cluster to the
ClusterState.PASSIVE transactionally,
then triggers the shutdown process on each node. |
void |
shutdown(TransactionOptions transactionOptions)
Changes state of the cluster to the
ClusterState.PASSIVE transactionally, then
triggers the shutdown process on each node. |
String addMembershipListener(MembershipListener listener)
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.listener
- membership listenerNullPointerException
- if listener is null.removeMembershipListener(String)
boolean removeMembershipListener(String registrationId)
registrationId
- the registrationId of MembershipListener to remove.NullPointerException
- if the registration id is null.addMembershipListener(MembershipListener)
Set<Member> getMembers()
Member getLocalMember()
long getClusterTime()
ClusterState getClusterState()
ClusterState.IN_TRANSITION
will be returned.
This is a local operation, state will be read directly from local member.void changeClusterState(ClusterState newState)
TWO_PHASE
and will have 1 durability by default. If you want to override
transaction options, use 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
.newState
- new state of the clusterNullPointerException
- if newState is nullIllegalArgumentException
- if newState is ClusterState.IN_TRANSITION
IllegalStateException
- if member-list changes during the transaction
or there are ongoing/pending migration operationsTransactionException
- if there's already an ongoing transaction
or this transaction fails
or this transaction timeoutsvoid changeClusterState(ClusterState newState, TransactionOptions transactionOptions)
TWO_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
.newState
- new state of the clustertransactionOptions
- transaction optionsNullPointerException
- if newState is nullIllegalArgumentException
- if newState is ClusterState.IN_TRANSITION
or transaction type is not TWO_PHASE
IllegalStateException
- if member-list changes during the transaction
or there are ongoing/pending migration operationsTransactionException
- if there's already an ongoing transaction
or this transaction fails
or this transaction timeoutsvoid shutdown()
ClusterState.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 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.IllegalStateException
- if member-list changes during the transaction
or there are ongoing/pending migration operationsTransactionException
- if there's already an ongoing transaction
or this transaction fails
or this transaction timeoutscom.hazelcast.instance.GroupProperty#CLUSTER_SHUTDOWN_TIMEOUT_SECONDS}
,
#changeClusterState(ClusterState)}
,
ClusterState#PASSIVE}
void shutdown(TransactionOptions transactionOptions)
ClusterState.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.transactionOptions
- transaction optionsIllegalStateException
- if member-list changes during the transaction
or there are ongoing/pending migration operationsTransactionException
- if there's already an ongoing transaction
or this transaction fails
or this transaction timeoutscom.hazelcast.instance.GroupProperty#CLUSTER_SHUTDOWN_TIMEOUT_SECONDS}
,
#changeClusterState(ClusterState)}
,
ClusterState#PASSIVE}
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.