use of org.infinispan.transaction.xa.GlobalTransaction in project hibernate-orm by hibernate.
the class TxPutFromLoadInterceptor method endInvalidationAndInvokeNextInterceptor.
protected Object endInvalidationAndInvokeNextInterceptor(TxInvocationContext<?> ctx, VisitableCommand command) throws Throwable {
try {
if (ctx.isOriginLocal()) {
// During evictAll inside transaction this would cause unnecessary invalidate command
if (!ctx.getModifications().isEmpty()) {
Object[] keys = ctx.getModifications().stream().flatMap(mod -> mod.getAffectedKeys().stream()).distinct().toArray();
if (log.isTraceEnabled()) {
log.tracef("Sending end invalidation for keys %s asynchronously, modifications are %s", Arrays.toString(keys), ctx.getCacheTransaction().getModifications());
}
GlobalTransaction globalTransaction = ctx.getGlobalTransaction();
EndInvalidationCommand commitCommand = cacheCommandInitializer.buildEndInvalidationCommand(cacheName, keys, globalTransaction);
List<Address> members = stateTransferManager.getCacheTopology().getMembers();
rpcManager.invokeRemotely(members, commitCommand, asyncUnordered);
// we have to end invalidation from here manually (in successful case as well)
for (Object key : keys) {
putFromLoadValidator.endInvalidatingKey(globalTransaction, key);
}
}
}
} finally {
return invokeNextInterceptor(ctx, command);
}
}
use of org.infinispan.transaction.xa.GlobalTransaction in project hibernate-orm by hibernate.
the class TxPutFromLoadInterceptor method beginInvalidating.
private void beginInvalidating(InvocationContext ctx, Object key) {
TxInvocationContext txCtx = (TxInvocationContext) ctx;
// make sure that the command is registered in the transaction
txCtx.addAffectedKey(key);
GlobalTransaction globalTransaction = txCtx.getGlobalTransaction();
if (!putFromLoadValidator.beginInvalidatingKey(globalTransaction, key)) {
log.failedInvalidatePendingPut(key, cacheName);
}
}
Aggregations