use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class BasicClusterStateTest method assertNodeState.
private static void assertNodeState(HazelcastInstance[] instances, NodeState expectedState) {
for (HazelcastInstance instance : instances) {
Node node = getNode(instance);
assertEquals(expectedState, node.getState());
}
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method changeClusterState_shouldFail_whenStartupIsNotCompleted.
@Test
public void changeClusterState_shouldFail_whenStartupIsNotCompleted() throws Exception {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
final AtomicBoolean startupDone = new AtomicBoolean(false);
HazelcastInstance instance = HazelcastInstanceFactory.newHazelcastInstance(new Config(), randomName(), new MockNodeContext(factory.getRegistry(), new Address("127.0.0.1", 5555)) {
@Override
public NodeExtension createNodeExtension(Node node) {
return new DefaultNodeExtension(node) {
@Override
public boolean isStartCompleted() {
return startupDone.get() && super.isStartCompleted();
}
};
}
});
try {
instance.getCluster().changeClusterState(ClusterState.FROZEN);
fail("Should not be able to change cluster state when startup is not completed yet!");
} catch (IllegalStateException expected) {
}
startupDone.set(true);
instance.getCluster().changeClusterState(ClusterState.FROZEN);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class AdvancedClusterStateTest method lockClusterState.
private void lockClusterState(HazelcastInstance hz) {
final Node node = getNode(hz);
int partitionStateVersion = node.getPartitionService().getPartitionStateVersion();
long timeoutInMillis = TimeUnit.SECONDS.toMillis(60);
ClusterStateManager clusterStateManager = node.clusterService.getClusterStateManager();
clusterStateManager.lockClusterState(ClusterStateChange.from(ClusterState.FROZEN), node.getThisAddress(), "fakeTxn", timeoutInMillis, partitionStateVersion);
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class DiagnosticsLogTest method getDiagnostics.
public Diagnostics getDiagnostics(HazelcastInstance hazelcastInstance) {
Node node = getNode(hazelcastInstance);
NodeEngineImpl nodeEngine = node.nodeEngine;
try {
Field field = NodeEngineImpl.class.getDeclaredField("diagnostics");
field.setAccessible(true);
return (Diagnostics) field.get(nodeEngine);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.hazelcast.instance.Node in project hazelcast by hazelcast.
the class TimedMemberStateFactory method createNodeState.
private void createNodeState(MemberStateImpl memberState) {
Node node = instance.node;
ClusterService cluster = instance.node.clusterService;
NodeStateImpl nodeState = new NodeStateImpl(cluster.getClusterState(), node.getState(), cluster.getClusterVersion(), node.getVersion());
memberState.setNodeState(nodeState);
}
Aggregations