use of com.hazelcast.core.Partition in project hazelcast by hazelcast.
the class PartitionServiceProxyTest method testGetPartitions.
@Test
public void testGetPartitions() {
String key = "Key";
PartitionService clientPartitionService = client.getPartitionService();
Set<Partition> clientPartitions = clientPartitionService.getPartitions();
PartitionService serverPartitionService = server.getPartitionService();
Set<Partition> serverPartitions = serverPartitionService.getPartitions();
assertEquals(clientPartitions.size(), serverPartitions.size());
}
use of com.hazelcast.core.Partition in project hazelcast by hazelcast.
the class PartitionServiceProxyTest method testGetPartition.
@Test
public void testGetPartition() {
String key = "Key";
PartitionService clientPartitionService = client.getPartitionService();
Partition clientPartition = clientPartitionService.getPartition(key);
PartitionService serverPartitionService = server.getPartitionService();
Partition serverPartition = serverPartitionService.getPartition(key);
assertEquals(clientPartition.getPartitionId(), serverPartition.getPartitionId());
}
use of com.hazelcast.core.Partition in project gora by apache.
the class JCacheStore method getPartitions.
@Override
public List<PartitionQuery<K, T>> getPartitions(Query<K, T> query) throws IOException {
List<PartitionQuery<K, T>> partitions = new ArrayList<>();
try {
Member[] clusterMembers = new Member[hazelcastInstance.getCluster().getMembers().size()];
this.hazelcastInstance.getCluster().getMembers().toArray(clusterMembers);
for (Member member : clusterMembers) {
JCacheResult<K, T> result = ((JCacheResult<K, T>) query.execute());
ConcurrentSkipListSet<K> memberOwnedCacheEntries = new ConcurrentSkipListSet<>();
while (result.next()) {
K key = result.getKey();
Partition partition = hazelcastInstance.getPartitionService().getPartition(key);
if (partition.getOwner().getUuid().equals(member.getUuid())) {
memberOwnedCacheEntries.add(key);
}
}
PartitionQueryImpl<K, T> partition = new PartitionQueryImpl<>(query, memberOwnedCacheEntries.first(), memberOwnedCacheEntries.last(), member.getSocketAddress().getHostString());
partition.setConf(this.getConf());
partitions.add(partition);
}
} catch (java.lang.Exception ex) {
LOG.error("Exception occurred while partitioning the query based on Hazelcast partitions.", ex);
return null;
}
LOG.info("Query is partitioned to {} number of partitions.", partitions.size());
return partitions;
}
Aggregations