use of org.infinispan.client.hotrod.RemoteCache in project keycloak by keycloak.
the class InfinispanUtil method toHotrodTimeMs.
/**
* Convert the given value to the proper value, which can be used when calling operations for the infinispan remoteCache.
*
* Infinispan HotRod protocol of versions older than 3.0 uses the "lifespan" or "maxIdle" as the normal expiration time when the value is 30 days or less.
* However for the bigger values, it assumes that the value is unix timestamp.
*
* @param ispnCache
* @param lifespanOrigMs
* @return
*/
public static long toHotrodTimeMs(BasicCache ispnCache, long lifespanOrigMs) {
if (ispnCache instanceof RemoteCache && lifespanOrigMs > 2592000000L) {
RemoteCache remoteCache = (RemoteCache) ispnCache;
ProtocolVersion protocolVersion = remoteCache.getRemoteCacheManager().getConfiguration().version();
if (ProtocolVersion.PROTOCOL_VERSION_30.compareTo(protocolVersion) > 0) {
return Time.currentTimeMillis() + lifespanOrigMs;
}
}
return lifespanOrigMs;
}
use of org.infinispan.client.hotrod.RemoteCache in project keycloak by keycloak.
the class DistributedCacheConcurrentWritesTest method printStats.
private static void printStats(BasicCache cache) {
if (cache instanceof Cache) {
Cache cache1 = (Cache) cache;
JChannel channel = ((JGroupsTransport) cache1.getAdvancedCache().getRpcManager().getTransport()).getChannel();
System.out.println("Sent MB: " + channel.getSentBytes() / 1000000 + ", sent messages: " + channel.getSentMessages() + ", received MB: " + channel.getReceivedBytes() / 1000000 + ", received messages: " + channel.getReceivedMessages());
} else {
Map<String, String> stats = ((RemoteCache) cache).stats().getStatsMap();
System.out.println("Stats: " + stats);
}
}
use of org.infinispan.client.hotrod.RemoteCache in project indy by Commonjava.
the class MetadataCacheProducer method registerTransformer.
private void registerTransformer(BasicCacheHandle handler) {
// for embedded mode
if (handler instanceof CacheHandle) {
((CacheHandle<MetadataKey, MetadataKey>) handler).executeCache(cache -> {
SearchManagerImplementor searchManager = (SearchManagerImplementor) Search.getSearchManager(cache);
searchManager.registerKeyTransformer(MetadataKey.class, MetadataKeyTransformer.class);
return null;
});
}
if (handler.getCache() instanceof RemoteCache) {
((RemoteCache) handler.getCache()).addClientListener(cacheListener);
} else {
((Cache) handler.getCache()).addListener(cacheListener);
}
}
use of org.infinispan.client.hotrod.RemoteCache in project wildfly by wildfly.
the class RemoteCacheServiceConfigurator method build.
@Override
public final ServiceBuilder<?> build(ServiceTarget target) {
ServiceBuilder<?> builder = new AsyncServiceConfigurator(this.getServiceName()).build(target);
Consumer<RemoteCache<K, V>> cache = this.container.register(builder).provides(this.getServiceName());
Service service = new FunctionalService<>(cache, Function.identity(), this, this);
return builder.setInstance(service).setInitialMode(ServiceController.Mode.ON_DEMAND);
}
use of org.infinispan.client.hotrod.RemoteCache in project wildfly by wildfly.
the class CoarseSessionsFactory method findEntryContaining.
@Override
public Map.Entry<String, Map<D, S>> findEntryContaining(S session) {
SessionFilter<CoarseSessionsKey, D, S> filter = new SessionFilter<>(session);
// Erase type to handle compilation issues with generics
// Our filter will handle type safety and casting
@SuppressWarnings("rawtypes") RemoteCache cache = this.cache;
try (Stream<Map.Entry<?, ?>> stream = cache.entrySet().stream()) {
Map.Entry<CoarseSessionsKey, Map<D, S>> entry = stream.filter(this.filter).map(this.filter).filter(filter).findAny().orElse(null);
return (entry != null) ? new AbstractMap.SimpleImmutableEntry<>(entry.getKey().getId(), entry.getValue()) : null;
}
}
Aggregations