use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.
the class ClusterStateManager method initialClusterState.
void initialClusterState(ClusterState initialState, Version version) {
clusterServiceLock.lock();
try {
final ClusterState currentState = getState();
if (currentState != ClusterState.ACTIVE && currentState != initialState) {
logger.warning("Initial state is already set! " + "Current state: " + currentState + ", Given state: " + initialState);
return;
}
// no need to validate again
setClusterStateAndVersion(initialState, version, true);
} finally {
clusterServiceLock.unlock();
}
}
use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method searchUnknownAddressesInPartitionTable.
private void searchUnknownAddressesInPartitionTable(Address sender, Set<Address> unknownAddresses, int partitionId, Address[] addresses) {
final ClusterServiceImpl clusterService = node.clusterService;
final ClusterState clusterState = clusterService.getClusterState();
for (int index = 0; index < InternalPartition.MAX_REPLICA_COUNT; index++) {
Address address = addresses[index];
if (address != null && node.clusterService.getMember(address) == null) {
if (clusterState == ClusterState.ACTIVE || !clusterService.isMemberRemovedWhileClusterIsNotActive(address)) {
if (logger.isFinestEnabled()) {
logger.finest("Unknown " + address + " found in partition table sent from master " + sender + ". It has probably already left the cluster. partitionId=" + partitionId);
}
unknownAddresses.add(address);
}
}
}
}
use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method memberAdded.
@Override
public void memberAdded(MemberImpl member) {
logger.fine("Adding " + member);
lock.lock();
try {
if (!member.localMember()) {
partitionStateManager.updateMemberGroupsSize();
}
lastMaster = node.getMasterAddress();
if (node.isMaster()) {
if (partitionStateManager.isInitialized()) {
final ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
if (clusterState == ClusterState.ACTIVE) {
migrationManager.triggerControlTask();
}
}
}
} finally {
lock.unlock();
}
}
use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.
the class InternalPartitionServiceImpl method triggerMasterToAssignPartitions.
private void triggerMasterToAssignPartitions() {
if (partitionStateManager.isInitialized()) {
return;
}
if (!node.joined()) {
return;
}
ClusterState clusterState = node.getClusterService().getClusterState();
if (clusterState != ClusterState.ACTIVE) {
logger.warning("Partitions can't be assigned since cluster-state= " + clusterState);
return;
}
if (!triggerMasterFlag.compareAndSet(false, true)) {
return;
}
try {
final Address masterAddress = node.getMasterAddress();
if (masterAddress != null && !masterAddress.equals(node.getThisAddress())) {
Future f = nodeEngine.getOperationService().createInvocationBuilder(SERVICE_NAME, new AssignPartitions(), masterAddress).setTryCount(1).invoke();
f.get(1, TimeUnit.SECONDS);
}
} catch (Exception e) {
logger.finest(e);
} finally {
triggerMasterFlag.set(false);
}
}
use of com.hazelcast.cluster.ClusterState in project hazelcast by hazelcast.
the class MigrationManager method onShutdownRequest.
void onShutdownRequest(Address address) {
if (!partitionStateManager.isInitialized()) {
sendShutdownOperation(address);
return;
}
ClusterState clusterState = node.getClusterService().getClusterState();
if (clusterState == ClusterState.FROZEN || clusterState == ClusterState.PASSIVE) {
sendShutdownOperation(address);
return;
}
if (shutdownRequestedAddresses.add(address)) {
logger.info("Shutdown request of " + address + " is handled");
triggerControlTask();
}
}
Aggregations