Search in sources :

Example 76 with Node

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

Example 77 with Node

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);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultNodeExtension(com.hazelcast.instance.DefaultNodeExtension) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.Node) DefaultNodeExtension(com.hazelcast.instance.DefaultNodeExtension) NodeExtension(com.hazelcast.instance.NodeExtension) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) MockNodeContext(com.hazelcast.test.mocknetwork.MockNodeContext) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 78 with Node

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);
}
Also used : Node(com.hazelcast.instance.Node)

Example 79 with Node

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);
    }
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) Field(java.lang.reflect.Field) Node(com.hazelcast.instance.Node) IOException(java.io.IOException)

Example 80 with Node

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);
}
Also used : ClusterService(com.hazelcast.internal.cluster.ClusterService) NodeStateImpl(com.hazelcast.monitor.impl.NodeStateImpl) Node(com.hazelcast.instance.Node)

Aggregations

Node (com.hazelcast.instance.Node)131 HazelcastInstance (com.hazelcast.core.HazelcastInstance)60 Test (org.junit.Test)50 QuickTest (com.hazelcast.test.annotation.QuickTest)45 ParallelTest (com.hazelcast.test.annotation.ParallelTest)42 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)21 ClientEventRegistration (com.hazelcast.client.spi.impl.listener.ClientEventRegistration)18 Address (com.hazelcast.nio.Address)17 Config (com.hazelcast.config.Config)14 ClusterServiceImpl (com.hazelcast.internal.cluster.impl.ClusterServiceImpl)13 ILogger (com.hazelcast.logging.ILogger)10 Data (com.hazelcast.nio.serialization.Data)10 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)10 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)9 StringUtil.bytesToString (com.hazelcast.util.StringUtil.bytesToString)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 ClusterService (com.hazelcast.internal.cluster.ClusterService)7 SerializationService (com.hazelcast.spi.serialization.SerializationService)7 ItemListener (com.hazelcast.core.ItemListener)6 Operation (com.hazelcast.spi.Operation)6