Search in sources :

Example 61 with HazelcastInstance

use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.

the class InternalPartitionServiceStackOverflowTest method test.

public void test(int partitionId) {
    HazelcastInstance hz = createHazelcastInstance();
    OperationService opService = getNode(hz).nodeEngine.getOperationService();
    int iterations = 2000;
    final CountDownLatch latch = new CountDownLatch(iterations);
    for (int k = 0; k < iterations; k++) {
        Operation op;
        if (partitionId >= 0) {
            op = new SlowPartitionAwareSystemOperation(latch, partitionId);
        } else {
            op = new SlowPartitionUnawareSystemOperation(latch);
        }
        op.setOperationResponseHandler(OperationResponseHandlerFactory.createEmptyResponseHandler());
        opService.execute(op);
    }
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() {
            assertEquals(0, latch.getCount());
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) OperationService(com.hazelcast.spi.OperationService) Operation(com.hazelcast.spi.Operation) UrgentSystemOperation(com.hazelcast.spi.UrgentSystemOperation) PartitionAwareOperation(com.hazelcast.spi.PartitionAwareOperation) CountDownLatch(java.util.concurrent.CountDownLatch)

Example 62 with HazelcastInstance

use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.

the class InternalPartitionServiceLiteMemberTest method test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberTerminates.

@Test
public void test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberTerminates() {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    final HazelcastInstance master = factory.newHazelcastInstance();
    final HazelcastInstance lite = factory.newHazelcastInstance(liteMemberConfig);
    warmUpPartitions(master, lite);
    master.getLifecycleService().terminate();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            try {
                final InternalPartitionServiceImpl partitionService = getInternalPartitionServiceImpl(lite);
                partitionService.getPartitionOwnerOrWait(0);
                fail();
            } catch (NoDataMemberInClusterException expected) {
                ignore(expected);
            }
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 63 with HazelcastInstance

use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.

the class InternalPartitionServiceLiteMemberTest method test_getPartition_nullPartitionOwnerOnMasterLiteMember.

/**
     * GET PARTITION
     **/
@Test
public void test_getPartition_nullPartitionOwnerOnMasterLiteMember() {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(1);
    final HazelcastInstance instance = factory.newHazelcastInstance(liteMemberConfig);
    final InternalPartitionServiceImpl partitionService = getInternalPartitionServiceImpl(instance);
    assertNull(partitionService.getPartition(0).getOwnerOrNull());
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 64 with HazelcastInstance

use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.

the class InternalPartitionServiceLiteMemberTest method test_liteMemberCanTerminate_withClusterSize1.

/**
     * TERMINATE
     **/
@Test(timeout = 120000)
public void test_liteMemberCanTerminate_withClusterSize1() {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    final HazelcastInstance lite = factory.newHazelcastInstance(liteMemberConfig);
    lite.getLifecycleService().terminate();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 65 with HazelcastInstance

use of com.hazelcast.core.HazelcastInstance in project hazelcast by hazelcast.

the class InternalPartitionServiceLiteMemberTest method test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberShutsDown.

@Test
public void test_getPartitionOwnerOrWait_onLiteMemberAfterDataMemberShutsDown() {
    final TestHazelcastInstanceFactory factory = createHazelcastInstanceFactory(2);
    final HazelcastInstance master = factory.newHazelcastInstance();
    final HazelcastInstance lite = factory.newHazelcastInstance(liteMemberConfig);
    assertClusterSizeEventually(2, master);
    assertClusterSizeEventually(2, lite);
    warmUpPartitions(master, lite);
    master.getLifecycleService().shutdown();
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            try {
                final InternalPartitionServiceImpl partitionService = getInternalPartitionServiceImpl(lite);
                partitionService.getPartitionOwnerOrWait(0);
                fail();
            } catch (NoDataMemberInClusterException expected) {
                ignore(expected);
            }
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) AssertTask(com.hazelcast.test.AssertTask) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) TestHazelcastInstanceFactory(com.hazelcast.test.TestHazelcastInstanceFactory) NoDataMemberInClusterException(com.hazelcast.partition.NoDataMemberInClusterException) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Aggregations

HazelcastInstance (com.hazelcast.core.HazelcastInstance)2084 Test (org.junit.Test)1684 QuickTest (com.hazelcast.test.annotation.QuickTest)1466 ParallelTest (com.hazelcast.test.annotation.ParallelTest)1389 Config (com.hazelcast.config.Config)815 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)665 AssertTask (com.hazelcast.test.AssertTask)263 MapConfig (com.hazelcast.config.MapConfig)254 CountDownLatch (java.util.concurrent.CountDownLatch)251 NightlyTest (com.hazelcast.test.annotation.NightlyTest)230 MapStoreConfig (com.hazelcast.config.MapStoreConfig)169 IMap (com.hazelcast.core.IMap)149 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)144 ClientConfig (com.hazelcast.client.config.ClientConfig)137 Before (org.junit.Before)111 NearCacheConfig (com.hazelcast.config.NearCacheConfig)106 Member (com.hazelcast.core.Member)99 Map (java.util.Map)96 SlowTest (com.hazelcast.test.annotation.SlowTest)94 SqlPredicate (com.hazelcast.query.SqlPredicate)83