Search in sources :

Example 1 with OperationsFactory

use of org.infinispan.client.hotrod.impl.operations.OperationsFactory 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;
}
Also used : IterationStartResponse(org.infinispan.client.hotrod.impl.operations.IterationStartResponse) OperationsFactory(org.infinispan.client.hotrod.impl.operations.OperationsFactory) Set(java.util.Set) HashSet(java.util.HashSet) IterationStartOperation(org.infinispan.client.hotrod.impl.operations.IterationStartOperation) SocketAddress(java.net.SocketAddress) RemoteCacheImpl(org.infinispan.client.hotrod.impl.RemoteCacheImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 2 with OperationsFactory

use of org.infinispan.client.hotrod.impl.operations.OperationsFactory 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;
}
Also used : IterationStartResponse(org.infinispan.client.hotrod.impl.operations.IterationStartResponse) OperationsFactory(org.infinispan.client.hotrod.impl.operations.OperationsFactory) Set(java.util.Set) HashSet(java.util.HashSet) IterationStartOperation(org.infinispan.client.hotrod.impl.operations.IterationStartOperation) SocketAddress(java.net.SocketAddress) RemoteCacheImpl(org.infinispan.client.hotrod.impl.RemoteCacheImpl) HashMap(java.util.HashMap) Map(java.util.Map)

Example 3 with OperationsFactory

use of org.infinispan.client.hotrod.impl.operations.OperationsFactory in project wildfly by wildfly.

the class HotRodStore method setRemoteCache.

synchronized void setRemoteCache(RemoteCacheContainer container, String cacheName) {
    this.cache = container.getCache(cacheName);
    if (this.cache == null) {
        // Administration support was introduced in protocol version 2.7
        throw InfinispanLogger.ROOT_LOGGER.remoteCacheMustBeDefined(container.getConfiguration().version().toString(), cacheName);
    }
    RemoteCacheManager manager = this.cache.getRemoteCacheManager();
    this.operationsFactory = new OperationsFactory(manager.getChannelFactory(), manager.getCodec(), null, manager.getConfiguration());
    this.cache.start();
}
Also used : RemoteCacheManager(org.infinispan.client.hotrod.RemoteCacheManager) OperationsFactory(org.infinispan.client.hotrod.impl.operations.OperationsFactory)

Aggregations

OperationsFactory (org.infinispan.client.hotrod.impl.operations.OperationsFactory)3 SocketAddress (java.net.SocketAddress)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 RemoteCacheImpl (org.infinispan.client.hotrod.impl.RemoteCacheImpl)2 IterationStartOperation (org.infinispan.client.hotrod.impl.operations.IterationStartOperation)2 IterationStartResponse (org.infinispan.client.hotrod.impl.operations.IterationStartResponse)2 RemoteCacheManager (org.infinispan.client.hotrod.RemoteCacheManager)1