Search in sources :

Example 96 with Node

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 97 with Node

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());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl) UUID(java.util.UUID) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 98 with Node

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;
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory)

Example 99 with Node

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());
}
Also used : Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) Config(com.hazelcast.config.Config) HazelcastOverloadException(com.hazelcast.core.HazelcastOverloadException) Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) HazelcastInstance(com.hazelcast.core.HazelcastInstance) ExecutionException(java.util.concurrent.ExecutionException) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 100 with Node

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);
}
Also used : Accessors.getNode(com.hazelcast.test.Accessors.getNode) Node(com.hazelcast.instance.impl.Node) ClusterServiceImpl(com.hazelcast.internal.cluster.impl.ClusterServiceImpl)

Aggregations

Node (com.hazelcast.instance.impl.Node)144 Accessors.getNode (com.hazelcast.test.Accessors.getNode)84 HazelcastInstance (com.hazelcast.core.HazelcastInstance)68 Test (org.junit.Test)60 QuickTest (com.hazelcast.test.annotation.QuickTest)57 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)44 Config (com.hazelcast.config.Config)22 Address (com.hazelcast.cluster.Address)20 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)19 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 UUID (java.util.UUID)13 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)12 SerializationService (com.hazelcast.internal.serialization.SerializationService)12 ILogger (com.hazelcast.logging.ILogger)10 MapService (com.hazelcast.map.impl.MapService)10 ClientConnectionRegistration (com.hazelcast.client.impl.spi.impl.listener.ClientConnectionRegistration)9 Operation (com.hazelcast.spi.impl.operationservice.Operation)9 HashMap (java.util.HashMap)9 Data (com.hazelcast.internal.serialization.Data)8 MapServiceContext (com.hazelcast.map.impl.MapServiceContext)8