Search in sources :

Example 1 with ProtocolVersion

use of org.infinispan.client.hotrod.ProtocolVersion in project keycloak by keycloak.

the class DefaultInfinispanConnectionProviderFactory method getHotrodVersion.

private ProtocolVersion getHotrodVersion() {
    String hotrodVersionStr = config.get("hotrodProtocolVersion", ProtocolVersion.DEFAULT_PROTOCOL_VERSION.toString());
    ProtocolVersion hotrodVersion = ProtocolVersion.parseVersion(hotrodVersionStr);
    if (hotrodVersion == null) {
        hotrodVersion = ProtocolVersion.DEFAULT_PROTOCOL_VERSION;
    }
    logger.debugf("HotRod protocol version: %s", hotrodVersion);
    return hotrodVersion;
}
Also used : ProtocolVersion(org.infinispan.client.hotrod.ProtocolVersion)

Example 2 with ProtocolVersion

use of org.infinispan.client.hotrod.ProtocolVersion 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;
}
Also used : RemoteCache(org.infinispan.client.hotrod.RemoteCache) ProtocolVersion(org.infinispan.client.hotrod.ProtocolVersion)

Aggregations

ProtocolVersion (org.infinispan.client.hotrod.ProtocolVersion)2 RemoteCache (org.infinispan.client.hotrod.RemoteCache)1