Search in sources :

Example 1 with PartitionService

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

the class PartitionServiceProxyTest method testRandomPartitionKeyNotNull.

@Test
public void testRandomPartitionKeyNotNull() {
    PartitionService p = client.getPartitionService();
    String key = p.randomPartitionKey();
    assertNotNull(key);
}
Also used : PartitionService(com.hazelcast.core.PartitionService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 2 with PartitionService

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

the class PartitionServiceProxyTest method testRemoveMigrationListener.

@Test(expected = UnsupportedOperationException.class)
public void testRemoveMigrationListener() throws Exception {
    PartitionService p = client.getPartitionService();
    p.removeMigrationListener("");
}
Also used : PartitionService(com.hazelcast.core.PartitionService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 3 with PartitionService

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

the class PartitionServiceSafetyCheckTest method clusterShouldNotBeSafe_whenBackupsBlocked_withoutAntiEntropy.

@Test
public void clusterShouldNotBeSafe_whenBackupsBlocked_withoutAntiEntropy() throws InterruptedException {
    Config config = getConfig(true, false);
    HazelcastInstance hz = factory.newHazelcastInstance(config);
    startNodes(config, nodeCount - 1);
    final Collection<HazelcastInstance> instances = factory.getAllHazelcastInstances();
    warmUpPartitions(instances);
    for (HazelcastInstance instance : instances) {
        setBackupPacketDropFilter(instance, BLOCK_RATIO);
    }
    fillData(hz);
    assertTrueFiveSeconds(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertFalse(isAllInSafeState(instances));
            for (HazelcastInstance instance : instances) {
                PartitionService ps = instance.getPartitionService();
                assertFalse(ps.isClusterSafe());
            }
        }
    });
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) Config(com.hazelcast.config.Config) AssertTask(com.hazelcast.test.AssertTask) PartitionService(com.hazelcast.core.PartitionService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 4 with PartitionService

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

the class HazelcastOSGiInstanceTest method getPartitionServiceCalledSuccessfullyOverOSGiInstance.

@Test
public void getPartitionServiceCalledSuccessfullyOverOSGiInstance() {
    PartitionService mockPartitionService = mock(PartitionService.class);
    HazelcastInstance mockHazelcastInstance = mock(HazelcastInstance.class);
    HazelcastOSGiInstance hazelcastOSGiInstance = HazelcastOSGiTestUtil.createHazelcastOSGiInstance(mockHazelcastInstance);
    when(mockHazelcastInstance.getPartitionService()).thenReturn(mockPartitionService);
    assertEquals(mockPartitionService, hazelcastOSGiInstance.getPartitionService());
    verify(mockHazelcastInstance).getPartitionService();
}
Also used : HazelcastInstance(com.hazelcast.core.HazelcastInstance) PartitionService(com.hazelcast.core.PartitionService) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test) ParallelTest(com.hazelcast.test.annotation.ParallelTest)

Example 5 with PartitionService

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

the class WriteBehindOnBackupsTest method getOwnerNode.

private HazelcastInstance getOwnerNode(String key, HazelcastInstance[] nodes) {
    PartitionService partitionService = nodes[0].getPartitionService();
    Partition partition = partitionService.getPartition(key);
    Member owner = partition.getOwner();
    for (HazelcastInstance node : nodes) {
        Member localMember = node.getCluster().getLocalMember();
        if (localMember.equals(owner)) {
            return node;
        }
    }
    throw new IllegalStateException("This should not be happen...");
}
Also used : Partition(com.hazelcast.core.Partition) HazelcastInstance(com.hazelcast.core.HazelcastInstance) PartitionService(com.hazelcast.core.PartitionService) Member(com.hazelcast.core.Member)

Aggregations

PartitionService (com.hazelcast.core.PartitionService)22 ParallelTest (com.hazelcast.test.annotation.ParallelTest)17 QuickTest (com.hazelcast.test.annotation.QuickTest)17 Test (org.junit.Test)17 HazelcastInstance (com.hazelcast.core.HazelcastInstance)13 Partition (com.hazelcast.core.Partition)7 Member (com.hazelcast.core.Member)4 InternalPartitionService (com.hazelcast.internal.partition.InternalPartitionService)4 IPartition (com.hazelcast.spi.partition.IPartition)4 Cluster (com.hazelcast.core.Cluster)2 MigrationListener (com.hazelcast.core.MigrationListener)2 TestHazelcastInstanceFactory (com.hazelcast.test.TestHazelcastInstanceFactory)2 Config (com.hazelcast.config.Config)1 MigrationEvent (com.hazelcast.core.MigrationEvent)1 AssertTask (com.hazelcast.test.AssertTask)1