use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.
the class SimpleMapTest method load.
private void load(ExecutorService es) throws InterruptedException {
if (!load) {
return;
}
final IMap<String, Object> map = instance.getMap(NAMESPACE);
final Member thisMember = instance.getCluster().getLocalMember();
List<String> lsOwnedEntries = new LinkedList<String>();
for (int i = 0; i < entryCount; i++) {
final String key = String.valueOf(i);
Partition partition = instance.getPartitionService().getPartition(key);
if (thisMember.equals(partition.getOwner())) {
lsOwnedEntries.add(key);
}
}
final CountDownLatch latch = new CountDownLatch(lsOwnedEntries.size());
for (final String ownedKey : lsOwnedEntries) {
es.execute(new Runnable() {
public void run() {
map.put(ownedKey, createValue());
latch.countDown();
}
});
}
latch.await();
}
use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.
the class SimpleMultiMapTest method load.
private static void load(boolean load, ExecutorService es, final MultiMap<String, byte[]> map) {
if (load) {
final Member thisMember = instance.getCluster().getLocalMember();
for (int i = 0; i < entryCount; i++) {
final String key = String.valueOf(i);
Partition partition = instance.getPartitionService().getPartition(key);
if (thisMember.equals(partition.getOwner())) {
es.execute(new Runnable() {
public void run() {
map.put(key, new byte[valueSize]);
}
});
}
}
}
}
use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.
the class EvictionTest method getRecordStore.
private static RecordStore getRecordStore(HazelcastInstance instanceB, String keyOwnedByInstanceA) {
Partition partition = instanceB.getPartitionService().getPartition(keyOwnedByInstanceA);
MapService service = getNodeEngineImpl(instanceB).getService(MapService.SERVICE_NAME);
return service.getMapServiceContext().getPartitionContainer(partition.getPartitionId()).getExistingRecordStore("Test");
}
use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.
the class IndexStatsChangingNumberOfMembersTest method toMemberToPartitionsMap.
private Map<UUID, PartitionIdSet> toMemberToPartitionsMap(HazelcastInstance instance1) {
Map<UUID, PartitionIdSet> memberToPartitions = new HashMap<>();
Set<Partition> partitions = instance1.getPartitionService().getPartitions();
for (Partition partition : partitions) {
UUID member = partition.getOwner().getUuid();
memberToPartitions.computeIfAbsent(member, (key) -> new PartitionIdSet(partitions.size())).add(partition.getPartitionId());
}
return memberToPartitions;
}
use of com.hazelcast.partition.Partition in project hazelcast by hazelcast.
the class HazelcastTestSupport method generateKeyForPartition.
public static String generateKeyForPartition(HazelcastInstance instance, int partitionId) {
Cluster cluster = instance.getCluster();
checkPartitionCountGreaterOrEqualMemberCount(instance);
PartitionService partitionService = instance.getPartitionService();
while (true) {
String id = randomString();
Partition partition = partitionService.getPartition(id);
if (partition.getPartitionId() == partitionId) {
return id;
}
}
}
Aggregations