super(key, value, version, lifespan);
this.version = version;
}
public boolean performWriteSkewCheck(DataContainer container, TxInvocationContext ctx, boolean previousRead) {
EntryVersion prevVersion;
InternalCacheEntry ice = container.get(key);
if (ice == null) {
log.tracef("No entry for key %s found in data container" , key);
prevVersion = ctx.getCacheTransaction().getLookedUpRemoteVersion(key);
if (prevVersion == null) {
log.tracef("No looked up remote version for key %s found in context" , key);
return version == null;
}
} else {
prevVersion = ice.getVersion();
if (prevVersion == null)
throw new IllegalStateException("Entries cannot have null versions!");
}
if (log.isTraceEnabled()) {
log.tracef("Is going to compare versions %s and %s for key %s. Was previously read? %s", prevVersion, version, key, previousRead);
}
// Could be that we didn't do a remote get first ... so we haven't effectively read this entry yet.
if (version == null) return !previousRead;
log.tracef("Comparing versions %s and %s for key %s: %s", prevVersion, version, key, prevVersion.compareTo(version));
return InequalVersionComparisonResult.AFTER != prevVersion.compareTo(version);
}