use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ClusterInfoTest method all_nodes_should_have_the_same_cluster_start_time_and_id_after_master_shutdown_and_new_node_join.
@Test
public void all_nodes_should_have_the_same_cluster_start_time_and_id_after_master_shutdown_and_new_node_join() {
HazelcastInstance h1 = factory.newHazelcastInstance();
HazelcastInstance h2 = factory.newHazelcastInstance();
HazelcastInstance h3 = factory.newHazelcastInstance();
assertClusterSize(3, h1, h3);
assertClusterSizeEventually(3, h2);
Node node1 = getNode(h1);
final ClusterServiceImpl clusterService = node1.getClusterService();
long node1ClusterStartTime = clusterService.getClusterClock().getClusterStartTime();
long clusterUpTime = clusterService.getClusterClock().getClusterUpTime();
UUID node1ClusterId = clusterService.getClusterId();
assertTrue(clusterUpTime > 0);
assertTrue(node1.isMaster());
h1.shutdown();
assertClusterSizeEventually(2, h2);
HazelcastInstance h4 = factory.newHazelcastInstance();
Node node2 = getNode(h2);
Node node3 = getNode(h3);
Node node4 = getNode(h4);
// All nodes should have the same cluster start time
assertNotEquals(node1ClusterStartTime, Long.MIN_VALUE);
assertEquals(node1ClusterStartTime, node2.getClusterService().getClusterClock().getClusterStartTime());
assertEquals(node1ClusterStartTime, node3.getClusterService().getClusterClock().getClusterStartTime());
assertEquals(node1ClusterStartTime, node4.getClusterService().getClusterClock().getClusterStartTime());
// All nodes should have the same clusterId
assertEquals(node1ClusterId, node2.getClusterService().getClusterId());
assertEquals(node1ClusterId, node3.getClusterService().getClusterId());
assertEquals(node1ClusterId, node4.getClusterService().getClusterId());
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ClusterInfoTest method all_nodes_should_have_the_same_cluster_start_time_and_cluster_id.
@Test
public void all_nodes_should_have_the_same_cluster_start_time_and_cluster_id() {
HazelcastInstance h1 = factory.newHazelcastInstance();
HazelcastInstance h2 = factory.newHazelcastInstance();
HazelcastInstance h3 = factory.newHazelcastInstance();
assertClusterSize(3, h1, h3);
assertClusterSizeEventually(3, h2);
Node node1 = getNode(h1);
Node node2 = getNode(h2);
Node node3 = getNode(h3);
// All nodes should have same startTime
final ClusterServiceImpl clusterService = node1.getClusterService();
long node1ClusterStartTime = clusterService.getClusterClock().getClusterStartTime();
long clusterUpTime = clusterService.getClusterClock().getClusterUpTime();
UUID node1ClusterId = clusterService.getClusterId();
assertTrue(clusterUpTime > 0);
assertNotEquals(node1ClusterStartTime, Long.MIN_VALUE);
assertEquals(node1ClusterStartTime, node2.getClusterService().getClusterClock().getClusterStartTime());
assertEquals(node1ClusterStartTime, node3.getClusterService().getClusterClock().getClusterStartTime());
// All nodes should have same clusterId
assertNotNull(node1ClusterId);
assertEquals(node1ClusterId, node2.getClusterService().getClusterId());
assertEquals(node1ClusterId, node3.getClusterService().getClusterId());
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ClusterShutdownTest method testClusterShutdownWithSingleMember.
private HazelcastInstance testClusterShutdownWithSingleMember(ClusterState clusterState) {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(4);
HazelcastInstance[] instances = factory.newInstances();
assertClusterSizeEventually(4, instances);
HazelcastInstance hz1 = instances[0];
Node[] nodes = getNodes(instances);
hz1.getCluster().changeClusterState(clusterState);
hz1.getCluster().shutdown();
assertNodesShutDownEventually(nodes);
return hz1;
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class ClusterShutdownTest method clusterShutdown_shouldNotBeRejected_byBackpressure.
@Test
public void clusterShutdown_shouldNotBeRejected_byBackpressure() throws Exception {
Config config = new Config();
config.setProperty(ClusterProperty.PARTITION_COUNT.toString(), "1");
config.setProperty(ClusterProperty.BACKPRESSURE_ENABLED.toString(), "true");
config.setProperty(ClusterProperty.BACKPRESSURE_BACKOFF_TIMEOUT_MILLIS.toString(), "100");
config.setProperty(ClusterProperty.BACKPRESSURE_MAX_CONCURRENT_INVOCATIONS_PER_PARTITION.toString(), "3");
HazelcastInstance hz = createHazelcastInstance(config);
final OperationServiceImpl operationService = getOperationService(hz);
final Address address = getAddress(hz);
for (int i = 0; i < 10; i++) {
Future<Object> future = spawn(new Callable<Object>() {
@Override
public Object call() {
operationService.invokeOnTarget(null, new AlwaysBlockingOperation(), address);
return null;
}
});
try {
future.get();
} catch (ExecutionException e) {
assertInstanceOf(HazelcastOverloadException.class, e.getCause());
}
}
Node node = getNode(hz);
hz.getCluster().shutdown();
assertFalse(hz.getLifecycleService().isRunning());
assertEquals(NodeState.SHUT_DOWN, node.getState());
}
use of com.hazelcast.instance.impl.Node in project hazelcast by hazelcast.
the class LiteMemberJoinTest method reconnect.
private void reconnect(final HazelcastInstance instance1, final HazelcastInstance instance2) {
final Node node1 = getNode(instance1);
final Node node2 = getNode(instance2);
final ClusterServiceImpl clusterService = node1.getClusterService();
clusterService.merge(node2.address);
}
Aggregations