use of com.hazelcast.internal.partition.impl.PartitionServiceState in project hazelcast by hazelcast.
the class HazelcastStarterTest method assertSafePartitionServiceState.
private static void assertSafePartitionServiceState(HazelcastInstance realInstance) {
PartitionServiceState partitionServiceState = TestPartitionUtils.getPartitionServiceState(realInstance);
assertEquals(PartitionServiceState.SAFE, partitionServiceState);
}
use of com.hazelcast.internal.partition.impl.PartitionServiceState in project hazelcast by hazelcast.
the class JobCoordinationService method shouldStartJobs.
boolean shouldStartJobs() {
if (!isMaster() || !nodeEngine.isRunning()) {
return false;
}
ClusterState clusterState = nodeEngine.getClusterService().getClusterState();
if (isClusterEnteringPassiveState || clusterState == PASSIVE || clusterState == IN_TRANSITION) {
logger.fine("Not starting jobs because cluster is in passive state or in transition.");
return false;
}
// if there are any members in a shutdown process, don't start jobs
if (!membersShuttingDown.isEmpty()) {
LoggingUtil.logFine(logger, "Not starting jobs because members are shutting down: %s", membersShuttingDown.keySet());
return false;
}
Version clusterVersion = nodeEngine.getClusterService().getClusterVersion();
for (Member m : nodeEngine.getClusterService().getMembers()) {
if (!clusterVersion.equals(m.getVersion().asVersion())) {
logger.fine("Not starting non-light jobs because rolling upgrade is in progress");
return false;
}
}
PartitionServiceState state = getInternalPartitionService().getPartitionReplicaStateChecker().getPartitionServiceState();
if (state != PartitionServiceState.SAFE) {
logger.fine("Not starting jobs because partition replication is not in safe state, but in " + state);
return false;
}
if (!getInternalPartitionService().getPartitionStateManager().isInitialized()) {
logger.fine("Not starting jobs because partitions are not yet initialized.");
return false;
}
return true;
}
use of com.hazelcast.internal.partition.impl.PartitionServiceState in project hazelcast by hazelcast.
the class TestPartitionUtils method getPartitionServiceState.
public static PartitionServiceState getPartitionServiceState(HazelcastInstance instance) {
try {
Node node = getNode(instance);
InternalPartitionService partitionService = node.getPartitionService();
if (isProxyClass(instance.getClass())) {
try {
// this is very ugly, but because of a direct field access to Node.nodeEngine in the MigrationManager
// constructor, we cannot properly mock or proxy the PartitionReplicaStateChecker class
Object delegate = getDelegateFromMock(partitionService);
Object partitionReplicaStateChecker = getFieldValueReflectively(delegate, "partitionReplicaStateChecker");
Method method = partitionReplicaStateChecker.getClass().getMethod("getPartitionServiceState");
Object result = method.invoke(partitionReplicaStateChecker);
return (PartitionServiceState) proxyObjectForStarter(TestPartitionUtils.class.getClassLoader(), result);
} catch (Exception e) {
throw rethrowGuardianException(e);
}
} else {
return partitionService.getPartitionReplicaStateChecker().getPartitionServiceState();
}
} catch (IllegalArgumentException e) {
return PartitionServiceState.SAFE;
}
}
use of com.hazelcast.internal.partition.impl.PartitionServiceState in project hazelcast by hazelcast.
the class HazelcastTestSupport method assertAllInSafeState.
public static void assertAllInSafeState(Collection<HazelcastInstance> nodes) {
Map<Address, PartitionServiceState> nonSafeStates = new HashMap<Address, PartitionServiceState>();
for (HazelcastInstance node : nodes) {
if (node == null) {
continue;
}
final PartitionServiceState state = getPartitionServiceState(node);
if (state != PartitionServiceState.SAFE) {
nonSafeStates.put(Accessors.getAddress(node), state);
}
}
assertTrue("Instances not in safe state! " + nonSafeStates, nonSafeStates.isEmpty());
}
Aggregations