use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.
the class ScatteredStateConsumerImpl method backupEntries.
private void backupEntries(List<InternalCacheEntry<?, ?>> entries) {
long incrementedCounter = chunkCounter.incrementAndGet();
if (log.isTraceEnabled())
log.tracef("Backing up entries, chunk counter is %d", incrementedCounter);
Map<Object, InternalCacheValue<?>> map = new HashMap<>();
for (InternalCacheEntry<?, ?> entry : entries) {
map.put(entry.getKey(), entry.toInternalCacheValue());
}
PutMapCommand putMapCommand = commandsFactory.buildPutMapCommand(map, null, STATE_TRANSFER_FLAGS);
putMapCommand.setTopologyId(rpcManager.getTopologyId());
rpcManager.invokeCommand(backupAddress, putMapCommand, SingleResponseCollector.validOnly(), rpcManager.getSyncRpcOptions()).whenComplete(((response, throwable) -> {
try {
if (throwable != null) {
log.failedOutBoundTransferExecution(throwable);
}
} finally {
long decrementedCounter = chunkCounter.decrementAndGet();
if (log.isTraceEnabled())
log.tracef("Backed up entries, chunk counter is %d", decrementedCounter);
if (decrementedCounter == 0) {
notifyEndOfStateTransferIfNeeded();
}
}
}));
}
use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.
the class CacheMgmtInterceptorTest method testVisitPutMapCommand.
public void testVisitPutMapCommand() throws Throwable {
PutMapCommand command = new PutMapCommand(Collections.singletonMap(KEY, VALUE), null, 0, null);
InvocationStage stage = makeStage(interceptor.visitPutMapCommand(ctx, command));
assertFalse(stage.isDone());
timeService.advance(1);
nextInterceptor.completeLastInvocation(null);
assertNull(stage.get());
assertEquals(1, interceptor.getAverageWriteTime());
}
use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.
the class PutMapBackupWriteCommand method createWriteCommand.
@Override
WriteCommand createWriteCommand() {
PutMapCommand cmd = new PutMapCommand(map, metadata, getFlags(), getCommandInvocationId());
cmd.setForwarded(true);
internalMetadataMap.forEach(cmd::setInternalMetadata);
return cmd;
}
use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.
the class TriangleFunctionsUtil method copy.
public static PutMapCommand copy(PutMapCommand command, Collection<Object> keys) {
PutMapCommand copy = new PutMapCommand(command);
copy.setMap(filterEntries(command.getMap(), keys));
return copy;
}
use of org.infinispan.commands.write.PutMapCommand in project infinispan by infinispan.
the class PutMapHelper method copyForBackup.
@Override
public PutMapCommand copyForBackup(PutMapCommand cmd, LocalizedCacheTopology topology, Address target, IntSet segments) {
PutMapCommand copy = new PutMapCommand(cmd).withMap(new ReadOnlySegmentAwareMap(cmd.getMap(), topology, segments));
copy.setForwarded(true);
return copy;
}
Aggregations