Search in sources :

Example 46 with HazelcastInstance

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

the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesStartedShutdown_withRestart.

@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesStartedShutdown_withRestart() throws InterruptedException {
    Config config = getConfig(true, false);
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    fillData(hz);
    assertSizeAndDataEventually();
    Collection<Address> addresses = Collections.emptySet();
    int size = 1;
    while (size < (nodeCount + 1)) {
        int startCount = (shutdownNodeCount + 1) - addresses.size();
        startNodes(config, addresses);
        startNodes(config, startCount);
        size += (shutdownNodeCount + 1);
        assertSizeAndDataEventually();
        addresses = shutdownNodes(shutdownNodeCount);
        size -= shutdownNodeCount;
        assertSizeAndData();
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) Config(com.hazelcast.config.Config) Test(org.junit.Test)

Example 47 with HazelcastInstance

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

the class AbstractGracefulShutdownCorrectnessTest method testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing.

@Test(timeout = 6000 * 10 * 10)
public void testPartitionData_whenNodesStartedShutdown_whileOperationsOngoing() throws InterruptedException {
    final Config config = getConfig(true, false);
    Future future = spawn(new Runnable() {

        @Override
        public void run() {
            LinkedList<HazelcastInstance> instances = new LinkedList<HazelcastInstance>(Arrays.asList(factory.newInstances(config, nodeCount)));
            try {
                for (int i = 0; i < 3; i++) {
                    shutdownNodes(instances, shutdownNodeCount);
                    Collection<HazelcastInstance> startedInstances = startNodes(config, shutdownNodeCount);
                    instances.addAll(startedInstances);
                }
                shutdownNodes(instances, shutdownNodeCount);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    });
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    NodeEngine nodeEngine = getNodeEngineImpl(hz);
    OperationService operationService = nodeEngine.getOperationService();
    int partitionCount = nodeEngine.getPartitionService().getPartitionCount();
    int value = 0;
    while (!future.isDone()) {
        value++;
        for (int p = 0; p < partitionCount; p++) {
            operationService.invokeOnPartition(null, new TestPutOperation(value), p).join();
        }
    }
    for (int p = 0; p < partitionCount; p++) {
        Integer actual = (Integer) operationService.invokeOnPartition(null, new TestGetOperation(), p).join();
        assertEquals(value, actual.intValue());
    }
}
Also used : TestPutOperation(com.hazelcast.internal.partition.service.TestPutOperation) TestGetOperation(com.hazelcast.internal.partition.service.TestGetOperation) Config(com.hazelcast.config.Config) LinkedList(java.util.LinkedList) NodeEngine(com.hazelcast.spi.NodeEngine) HazelcastInstance(com.hazelcast.core.HazelcastInstance) Future(java.util.concurrent.Future) Collection(java.util.Collection) OperationService(com.hazelcast.spi.OperationService) Test(org.junit.Test)

Example 48 with HazelcastInstance

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

the class AbstractMigrationCorrectnessTest method testPartitionData_whenNodesStartedParallel.

@Test
public void testPartitionData_whenNodesStartedParallel() throws InterruptedException {
    Config config = getConfig(true, false);
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    fillData(hz);
    assertSizeAndDataEventually();
    startNodes(config, nodeCount);
    assertSizeAndDataEventually();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) Test(org.junit.Test)

Example 49 with HazelcastInstance

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

the class AbstractMigrationCorrectnessTest method testPartitionData_whenBackupNodesStartedTerminated.

public void testPartitionData_whenBackupNodesStartedTerminated(boolean checkAfterTerminate) throws InterruptedException {
    Config config = getConfig(true, false);
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    fillData(hz);
    assertSizeAndDataEventually();
    int size = 1;
    while (size < (nodeCount + 1)) {
        startNodes(config, backupCount + 1);
        size += (backupCount + 1);
        assertSizeAndDataEventually();
        terminateNodes(backupCount);
        size -= backupCount;
        if (checkAfterTerminate) {
            assertSizeAndDataEventually();
        }
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config)

Example 50 with HazelcastInstance

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

the class AbstractPartitionAssignmentsCorrectnessTest method assertPartitionAssignments.

static void assertPartitionAssignments(TestHazelcastInstanceFactory factory) {
    Collection<HazelcastInstance> instances = factory.getAllHazelcastInstances();
    final int replicaCount = Math.min(instances.size(), InternalPartition.MAX_REPLICA_COUNT);
    for (HazelcastInstance hz : instances) {
        Node node = getNode(hz);
        InternalPartitionService partitionService = node.getPartitionService();
        InternalPartition[] partitions = partitionService.getInternalPartitions();
        for (InternalPartition partition : partitions) {
            for (int i = 0; i < replicaCount; i++) {
                Address replicaAddress = partition.getReplicaAddress(i);
                assertNotNull("Replica " + i + " is not found in " + partition, replicaAddress);
                assertTrue("Not member: " + replicaAddress, node.getClusterService().getMember(replicaAddress) != null);
            }
        }
    }
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Address(com.hazelcast.nio.Address) Node(com.hazelcast.instance.Node)

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