Search in sources :

Example 1 with TombstoneUpdate

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

the class TombstoneAccessDelegate method putFromLoad.

@Override
public boolean putFromLoad(SharedSessionContractImplementor session, Object key, Object value, long txTimestamp, Object version, boolean minimalPutOverride) throws CacheException {
    long lastRegionInvalidation = region.getLastRegionInvalidation();
    if (txTimestamp < lastRegionInvalidation) {
        log.tracef("putFromLoad not executed since tx started at %d, before last region invalidation finished = %d", txTimestamp, lastRegionInvalidation);
        return false;
    }
    if (minimalPutOverride) {
        Object prev = cache.get(key);
        if (prev instanceof Tombstone) {
            Tombstone tombstone = (Tombstone) prev;
            long lastTimestamp = tombstone.getLastTimestamp();
            if (txTimestamp <= lastTimestamp) {
                log.tracef("putFromLoad not executed since tx started at %d, before last invalidation finished = %d", txTimestamp, lastTimestamp);
                return false;
            }
        } else if (prev != null) {
            log.tracef("putFromLoad not executed since cache contains %s", prev);
            return false;
        }
    }
    // we can't use putForExternalRead since the PFER flag means that entry is not wrapped into context
    // when it is present in the container. TombstoneCallInterceptor will deal with this.
    putFromLoadCache.put(key, new TombstoneUpdate(session.getTimestamp(), value));
    return true;
}
Also used : Tombstone(org.hibernate.cache.infinispan.util.Tombstone) TombstoneUpdate(org.hibernate.cache.infinispan.util.TombstoneUpdate)

Example 2 with TombstoneUpdate

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

the class TombstoneCallInterceptor method visitPutKeyValueCommand.

@Override
public Object visitPutKeyValueCommand(InvocationContext ctx, PutKeyValueCommand command) throws Throwable {
    MVCCEntry e = (MVCCEntry) ctx.lookupEntry(command.getKey());
    if (e == null) {
        return null;
    }
    log.tracef("In cache %s(%d) applying update %s to %s", cache.getName(), region.getLastRegionInvalidation(), command.getValue(), e.getValue());
    try {
        Object value = command.getValue();
        if (value instanceof TombstoneUpdate) {
            return handleTombstoneUpdate(e, (TombstoneUpdate) value, command);
        } else if (value instanceof Tombstone) {
            return handleTombstone(e, (Tombstone) value);
        } else if (value instanceof FutureUpdate) {
            return handleFutureUpdate(e, (FutureUpdate) value, command);
        } else {
            return super.visitPutKeyValueCommand(ctx, command);
        }
    } finally {
        log.tracef("Result is %s", e.getValue());
    }
}
Also used : TombstoneUpdate(org.hibernate.cache.infinispan.util.TombstoneUpdate) Tombstone(org.hibernate.cache.infinispan.util.Tombstone) MVCCEntry(org.infinispan.container.entries.MVCCEntry) FutureUpdate(org.hibernate.cache.infinispan.util.FutureUpdate)

Aggregations

Tombstone (org.hibernate.cache.infinispan.util.Tombstone)2 TombstoneUpdate (org.hibernate.cache.infinispan.util.TombstoneUpdate)2 FutureUpdate (org.hibernate.cache.infinispan.util.FutureUpdate)1 MVCCEntry (org.infinispan.container.entries.MVCCEntry)1