Search in sources :

Example 1 with DefaultNodeExtension

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();
}
Also used : DefaultNodeExtension(com.hazelcast.instance.DefaultNodeExtension) MockNodeContext(com.hazelcast.test.mocknetwork.MockNodeContext) NodeContext(com.hazelcast.instance.NodeContext) Config(com.hazelcast.config.Config) Node(com.hazelcast.instance.Node) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) MockNodeContext(com.hazelcast.test.mocknetwork.MockNodeContext) Before(org.junit.Before)

Example 2 with DefaultNodeExtension

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();
}
Also used : DefaultSerializationServiceBuilder(com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder) DefaultNodeExtension(com.hazelcast.instance.DefaultNodeExtension) Address(com.hazelcast.nio.Address) LoggingServiceImpl(com.hazelcast.logging.LoggingServiceImpl) Config(com.hazelcast.config.Config) BuildInfo(com.hazelcast.instance.BuildInfo) HazelcastThreadGroup(com.hazelcast.instance.HazelcastThreadGroup) Before(org.junit.Before)

Example 3 with DefaultNodeExtension

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

Aggregations

Config (com.hazelcast.config.Config)3 DefaultNodeExtension (com.hazelcast.instance.DefaultNodeExtension)3 Node (com.hazelcast.instance.Node)2 Address (com.hazelcast.nio.Address)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 MockNodeContext (com.hazelcast.test.mocknetwork.MockNodeContext)2 Before (org.junit.Before)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 BuildInfo (com.hazelcast.instance.BuildInfo)1 HazelcastThreadGroup (com.hazelcast.instance.HazelcastThreadGroup)1 NodeContext (com.hazelcast.instance.NodeContext)1 NodeExtension (com.hazelcast.instance.NodeExtension)1 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)1 LoggingServiceImpl (com.hazelcast.logging.LoggingServiceImpl)1 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Test (org.junit.Test)1