use of org.infinispan.commands.VisitableCommand.LoadType.DONT_LOAD in project infinispan by infinispan.
the class ScatteredDistributionInterceptor method handleWriteManyOnPrimary.
private Object handleWriteManyOnPrimary(InvocationContext ctx, WriteCommand cmd, Object rv) {
int numKeys = cmd.getAffectedKeys().size();
InternalCacheValue[] values = new InternalCacheValue[numKeys];
// keys are always iterated in order
int i = 0;
AggregateCompletionStage<Void> aggregateCompletionStage = CompletionStages.aggregateCompletionStage();
for (Object key : cmd.getAffectedKeys()) {
RepeatableReadEntry entry = (RepeatableReadEntry) ctx.lookupEntry(key);
EntryVersion nextVersion = svm.incrementVersion(keyPartitioner.getSegment(key));
entry.setMetadata(addVersion(entry.getMetadata(), nextVersion));
if (cmd.loadType() == DONT_LOAD) {
aggregateCompletionStage.dependsOn(commitSingleEntryIfNewer(entry, ctx, cmd));
} else {
aggregateCompletionStage.dependsOn(commitSingleEntryIfNoChange(entry, ctx, cmd));
}
values[i++] = new MetadataImmortalCacheValue(entry.getValue(), entry.getMetadata());
}
CompletionStage<Void> aggregatedStage = aggregateCompletionStage.freeze();
Object returnValue;
if (cmd.loadType() == DONT_LOAD) {
// Disable ignoring return value in response
cmd.setFlagsBitSet(cmd.getFlagsBitSet() & ~FlagBitSets.IGNORE_RETURN_VALUES);
returnValue = values;
} else {
returnValue = new Object[] { values, ((List) rv).toArray() };
}
return asyncValue(aggregatedStage).thenApply(ctx, cmd, ((rCtx, rCommand, rv1) -> manyWriteResponse(rCtx, cmd, returnValue)));
}
Aggregations