Search in sources :

Example 1 with RevokeBiasCommand

use of org.infinispan.commands.remote.RevokeBiasCommand in project infinispan by infinispan.

the class BiasManagerImpl method removeOldBiasses.

private void removeOldBiasses() {
    log.trace("Purging old biasses");
    long minTimestamp = timeService.wallClockTime() - configuration.clustering().biasLifespan();
    remoteBias.forEach((key, bias) -> {
        if (bias.acquiredTimestamp < minTimestamp && bias.revoking == null) {
            RemoteBias bias3 = remoteBias.computeIfPresent(key, (k, bias2) -> {
                bias2.revoking = bias2.biased;
                bias2.future = new CompletableFuture<>();
                return bias2;
            });
            if (bias3 == null)
                return;
            if (log.isTraceEnabled()) {
                log.tracef("Revoking old bias for key %s from %s", key, bias3.biased);
            }
            // TODO: maybe some batching here; on the other side we don't want to block writes for too long
            RevokeBiasCommand revokeBiasCommand = commandsFactory.buildRevokeBiasCommand(null, 0, 0, Collections.singleton(key));
            rpcManager.invokeCommand(bias3.biased, revokeBiasCommand, MapResponseCollector.ignoreLeavers(), rpcManager.getSyncRpcOptions()).whenComplete((nil, throwable) -> {
                CompletableFuture<?> future = bias3.future;
                if (throwable != null) {
                    if (log.isTraceEnabled()) {
                        log.tracef(throwable, "Bias revocation for %s failed", key);
                    }
                    remoteBias.compute(key, (k, bias4) -> {
                        assert bias4 != null;
                        bias4.revoking = null;
                        bias4.future = null;
                        return bias4;
                    });
                } else {
                    remoteBias.remove(key);
                    if (log.isTraceEnabled()) {
                        log.tracef("Bias for %s has been revoked", key);
                    }
                }
                future.complete(null);
            });
        }
    });
    log.trace("Purge completed");
}
Also used : RevokeBiasCommand(org.infinispan.commands.remote.RevokeBiasCommand)

Example 2 with RevokeBiasCommand

use of org.infinispan.commands.remote.RevokeBiasCommand in project infinispan by infinispan.

the class BiasedScatteredDistributionInterceptor method sendRevokeBias.

private CompletionStage<Map<Address, Response>> sendRevokeBias(Collection<Address> targets, Collection<Object> keys, int topologyId, CommandInvocationId commandInvocationId) {
    try {
        Address ackTarget = null;
        long id = 0;
        if (commandInvocationId != null) {
            ackTarget = commandInvocationId.getAddress();
            id = commandInvocationId.getId();
        }
        RevokeBiasCommand revokeBiasCommand = cf.buildRevokeBiasCommand(ackTarget, id, topologyId, keys);
        return rpcManager.invokeCommand(targets, revokeBiasCommand, MapResponseCollector.ignoreLeavers(targets.size()), rpcManager.getSyncRpcOptions());
    } catch (Throwable t) {
        return CompletableFutures.completedExceptionFuture(t);
    }
}
Also used : Address(org.infinispan.remoting.transport.Address) RevokeBiasCommand(org.infinispan.commands.remote.RevokeBiasCommand)

Aggregations

RevokeBiasCommand (org.infinispan.commands.remote.RevokeBiasCommand)2 Address (org.infinispan.remoting.transport.Address)1