use of com.hazelcast.internal.cluster.impl.ClusterServiceImpl in project hazelcast by hazelcast.
the class FinalizeJoinOperation method sendPostJoinOperations.
private void sendPostJoinOperations() {
final ClusterServiceImpl clusterService = getService();
final NodeEngineImpl nodeEngine = clusterService.getNodeEngine();
// Post join operations must be lock free; means no locks at all;
// no partition locks, no key-based locks, no service level locks!
final Operation[] postJoinOperations = nodeEngine.getPostJoinOperations();
final OperationService operationService = nodeEngine.getOperationService();
if (postJoinOperations != null && postJoinOperations.length > 0) {
final Collection<Member> members = clusterService.getMembers();
for (Member member : members) {
if (!member.localMember()) {
PostJoinOperation operation = new PostJoinOperation(postJoinOperations);
operationService.createInvocationBuilder(ClusterServiceImpl.SERVICE_NAME, operation, member.getAddress()).setTryCount(POST_JOIN_TRY_COUNT).invoke();
}
}
}
}
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 MockConnectionManager method stop.
@Override
public void stop() {
logger.fine("Stopping connection manager");
live = false;
final Member localMember = node.getLocalMember();
final Address thisAddress = localMember.getAddress();
for (Address address : registry.getAddresses()) {
if (address.equals(thisAddress)) {
continue;
}
Node otherNode = registry.getNode(address);
if (otherNode != null && otherNode.getState() != NodeState.SHUT_DOWN) {
logger.fine(otherNode.getThisAddress() + " is instructed to remove us.");
ILogger otherLogger = otherNode.getLogger(MockConnectionManager.class);
otherLogger.fine(localMember + " will be removed from the cluster if present, " + "because it has requested to leave.");
try {
ClusterServiceImpl clusterService = otherNode.getClusterService();
clusterService.removeAddress(localMember.getAddress(), localMember.getUuid(), "Connection manager is stopped on " + localMember);
} catch (Throwable e) {
otherLogger.warning("While removing " + thisAddress, e);
}
}
}
for (Connection connection : mapConnections.values()) {
connection.close(null, null);
}
}
Aggregations