use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl 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() throws Exception {
HazelcastInstance h1 = factory.newHazelcastInstance();
HazelcastInstance h2 = factory.newHazelcastInstance();
HazelcastInstance h3 = factory.newHazelcastInstance();
assertClusterSizeEventually(3, h1);
assertClusterSizeEventually(3, h2);
assertClusterSizeEventually(3, h3);
Node node1 = TestUtil.getNode(h1);
Node node2 = TestUtil.getNode(h2);
Node node3 = TestUtil.getNode(h3);
//All nodes should have same startTime
final ClusterServiceImpl clusterService = node1.getClusterService();
long node1ClusterStartTime = clusterService.getClusterClock().getClusterStartTime();
long clusterUpTime = clusterService.getClusterClock().getClusterUpTime();
String 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.internal.cluster.impl.ClusterServiceImpl 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();
assertClusterSizeEventually(3, h1);
assertClusterSizeEventually(3, h2);
assertClusterSizeEventually(3, h3);
Node node1 = TestUtil.getNode(h1);
final ClusterServiceImpl clusterService = node1.getClusterService();
long node1ClusterStartTime = clusterService.getClusterClock().getClusterStartTime();
long clusterUpTime = clusterService.getClusterClock().getClusterUpTime();
String node1ClusterId = clusterService.getClusterId();
assertTrue(clusterUpTime > 0);
assertTrue(node1.isMaster());
h1.shutdown();
assertClusterSizeEventually(2, h2);
HazelcastInstance h4 = factory.newHazelcastInstance();
Node node2 = TestUtil.getNode(h2);
Node node3 = TestUtil.getNode(h3);
Node node4 = TestUtil.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.internal.cluster.impl.ClusterServiceImpl 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);
}
use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.
the class Invocation_NetworkSplitTest method testWaitingInvocations_whenNodeSplitFromCluster.
private void testWaitingInvocations_whenNodeSplitFromCluster(SplitAction splitAction) throws Exception {
Config config = createConfig();
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(3);
HazelcastInstance hz1 = factory.newHazelcastInstance(config);
HazelcastInstance hz2 = factory.newHazelcastInstance(config);
HazelcastInstance hz3 = factory.newHazelcastInstance(config);
Node node1 = TestUtil.getNode(hz1);
Node node2 = TestUtil.getNode(hz2);
Node node3 = TestUtil.getNode(hz3);
warmUpPartitions(hz1, hz2, hz3);
int partitionId = getPartitionId(hz2);
NodeEngineImpl nodeEngine3 = node3.getNodeEngine();
OperationService operationService3 = nodeEngine3.getOperationService();
Operation op = new AlwaysBlockingOperation();
Future<Object> future = operationService3.invokeOnPartition("", op, partitionId);
// just wait a little to make sure
// operation is landed on wait-queue
sleepSeconds(1);
// execute the given split action
splitAction.run(node1, node2, node3);
// Let node3 detect the split and merge it back to other two.
ClusterServiceImpl clusterService3 = node3.getClusterService();
clusterService3.merge(node1.address);
assertClusterSizeEventually(3, hz1);
assertClusterSizeEventually(3, hz2);
assertClusterSizeEventually(3, hz3);
try {
future.get(1, TimeUnit.MINUTES);
fail("Future.get() should fail with a MemberLeftException!");
} catch (MemberLeftException e) {
// expected
EmptyStatement.ignore(e);
} catch (Exception e) {
fail(e.getClass().getName() + ": " + e.getMessage());
}
}
use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.
the class HeartbeatOperation method run.
@Override
public void run() {
ClusterServiceImpl service = getService();
MemberImpl member = service.getMember(getCallerAddress());
if (member == null) {
ILogger logger = getLogger();
if (logger.isFineEnabled()) {
logger.fine("Heartbeat received from an unknown endpoint: " + getCallerAddress());
}
return;
}
service.getClusterHeartbeatManager().onHeartbeat(member, timestamp);
}
Aggregations