@Override public SoftLock tryLock(final Object key, final Object version) { ExpiryMarker marker; String markerId = nextMarkerId(); while (true) { final Expirable original = cache.get(key); long timeout = nextTimestamp() + CacheEnvironment.getDefaultCacheTimeoutInMillis(); if (original == null) { marker = new ExpiryMarker(version, timeout, markerId); if (cache.putIfAbsent(key, marker) == null) { break; } } else { marker = original.markForExpiration(timeout, markerId); if (cache.replace(key, original, marker)) { break; } } } return new MarkerWrapper(marker); }
public boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); return (Boolean) map.executeOnKey(key, new UpdateEntryProcessor(unwrappedMarker, newValue, newVersion, nextMarkerId(), nextTimestamp(hazelcastInstance))); } else { return false; } }
@Override public void unlock(final Object key, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); map.executeOnKey(key, new UnlockEntryProcessor(unwrappedMarker, nextMarkerId(), nextTimestamp(hazelcastInstance))); } }
@Override public SoftLock tryLock(final Object key, final Object version) { ExpiryMarker marker; String markerId = nextMarkerId(); while (true) { final Expirable original = cache.get(key); long timeout = nextTimestamp() + CacheEnvironment.getDefaultCacheTimeoutInMillis(); if (original == null) { marker = new ExpiryMarker(version, timeout, markerId); if (cache.putIfAbsent(key, marker) == null) { break; } } else { marker = original.markForExpiration(timeout, markerId); if (cache.replace(key, original, marker)) { break; } } } return new MarkerWrapper(marker); }
@Override public boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); return (Boolean) map.executeOnKey(key, new UpdateEntryProcessor(unwrappedMarker, newValue, newVersion, nextMarkerId(), nextTimestamp(hazelcastInstance))); } else { return false; } }
public SoftLock tryLock(final Object key, final Object version) { ExpiryMarker marker; String markerId = nextMarkerId(); while (true) { final Expirable original = cache.get(key); long timeout = nextTimestamp() + CacheEnvironment.getDefaultCacheTimeoutInMillis(); if (original == null) { marker = new ExpiryMarker(version, timeout, markerId); if (cache.putIfAbsent(key, marker) == null) { break; } } else { marker = original.markForExpiration(timeout, markerId); if (cache.replace(key, original, marker)) { break; } } } return new MarkerWrapper(marker); }
@Override public void unlock(final Object key, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); map.executeOnKey(key, new UnlockEntryProcessor(unwrappedMarker, nextMarkerId(), nextTimestamp(hazelcastInstance))); } }
@Override public SoftLock tryLock(final Object key, final Object version) { ExpiryMarker marker; String markerId = nextMarkerId(); while (true) { final Expirable original = cache.get(key); long timeout = nextTimestamp() + CacheEnvironment.getDefaultCacheTimeoutInMillis(); if (original == null) { marker = new ExpiryMarker(version, timeout, markerId); if (cache.putIfAbsent(key, marker) == null) { break; } } else { marker = original.markForExpiration(timeout, markerId); if (cache.replace(key, original, marker)) { break; } } } return new MarkerWrapper(marker); }
@Override public void unlock(final Object key, final SoftLock lock) { while (true) { final Expirable original = cache.get(key); if (original != null) { if (!(lock instanceof MarkerWrapper)) { break; } final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); if (original.matches(unwrappedMarker)) { final Expirable revised = ((ExpiryMarker) original).expire(nextTimestamp()); if (cache.replace(key, original, revised)) { break; } } else if (original.getValue() != null) { if (cache.remove(key, original)) { break; } } else { break; } } else { break; } } maybeNotifyTopic(key, null, null); }
@Override public SoftLock tryLock(final Object key, final Object version) { long timeout = nextTimestamp(hazelcastInstance) + lockTimeout; final ExpiryMarker marker = (ExpiryMarker) map.executeOnKey(key, new LockEntryProcessor(nextMarkerId(), timeout, version)); return new MarkerWrapper(marker); }
public void unlock(final Object key, SoftLock lock) { while (true) { final Expirable original = cache.get(key); if (original != null) { if (!(lock instanceof MarkerWrapper)) { break; } final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); if (original.matches(unwrappedMarker)) { final Expirable revised = ((ExpiryMarker) original).expire(nextTimestamp()); if (cache.replace(key, original, revised)) { break; } } else if (original.getValue() != null) { if (cache.remove(key, original)) { break; } } else { break; } } else { break; } } maybeNotifyTopic(key, null, null); }
@Override public SoftLock tryLock(final Object key, final Object version) { long timeout = nextTimestamp(hazelcastInstance) + lockTimeout; final ExpiryMarker marker = (ExpiryMarker) map.executeOnKey(key, new LockEntryProcessor(nextMarkerId(), timeout, version)); return new MarkerWrapper(marker); }
@Override public boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); return (Boolean) map.executeOnKey(key, new UpdateEntryProcessor(unwrappedMarker, newValue, newVersion, nextMarkerId(), nextTimestamp(hazelcastInstance))); } else { return false; } }
@Override public SoftLock tryLock(final Object key, final Object version) { long timeout = nextTimestamp(hazelcastInstance) + lockTimeout; final ExpiryMarker marker = (ExpiryMarker) map.executeOnKey(key, new LockEntryProcessor(nextMarkerId(), timeout, version)); return new MarkerWrapper(marker); }
@Override public void unlock(final Object key, final SoftLock lock) { while (true) { final Expirable original = cache.get(key); if (original != null) { if (!(lock instanceof MarkerWrapper)) { break; } final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); if (original.matches(unwrappedMarker)) { final Expirable revised = ((ExpiryMarker) original).expire(nextTimestamp()); if (cache.replace(key, original, revised)) { break; } } else if (original.getValue() != null) { if (cache.remove(key, original)) { break; } } else { break; } } else { break; } } maybeNotifyTopic(key, null, null); }
public SoftLock tryLock(final Object key, final Object version) { long timeout = nextTimestamp(hazelcastInstance) + lockTimeout; final ExpiryMarker marker = (ExpiryMarker) map.executeOnKey(key, new LockEntryProcessor(nextMarkerId(), timeout, version)); return new MarkerWrapper(marker); }
@Override public void unlock(final Object key, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); map.executeOnKey(key, new UnlockEntryProcessor(unwrappedMarker, nextMarkerId(), nextTimestamp(hazelcastInstance))); } }
public void unlock(final Object key, SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); map.executeOnKey(key, new UnlockEntryProcessor(unwrappedMarker, nextMarkerId(), nextTimestamp(hazelcastInstance))); } }
@Override public boolean update(final Object key, final Object newValue, final Object newVersion, final SoftLock lock) { if (lock instanceof MarkerWrapper) { final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); return (Boolean) map.executeOnKey(key, new UpdateEntryProcessor(unwrappedMarker, newValue, newVersion, nextMarkerId(), nextTimestamp(hazelcastInstance))); } else { return false; } }
@Override public void unlock(final Object key, final SoftLock lock) { while (true) { final Expirable original = cache.get(key); if (original != null) { if (!(lock instanceof MarkerWrapper)) { break; } final ExpiryMarker unwrappedMarker = ((MarkerWrapper) lock).getMarker(); if (original.matches(unwrappedMarker)) { final Expirable revised = ((ExpiryMarker) original).expire(nextTimestamp()); if (cache.replace(key, original, revised)) { break; } } else if (original.getValue() != null) { if (cache.remove(key, original)) { break; } } else { break; } } else { break; } } maybeNotifyTopic(key, null, null); }