use of org.infinispan.commands.write.ComputeCommand 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;
}
use of org.infinispan.commands.write.ComputeCommand in project infinispan by infinispan.
the class MigrationTask method writeToDestinationCache.
private Object writeToDestinationCache(Entry<Object, MetadataValue<Object>> entry, Metadata metadata, DataConversion keyDataConversion, DataConversion valueDataConversion) {
Object key = keyDataConversion.toStorage(entry.getKey());
Object value = valueDataConversion.toStorage(entry.getValue().getValue());
int segment = keyPartitioner.getSegment(key);
long flags = EnumUtil.bitSetOf(Flag.SKIP_CACHE_LOAD, Flag.ROLLING_UPGRADE);
ComputeCommand computeCommand = commandsFactory.buildComputeCommand(key, new EntryWriter<>(value), false, segment, metadata, flags);
InvocationContext context = invocationHelper.createInvocationContextWithImplicitTransaction(1, true);
return invocationHelper.invoke(context, computeCommand);
}
use of org.infinispan.commands.write.ComputeCommand in project infinispan by infinispan.
the class CacheImpl method computeAsyncInternal.
CompletableFuture<V> computeAsyncInternal(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, boolean computeIfPresent, Metadata metadata, long flags, ContextBuilder contextBuilder) {
assertKeyNotNull(key);
assertFunctionNotNull(remappingFunction);
ComputeCommand command = commandsFactory.buildComputeCommand(key, remappingFunction, computeIfPresent, keyPartitioner.getSegment(key), metadata, flags);
return invocationHelper.invokeAsync(contextBuilder, command, 1);
}
use of org.infinispan.commands.write.ComputeCommand in project infinispan by infinispan.
the class CacheImpl method computeInternal.
V computeInternal(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction, boolean computeIfPresent, Metadata metadata, long flags, ContextBuilder contextBuilder) {
assertKeyNotNull(key);
assertFunctionNotNull(remappingFunction);
ComputeCommand command = commandsFactory.buildComputeCommand(key, remappingFunction, computeIfPresent, keyPartitioner.getSegment(key), metadata, flags);
return invocationHelper.invoke(contextBuilder, command, 1);
}
Aggregations