use of com.hazelcast.instance.DefaultNodeExtension in project hazelcast by hazelcast.
the class InternalPartitionServiceImplTest method setup.
@Before
public void setup() {
TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory();
NodeContext nodeContext = new MockNodeContext(factory.getRegistry(), factory.nextAddress()) {
@Override
public NodeExtension createNodeExtension(Node node) {
return new DefaultNodeExtension(node) {
@Override
public boolean isStartCompleted() {
return startupDone.get();
}
};
}
};
instance = HazelcastInstanceFactory.newHazelcastInstance(new Config(), randomName(), nodeContext);
partitionService = (InternalPartitionServiceImpl) getPartitionService(instance);
thisAddress = getNode(instance).getThisAddress();
partitionCount = partitionService.getPartitionCount();
}
use of com.hazelcast.instance.DefaultNodeExtension in project hazelcast by hazelcast.
the class OperationExecutorImpl_AbstractTest method setup.
@Before
public void setup() throws Exception {
loggingService = new LoggingServiceImpl("foo", "jdk", new BuildInfo("1", "1", "1", 1, false, (byte) 1));
serializationService = new DefaultSerializationServiceBuilder().build();
config = new Config();
config.setProperty(PARTITION_COUNT.getName(), "10");
config.setProperty(PARTITION_OPERATION_THREAD_COUNT.getName(), "10");
config.setProperty(GENERIC_OPERATION_THREAD_COUNT.getName(), "10");
thisAddress = new Address("localhost", 5701);
threadGroup = new HazelcastThreadGroup("foo", loggingService.getLogger(HazelcastThreadGroup.class), Thread.currentThread().getContextClassLoader());
nodeExtension = new DefaultNodeExtension(Mockito.mock(Node.class));
handlerFactory = new DummyOperationRunnerFactory();
responsePacketHandler = new DummyResponsePacketHandler();
}
use of com.hazelcast.instance.DefaultNodeExtension 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);
}
Aggregations