private static boolean isInDoubt(SoftLock<?> softLock) { return softLock.getTransactionId() != null; }
@Override public Duration getExpiryForAccess(K key, Supplier<? extends SoftLock<V>> softLock) { if (softLock.get().getTransactionId() != null) { // phase 1 prepare, access -> forever return ExpiryPolicy.INFINITE; } else { // phase 2 commit, or during a TX's lifetime, access -> some time Duration duration; try { duration = configuredExpiry.getExpiryForAccess(key, () -> softLock.get().getOldValue()); } catch (RuntimeException re) { LOGGER.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); return Duration.ZERO; } return duration; } }
@Override public Duration getExpiryForCreation(K key, SoftLock<V> softLock) { if (softLock.getTransactionId() != null) { // phase 1 prepare, create -> forever return ExpiryPolicy.INFINITE; } else { // phase 2 commit, or during a TX's lifetime, create -> some time Duration duration; try { duration = configuredExpiry.getExpiryForCreation(key, softLock.getOldValue()); } catch (RuntimeException re) { LOGGER.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); return Duration.ZERO; } return duration; } }
if (preparedSoftLock.getTransactionId() != null && !preparedSoftLock.getTransactionId().equals(transactionId)) { LOGGER.debug("rollback skipping prepared softlock with non-matching TX ID (concurrent modification?)"); evictFromUnderlyingStore(key);
@Override public Duration getExpiryForUpdate(K key, Supplier<? extends SoftLock<V>> oldSoftLockSupplier, SoftLock<V> newSoftLock) { SoftLock<V> oldSoftLock = oldSoftLockSupplier.get(); if (oldSoftLock.getTransactionId() == null) {
if (preparedSoftLock.getTransactionId() != null && !preparedSoftLock.getTransactionId().equals(transactionId)) { LOGGER.debug("commit skipping prepared softlock with non-matching TX ID (concurrent modification?)"); evictFromUnderlyingStore(key);
@Override public SoftLock<T> copyForRead(SoftLock<T> obj) { T oldValue = valueCopier.copyForRead(obj.getOldValue()); XAValueHolder<T> valueHolder = obj.getNewValueHolder(); XAValueHolder<T> newValueHolder = valueHolder == null ? null : new XAValueHolder<>(valueHolder, valueCopier.copyForRead(valueHolder .get())); return new SoftLock<>(obj.getTransactionId(), oldValue, newValueHolder); }
@Override public SoftLock<T> copyForWrite(SoftLock<T> obj) { T oldValue = valueCopier.copyForWrite(obj.getOldValue()); XAValueHolder<T> valueHolder = obj.getNewValueHolder(); XAValueHolder<T> newValueHolder = valueHolder == null ? null : new XAValueHolder<>(valueHolder, valueCopier.copyForWrite(valueHolder .get())); return new SoftLock<>(obj.getTransactionId(), oldValue, newValueHolder); }
@Override public boolean containsKey(K key) throws StoreAccessException { checkKey(key); if (getCurrentContext().touched(key)) { return getCurrentContext().newValueHolderOf(key) != null; } ValueHolder<SoftLock<V>> softLockValueHolder = getSoftLockValueHolderFromUnderlyingStore(key); return softLockValueHolder != null && softLockValueHolder.get().getTransactionId() == null && softLockValueHolder.get().getOldValue() != null; }
private static boolean isInDoubt(SoftLock<?> softLock) { return softLock.getTransactionId() != null; }
@Override public Duration getExpiryForAccess(K key, Supplier<? extends SoftLock<V>> softLock) { if (softLock.get().getTransactionId() != null) { // phase 1 prepare, access -> forever return ExpiryPolicy.INFINITE; } else { // phase 2 commit, or during a TX's lifetime, access -> some time Duration duration; try { duration = configuredExpiry.getExpiryForAccess(key, () -> softLock.get().getOldValue()); } catch (RuntimeException re) { LOGGER.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); return Duration.ZERO; } return duration; } }
@Override public Duration getExpiryForCreation(K key, SoftLock<V> softLock) { if (softLock.getTransactionId() != null) { // phase 1 prepare, create -> forever return ExpiryPolicy.INFINITE; } else { // phase 2 commit, or during a TX's lifetime, create -> some time Duration duration; try { duration = configuredExpiry.getExpiryForCreation(key, softLock.getOldValue()); } catch (RuntimeException re) { LOGGER.error("Expiry computation caused an exception - Expiry duration will be 0 ", re); return Duration.ZERO; } return duration; } }
if (preparedSoftLock.getTransactionId() != null && !preparedSoftLock.getTransactionId().equals(transactionId)) { LOGGER.debug("rollback skipping prepared softlock with non-matching TX ID (concurrent modification?)"); evictFromUnderlyingStore(key);
@Override public Duration getExpiryForUpdate(K key, Supplier<? extends SoftLock<V>> oldSoftLockSupplier, SoftLock<V> newSoftLock) { SoftLock<V> oldSoftLock = oldSoftLockSupplier.get(); if (oldSoftLock.getTransactionId() == null) {
if (preparedSoftLock.getTransactionId() != null && !preparedSoftLock.getTransactionId().equals(transactionId)) { LOGGER.debug("commit skipping prepared softlock with non-matching TX ID (concurrent modification?)"); evictFromUnderlyingStore(key);
@Override public SoftLock<T> copyForRead(SoftLock<T> obj) { T oldValue = valueCopier.copyForRead(obj.getOldValue()); XAValueHolder<T> valueHolder = obj.getNewValueHolder(); XAValueHolder<T> newValueHolder = valueHolder == null ? null : new XAValueHolder<>(valueHolder, valueCopier.copyForRead(valueHolder .get())); return new SoftLock<>(obj.getTransactionId(), oldValue, newValueHolder); }
@Override public SoftLock<T> copyForWrite(SoftLock<T> obj) { T oldValue = valueCopier.copyForWrite(obj.getOldValue()); XAValueHolder<T> valueHolder = obj.getNewValueHolder(); XAValueHolder<T> newValueHolder = valueHolder == null ? null : new XAValueHolder<>(valueHolder, valueCopier.copyForWrite(valueHolder .get())); return new SoftLock<>(obj.getTransactionId(), oldValue, newValueHolder); }
@Override public boolean containsKey(K key) throws StoreAccessException { checkKey(key); if (getCurrentContext().touched(key)) { return getCurrentContext().newValueHolderOf(key) != null; } ValueHolder<SoftLock<V>> softLockValueHolder = getSoftLockValueHolderFromUnderlyingStore(key); return softLockValueHolder != null && softLockValueHolder.get().getTransactionId() == null && softLockValueHolder.get().getOldValue() != null; }