Search in sources :

Example 6 with NodeExtension

use of com.hazelcast.instance.impl.NodeExtension in project hazelcast by hazelcast.

the class ServiceManagerImpl method createService.

private <T> T createService(Class<T> service) {
    Node node = nodeEngine.getNode();
    NodeExtension nodeExtension = node.getNodeExtension();
    return nodeExtension.createService(service);
}
Also used : Node(com.hazelcast.instance.impl.Node) NodeExtension(com.hazelcast.instance.impl.NodeExtension)

Example 7 with NodeExtension

use of com.hazelcast.instance.impl.NodeExtension in project hazelcast by hazelcast.

the class AdvancedClusterStateTest method changeClusterState_shouldFail_whenStartupIsNotCompleted.

@Test
public void changeClusterState_shouldFail_whenStartupIsNotCompleted() throws Exception {
    TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
    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.impl.DefaultNodeExtension) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.cluster.Address) Accessors.getAddress(com.hazelcast.test.Accessors.getAddress) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.impl.Node) Accessors.getNode(com.hazelcast.test.Accessors.getNode) NodeExtension(com.hazelcast.instance.impl.NodeExtension) DefaultNodeExtension(com.hazelcast.instance.impl.DefaultNodeExtension) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) MockNodeContext(com.hazelcast.test.mocknetwork.MockNodeContext) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) Test(org.junit.Test) SlowTest(com.hazelcast.test.annotation.SlowTest)

Example 8 with NodeExtension

use of com.hazelcast.instance.impl.NodeExtension in project hazelcast by hazelcast.

the class ClusterStateManagerTest method setup.

@Before
public void setup() {
    NodeExtension nodeExtension = mock(NodeExtension.class);
    when(nodeExtension.isStartCompleted()).thenReturn(true);
    when(nodeExtension.getAuditlogService()).thenReturn(NoOpAuditlogService.INSTANCE);
    when(nodeExtension.isNodeVersionCompatibleWith(ArgumentMatchers.any(Version.class))).thenReturn(true);
    when(node.getPartitionService()).thenReturn(partitionService);
    when(node.getClusterService()).thenReturn(clusterService);
    when(node.getNodeExtension()).thenReturn(nodeExtension);
    when(node.getLogger(ClusterStateManager.class)).thenReturn(mock(ILogger.class));
    when(node.getVersion()).thenReturn(CURRENT_NODE_VERSION);
    when(clusterService.getMembershipManager()).thenReturn(membershipManager);
    when(clusterService.getClusterJoinManager()).thenReturn(mock(ClusterJoinManager.class));
    when(clusterService.getMemberListVersion()).thenReturn(MEMBERLIST_VERSION);
    when(membershipManager.getMemberListVersion()).thenReturn(MEMBERLIST_VERSION);
    when(partitionService.getPartitionStateStamp()).thenReturn(PARTITION_STAMP);
    clusterStateManager = new ClusterStateManager(node, lock);
}
Also used : Version(com.hazelcast.version.Version) MemberVersion(com.hazelcast.version.MemberVersion) ILogger(com.hazelcast.logging.ILogger) NodeExtension(com.hazelcast.instance.impl.NodeExtension) Before(org.junit.Before)

Aggregations

NodeExtension (com.hazelcast.instance.impl.NodeExtension)8 Node (com.hazelcast.instance.impl.Node)3 Config (com.hazelcast.config.Config)2 DefaultNodeExtension (com.hazelcast.instance.impl.DefaultNodeExtension)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 MockNodeContext (com.hazelcast.test.mocknetwork.MockNodeContext)2 Test (org.junit.Test)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 Address (com.hazelcast.cluster.Address)1 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 ILogger (com.hazelcast.logging.ILogger)1 OperationRunner (com.hazelcast.spi.impl.operationexecutor.OperationRunner)1 PartitionOperationThread (com.hazelcast.spi.impl.operationexecutor.impl.PartitionOperationThread)1 Accessors.getAddress (com.hazelcast.test.Accessors.getAddress)1 Accessors.getNode (com.hazelcast.test.Accessors.getNode)1 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 SlowTest (com.hazelcast.test.annotation.SlowTest)1 SamplingNodeExtension (com.hazelcast.test.compatibility.SamplingNodeExtension)1 MemberVersion (com.hazelcast.version.MemberVersion)1