use of org.infinispan.context.impl.SingleKeyNonTxInvocationContext in project infinispan by infinispan.
the class CacheMgmtInterceptorTest method setup.
@BeforeMethod(alwaysRun = true)
public void setup() {
nextInterceptor = new ControlledNextInterceptor();
timeService = new ControlledTimeService();
ctx = new SingleKeyNonTxInvocationContext(null);
interceptor = new CacheMgmtInterceptor();
interceptor.setNextInterceptor(nextInterceptor);
TestingUtil.inject(interceptor, timeService);
interceptor.start();
interceptor.setStatisticsEnabled(true);
}
use of org.infinispan.context.impl.SingleKeyNonTxInvocationContext in project infinispan by infinispan.
the class XSiteStateConsumerImpl method applyStateInNonTransaction.
private void applyStateInNonTransaction(XSiteState[] chunk) {
SingleKeyNonTxInvocationContext ctx = (SingleKeyNonTxInvocationContext) invocationContextFactory.createSingleKeyNonTxInvocationContext();
for (XSiteState siteState : chunk) {
PutKeyValueCommand command = createPut(siteState);
ctx.setLockOwner(command.getKeyLockOwner());
interceptorChain.invoke(ctx, command);
// re-use same context. Old context is not longer needed
ctx.resetState();
if (log.isTraceEnabled()) {
log.tracef("Successfully applied key'%s'", siteState);
}
}
if (log.isDebugEnabled()) {
log.debugf("Successfully applied state. %s keys inserted", chunk.length);
}
}
use of org.infinispan.context.impl.SingleKeyNonTxInvocationContext in project infinispan by infinispan.
the class EntryWrappingInterceptor method commitContextEntries.
protected final CompletionStage<Void> commitContextEntries(InvocationContext ctx, FlagAffectedCommand command) {
final Flag stateTransferFlag = FlagBitSets.extractStateTransferFlag(ctx, command);
if (ctx instanceof SingleKeyNonTxInvocationContext) {
SingleKeyNonTxInvocationContext singleKeyCtx = (SingleKeyNonTxInvocationContext) ctx;
return commitEntryIfNeeded(ctx, command, singleKeyCtx.getKey(), singleKeyCtx.getCacheEntry(), stateTransferFlag);
} else {
AggregateCompletionStage<Void> aggregateCompletionStage = null;
Map<Object, CacheEntry> entries = ctx.getLookedUpEntries();
for (Map.Entry<Object, CacheEntry> entry : entries.entrySet()) {
CompletionStage<Void> stage = commitEntryIfNeeded(ctx, command, entry.getKey(), entry.getValue(), stateTransferFlag);
if (!CompletionStages.isCompletedSuccessfully(stage)) {
if (aggregateCompletionStage == null) {
aggregateCompletionStage = CompletionStages.aggregateCompletionStage();
}
aggregateCompletionStage.dependsOn(stage);
}
}
return aggregateCompletionStage != null ? aggregateCompletionStage.freeze() : CompletableFutures.completedNull();
}
}
Aggregations