Search in sources :

Example 1 with EndInvalidationCommand

use of org.hibernate.cache.infinispan.util.EndInvalidationCommand in project hibernate-orm by hibernate.

the class NonTxPutFromLoadInterceptor method endInvalidating.

public void endInvalidating(Object key, Object lockOwner, boolean successful) {
    assert lockOwner != null;
    if (!putFromLoadValidator.endInvalidatingKey(lockOwner, key, successful)) {
        log.failedEndInvalidating(key, cacheName);
    }
    EndInvalidationCommand endInvalidationCommand = commandInitializer.buildEndInvalidationCommand(cacheName, new Object[] { key }, lockOwner);
    List<Address> members = stateTransferManager.getCacheTopology().getMembers();
    rpcManager.invokeRemotely(members, endInvalidationCommand, asyncUnordered);
}
Also used : Address(org.infinispan.remoting.transport.Address) EndInvalidationCommand(org.hibernate.cache.infinispan.util.EndInvalidationCommand)

Example 2 with EndInvalidationCommand

use of org.hibernate.cache.infinispan.util.EndInvalidationCommand 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);
    }
}
Also used : Address(org.infinispan.remoting.transport.Address) EndInvalidationCommand(org.hibernate.cache.infinispan.util.EndInvalidationCommand) GlobalTransaction(org.infinispan.transaction.xa.GlobalTransaction)

Aggregations

EndInvalidationCommand (org.hibernate.cache.infinispan.util.EndInvalidationCommand)2 Address (org.infinispan.remoting.transport.Address)2 GlobalTransaction (org.infinispan.transaction.xa.GlobalTransaction)1