Search in sources :

Example 1 with IracPutKeyValueCommand

use of org.infinispan.commands.write.IracPutKeyValueCommand in project infinispan by infinispan.

the class SingleKeyBackupWriteCommand method createWriteCommand.

@Override
WriteCommand createWriteCommand() {
    DataWriteCommand command;
    switch(operation) {
        case REMOVE:
            command = new RemoveCommand(key, null, segmentId, getFlags(), getCommandInvocationId());
            break;
        case WRITE:
            command = EnumUtil.containsAny(getFlags(), FlagBitSets.IRAC_UPDATE) ? new IracPutKeyValueCommand(key, segmentId, getCommandInvocationId(), valueOrFunction, metadata, internalMetadata) : new PutKeyValueCommand(key, valueOrFunction, false, metadata, segmentId, getFlags(), getCommandInvocationId());
            break;
        case COMPUTE:
            command = new ComputeCommand(key, (BiFunction) valueOrFunction, false, segmentId, getFlags(), getCommandInvocationId(), metadata);
            break;
        case REPLACE:
            command = new ReplaceCommand(key, null, valueOrFunction, metadata, segmentId, getFlags(), getCommandInvocationId());
            break;
        case REMOVE_EXPIRED:
            // Doesn't matter if it is max idle or not - important thing is that it raises expired event
            command = new RemoveExpiredCommand(key, valueOrFunction, null, false, segmentId, getFlags(), getCommandInvocationId());
            break;
        case COMPUTE_IF_PRESENT:
            command = new ComputeCommand(key, (BiFunction) valueOrFunction, true, segmentId, getFlags(), getCommandInvocationId(), metadata);
            break;
        case COMPUTE_IF_ABSENT:
            command = new ComputeIfAbsentCommand(key, (Function) valueOrFunction, segmentId, getFlags(), getCommandInvocationId(), metadata);
            break;
        default:
            throw new IllegalStateException("Unknown operation " + operation);
    }
    command.setInternalMetadata(internalMetadata);
    return command;
}
Also used : RemoveCommand(org.infinispan.commands.write.RemoveCommand) ComputeCommand(org.infinispan.commands.write.ComputeCommand) BiFunction(java.util.function.BiFunction) Function(java.util.function.Function) DataWriteCommand(org.infinispan.commands.write.DataWriteCommand) BiFunction(java.util.function.BiFunction) ReplaceCommand(org.infinispan.commands.write.ReplaceCommand) RemoveExpiredCommand(org.infinispan.commands.write.RemoveExpiredCommand) ComputeIfAbsentCommand(org.infinispan.commands.write.ComputeIfAbsentCommand) IracPutKeyValueCommand(org.infinispan.commands.write.IracPutKeyValueCommand) IracPutKeyValueCommand(org.infinispan.commands.write.IracPutKeyValueCommand) PutKeyValueCommand(org.infinispan.commands.write.PutKeyValueCommand)

Example 2 with IracPutKeyValueCommand

use of org.infinispan.commands.write.IracPutKeyValueCommand in project infinispan by infinispan.

the class XSiteMBeanTest method afterSitesCreated.

@Override
protected void afterSitesCreated() {
    for (int i = 0; i < N_SITES; ++i) {
        for (Cache<?, ?> cache : caches(siteName(i))) {
            rpcManagerList.add(wrapRpcManager(cache));
            iracManagerList.add(ManualIracManager.wrapCache(cache));
            BlockingInterceptor<IracPutKeyValueCommand> interceptor = new BlockingInterceptor<>(new CyclicBarrier(2), IracPutKeyValueCommand.class, false, false);
            interceptor.suspend(true);
            blockingInterceptorList.add(interceptor);
            // noinspection deprecation
            cache.getAdvancedCache().getAsyncInterceptorChain().addInterceptor(interceptor, 0);
        }
    }
}
Also used : BlockingInterceptor(org.infinispan.distribution.BlockingInterceptor) IracPutKeyValueCommand(org.infinispan.commands.write.IracPutKeyValueCommand) CyclicBarrier(java.util.concurrent.CyclicBarrier)

Example 3 with IracPutKeyValueCommand

use of org.infinispan.commands.write.IracPutKeyValueCommand in project infinispan by infinispan.

the class ClusteredCacheBackupReceiver method putKeyValue.

@Override
public CompletionStage<Void> putKeyValue(Object key, Object value, Metadata metadata, IracMetadata iracMetadata) {
    IracPutKeyValueCommand cmd = commandsFactory.buildIracPutKeyValueCommand(key, segment(key), value, metadata, internalMetadata(iracMetadata));
    InvocationContext ctx = invocationContextFactory.createSingleKeyNonTxInvocationContext();
    return invocationHelper.invokeAsync(ctx, cmd).handle(CHECK_EXCEPTION);
}
Also used : InvocationContext(org.infinispan.context.InvocationContext) TxInvocationContext(org.infinispan.context.impl.TxInvocationContext) IracPutKeyValueCommand(org.infinispan.commands.write.IracPutKeyValueCommand)

Example 4 with IracPutKeyValueCommand

use of org.infinispan.commands.write.IracPutKeyValueCommand in project infinispan by infinispan.

the class ClusteredCacheBackupReceiver method removeKey.

@Override
public CompletionStage<Void> removeKey(Object key, IracMetadata iracMetadata, boolean expiration) {
    IracPutKeyValueCommand cmd = commandsFactory.buildIracPutKeyValueCommand(key, segment(key), null, null, internalMetadata(iracMetadata));
    cmd.setExpiration(expiration);
    InvocationContext ctx = invocationContextFactory.createSingleKeyNonTxInvocationContext();
    return invocationHelper.invokeAsync(ctx, cmd).handle(CHECK_EXCEPTION);
}
Also used : InvocationContext(org.infinispan.context.InvocationContext) TxInvocationContext(org.infinispan.context.impl.TxInvocationContext) IracPutKeyValueCommand(org.infinispan.commands.write.IracPutKeyValueCommand)

Aggregations

IracPutKeyValueCommand (org.infinispan.commands.write.IracPutKeyValueCommand)4 InvocationContext (org.infinispan.context.InvocationContext)2 TxInvocationContext (org.infinispan.context.impl.TxInvocationContext)2 CyclicBarrier (java.util.concurrent.CyclicBarrier)1 BiFunction (java.util.function.BiFunction)1 Function (java.util.function.Function)1 ComputeCommand (org.infinispan.commands.write.ComputeCommand)1 ComputeIfAbsentCommand (org.infinispan.commands.write.ComputeIfAbsentCommand)1 DataWriteCommand (org.infinispan.commands.write.DataWriteCommand)1 PutKeyValueCommand (org.infinispan.commands.write.PutKeyValueCommand)1 RemoveCommand (org.infinispan.commands.write.RemoveCommand)1 RemoveExpiredCommand (org.infinispan.commands.write.RemoveExpiredCommand)1 ReplaceCommand (org.infinispan.commands.write.ReplaceCommand)1 BlockingInterceptor (org.infinispan.distribution.BlockingInterceptor)1