use of org.infinispan.client.hotrod.impl.RemoteCacheImpl in project keycloak by keycloak.
the class JDGPutTest method getIspnSegmentsCount.
protected static int getIspnSegmentsCount(RemoteCache remoteCache) {
OperationsFactory operationsFactory = ((RemoteCacheImpl) remoteCache).getOperationsFactory();
Map<SocketAddress, Set<Integer>> segmentsByAddress = operationsFactory.getPrimarySegmentsByAddress();
for (Map.Entry<SocketAddress, Set<Integer>> entry : segmentsByAddress.entrySet()) {
SocketAddress targetAddress = entry.getKey();
// Same like RemoteCloseableIterator.startInternal
IterationStartOperation iterationStartOperation = operationsFactory.newIterationStartOperation(null, null, null, 64, false, null, targetAddress);
IterationStartResponse startResponse = await(iterationStartOperation.execute());
try {
// Could happen for non-clustered caches
if (startResponse.getSegmentConsistentHash() == null) {
return -1;
} else {
return startResponse.getSegmentConsistentHash().getNumSegments();
}
} finally {
startResponse.getChannel().close();
}
}
// Handle the case when primary segments owned by the address are not known
return -1;
}
use of org.infinispan.client.hotrod.impl.RemoteCacheImpl in project keycloak by keycloak.
the class RemoteCacheSessionsLoader method getIspnSegmentsCount.
protected int getIspnSegmentsCount(RemoteCache remoteCache) {
OperationsFactory operationsFactory = ((RemoteCacheImpl) remoteCache).getOperationsFactory();
Map<SocketAddress, Set<Integer>> segmentsByAddress = operationsFactory.getPrimarySegmentsByAddress();
for (Map.Entry<SocketAddress, Set<Integer>> entry : segmentsByAddress.entrySet()) {
SocketAddress targetAddress = entry.getKey();
// Same like RemoteCloseableIterator.startInternal
IterationStartOperation iterationStartOperation = operationsFactory.newIterationStartOperation(null, null, null, sessionsPerSegment, false, null, targetAddress);
IterationStartResponse startResponse = await(iterationStartOperation.execute());
try {
// Could happen for non-clustered caches
if (startResponse.getSegmentConsistentHash() == null) {
return -1;
} else {
return startResponse.getSegmentConsistentHash().getNumSegments();
}
} finally {
startResponse.getChannel().close();
}
}
// Handle the case when primary segments owned by the address are not known
return -1;
}
Aggregations