use of com.hazelcast.partition.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());
}
}
});
}
use of com.hazelcast.partition.PartitionService in project hazelcast by hazelcast.
the class LocalAddressRegistryIntegrationTest method randomKeyNameOwnedByPartition.
private String randomKeyNameOwnedByPartition(HazelcastInstance hz, int partitionId) {
PartitionService partitionService = hz.getPartitionService();
while (true) {
String name = randomString();
Partition partition = partitionService.getPartition(name);
if (partition.getPartitionId() == partitionId) {
return name;
}
}
}
use of com.hazelcast.partition.PartitionService in project hazelcast by hazelcast.
the class ClientMigrationListenerTest method testRemoveMigrationListener_whenExistingRegistrationId.
@Test
public void testRemoveMigrationListener_whenExistingRegistrationId() {
HazelcastInstance instance = hazelcastFactory.newHazelcastInstance();
HazelcastInstance client = hazelcastFactory.newHazelcastClient();
PartitionService clientPartitionService = client.getPartitionService();
MigrationListener listener = mock(MigrationListener.class);
UUID registrationId = clientPartitionService.addMigrationListener(listener);
assertRegistrationsSizeEventually(instance, 1);
boolean removed = clientPartitionService.removeMigrationListener(registrationId);
assertRegistrationsSizeEventually(instance, 0);
assertTrue(removed);
HazelcastInstance hz2 = hazelcastFactory.newHazelcastInstance();
warmUpPartitions(instance, hz2);
verifyMigrationListenerNeverInvoked(listener);
}
use of com.hazelcast.partition.PartitionService in project hazelcast by hazelcast.
the class MapFetchIndexOperationTest method getLocalPartitions.
private static PartitionIdSet getLocalPartitions(HazelcastInstance member) {
PartitionService partitionService = member.getPartitionService();
PartitionIdSet res = new PartitionIdSet(partitionService.getPartitions().size());
for (Partition partition : partitionService.getPartitions()) {
if (partition.getOwner().localMember()) {
res.add(partition.getPartitionId());
}
}
return res;
}
use of com.hazelcast.partition.PartitionService in project hazelcast by hazelcast.
the class SqlIndexTestSupport method getLocalEntries.
protected static <K, V> Map<K, V> getLocalEntries(HazelcastInstance member, int count, IntFunction<K> keyProducer, IntFunction<V> valueProducer) {
if (count == 0) {
return Collections.emptyMap();
}
PartitionService partitionService = member.getPartitionService();
Map<K, V> res = new LinkedHashMap<>();
for (int i = 0; i < Integer.MAX_VALUE; i++) {
K key = keyProducer.apply(i);
if (key == null) {
continue;
}
Partition partition = partitionService.getPartition(key);
if (!partition.getOwner().localMember()) {
continue;
}
V value = valueProducer.apply(i);
if (value == null) {
continue;
}
res.put(key, value);
if (res.size() == count) {
break;
}
}
if (res.size() < count) {
throw new RuntimeException("Failed to get the necessary number of keys: " + res.size());
}
return res;
}
Aggregations