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);
}
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);
}
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);
}
Aggregations