public Partition getPartition(UUID id) { return partitionService.getPartition(id); }
private int partitionId(@Nonnull String sequencerName) { Partition partition = partitionService.getPartition(sequencerName); return partition.getPartitionId(); }
@Override public boolean apply(Map.Entry<K, V> mapEntry) { if (partitions.contains(partService.getPartition(mapEntry.getKey()).getPartitionId())) { return predicate.apply(mapEntry); } return false; }
@Override public boolean apply(Map.Entry<K, V> mapEntry) { if (member.equals(partService.getPartition(mapEntry.getKey()).getOwner())) { return predicate.apply(mapEntry); } return false; }
@Override public final K next() { for (; ; ) { K key = generateKey(); Partition partition = partitionService.getPartition(key); Set<K> keys = keysPerPartition[partition.getPartitionId()]; if (keys == null) { continue; } if (keys.contains(key)) { continue; } if (keys.size() == maxKeysPerPartition) { continue; } keys.add(key); return key; } }
private static boolean isLocalKey(HazelcastInstance instance, String key) { PartitionService partitionService = instance.getPartitionService(); Partition partition = partitionService.getPartition(key); Member owner = partition.getOwner(); return owner.equals(instance.getLocalEndpoint()); }
private static void load(boolean load, ExecutorService es, final MultiMap<String, byte[]> map) { if (load) { 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]); } }); } } } }
@BeforeRun public void beforeRun(ThreadState state) { if (isClient(targetInstance)) { throw new IllegalArgumentException("SyntheticTest doesn't support clients at the moment"); } state.operationService = HazelcastTestUtils.getOperationService(targetInstance); int[] keys = KeyUtils.generateIntKeys(keyCount, keyLocality, targetInstance); for (int key : keys) { Partition partition = targetInstance.getPartitionService().getPartition(key); state.partitionSequence.add(partition.getPartitionId()); } Collections.shuffle(state.partitionSequence); }
@BeforeRun public void beforeRun(ThreadState state) { if (isClient(targetInstance)) { throw new IllegalArgumentException("SyntheticTest doesn't support clients at the moment"); } state.operationService = HazelcastTestUtils.getOperationService(targetInstance); int[] keys = KeyUtils.generateIntKeys(keyCount, keyLocality, targetInstance); for (int key : keys) { Partition partition = targetInstance.getPartitionService().getPartition(key); state.partitionSequence.add(partition.getPartitionId()); } Collections.shuffle(state.partitionSequence); }
@BeforeRun public void beforeRun(ThreadState state) { if (isClient(targetInstance)) { throw new IllegalArgumentException("SyntheticTest doesn't support clients at the moment"); } state.operationService = HazelcastTestUtils.getOperationService(targetInstance); int[] keys = KeyUtils.generateIntKeys(keyCount, keyLocality, targetInstance); for (int key : keys) { Partition partition = targetInstance.getPartitionService().getPartition(key); state.partitionSequence.add(partition.getPartitionId()); } Collections.shuffle(state.partitionSequence); }
@BeforeRun public void beforeRun(ThreadState state) { if (isClient(targetInstance)) { throw new IllegalArgumentException("SyntheticTest doesn't support clients at the moment"); } state.operationService = HazelcastTestUtils.getOperationService(targetInstance); int[] keys = KeyUtils.generateIntKeys(keyCount, keyLocality, targetInstance); for (int key : keys) { Partition partition = targetInstance.getPartitionService().getPartition(key); state.partitionSequence.add(partition.getPartitionId()); } Collections.shuffle(state.partitionSequence); }
@BeforeRun public void beforeRun(ThreadState state) { if (isClient(targetInstance)) { throw new IllegalArgumentException("SyntheticTest doesn't support clients at the moment"); } state.operationService = HazelcastTestUtils.getOperationService(targetInstance); int[] keys = KeyUtils.generateIntKeys(keyCount, keyLocality, targetInstance); for (int key : keys) { Partition partition = targetInstance.getPartitionService().getPartition(key); state.partitionSequence.add(partition.getPartitionId()); } Collections.shuffle(state.partitionSequence); }
private int getKeyPartitionId(Object key) { return getClient().getPartitionService().getPartition(key).getPartitionId(); }
private int getKeyPartitionId(Object key) { return getClient().getPartitionService().getPartition(key).getPartitionId(); }
private String getServiceInfo(DistributedObject obj) { final Partition partition = instance.getPartitionService().getPartition(obj.getPartitionKey()); return String.format("serviceName=%s, partitionId=%d, owner=%s", obj.getServiceName(), partition.getPartitionId(), partition.getOwner()); }
/** * Returns the next {@code long} key owned by the given Hazelcast instance. * * @param instance Hazelcast instance to search next key for * @param lastKey last key to start search from * @return next key owned by given Hazelcast instance */ public static long nextKeyOwnedBy(HazelcastInstance instance, long lastKey) { Member localMember = instance.getCluster().getLocalMember(); PartitionService partitionService = instance.getPartitionService(); while (true) { Partition partition = partitionService.getPartition(lastKey); if (localMember.equals(partition.getOwner())) { return lastKey; } lastKey++; } }
/** * Returns the next {@code long} key owned by the given Hazelcast instance. * * @param instance Hazelcast instance to search next key for * @param lastKey last key to start search from * @return next key owned by given Hazelcast instance */ public static long nextKeyOwnedBy(HazelcastInstance instance, long lastKey) { Member localMember = instance.getCluster().getLocalMember(); PartitionService partitionService = instance.getPartitionService(); while (true) { Partition partition = partitionService.getPartition(lastKey); if (localMember.equals(partition.getOwner())) { return lastKey; } lastKey++; } }
/** * Returns the next {@code long} key owned by the given Hazelcast instance. * * @param instance Hazelcast instance to search next key for * @param lastKey last key to start search from * @return next key owned by given Hazelcast instance */ public static long nextKeyOwnedBy(HazelcastInstance instance, long lastKey) { Member localMember = instance.getCluster().getLocalMember(); PartitionService partitionService = instance.getPartitionService(); while (true) { Partition partition = partitionService.getPartition(lastKey); if (localMember.equals(partition.getOwner())) { return lastKey; } lastKey++; } }
/** * Checks if a key is located on a Hazelcast instance. * * @param instance the HazelcastInstance the key should belong to * @param key the key to check * @return <tt>true</tt> if the key belongs to the Hazelcast instance, <tt>false</tt> otherwise */ public static boolean isLocalKey(HazelcastInstance instance, Object key) { PartitionService partitionService = instance.getPartitionService(); Partition partition = partitionService.getPartition(key); Member owner; while (true) { owner = partition.getOwner(); if (owner != null) { break; } sleepSeconds(1); } return owner.equals(instance.getLocalEndpoint()); }
@Override public void init(@Nonnull Context context) { if (context.localParallelism() != 1) { throw new IllegalArgumentException( "Non-distributed vertex had parallelism of " + context.localParallelism() + ", should be 1"); } String key = StringPartitioningStrategy.getPartitionKey(partitionKey); ownerAddress = context.jetInstance().getHazelcastInstance().getPartitionService() .getPartition(key).getOwner().getAddress(); }