@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { final Value newValue = new Value(currentVersion, nextTimestamp(), value); return cache.putIfAbsent(key, newValue) == null; }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { while (true) { Expirable previous = cache.get(key); Value newValue = new Value(version, nextTimestamp(), value); if (previous == null) { if (cache.putIfAbsent(key, newValue) == null) { return true; } } else if (previous.isReplaceableBy(txTimestamp, version, versionComparator)) { if (cache.replace(key, previous, newValue)) { return true; } } else { return false; } } }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
@Override public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
public boolean insert(final Object key, final Object value, final Object currentVersion) { return map.putIfAbsent(key, new Value(currentVersion, nextTimestamp(hazelcastInstance), value)) == null; }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { // Ideally this would be an entry processor. Unfortunately there is no guarantee that // the versionComparator is Serializable. // // Alternatively this could be implemented using a `map.get` followed by `map.set` wrapped inside a // `map.tryLock` block. Unfortunately this implementation was prone to `IllegalMonitorStateException` when // the lock was released under heavy load or after network partitions. Hence this implementation now uses // a spin loop around atomic operations. long timeout = System.currentTimeMillis() + tryLockAndGetTimeout; do { Expirable previousEntry = map.get(key); Value newValue = new Value(version, txTimestamp, value); if (previousEntry == null) { if (map.putIfAbsent(key, newValue) == null) { return true; } } else if (previousEntry.isReplaceableBy(txTimestamp, version, versionComparator)) { if (map.replace(key, previousEntry, newValue)) { return true; } } else { return false; } } while (System.currentTimeMillis() < timeout); return false; }
@Override protected void maybeInvalidate(final Object messageObject) { final Timestamp ts = (Timestamp) messageObject; final Object key = ts.getKey(); if (key == null) { // Invalidate the entire region cache. cache.clear(); return; } for (;;) { final Expirable value = cache.get(key); final Long current = value != null ? (Long) value.getValue() : null; if (current != null) { if (ts.getTimestamp() > current) { if (cache.replace(key, value, new Value(value.getVersion(), nextTimestamp(), ts.getTimestamp()))) { return; } } else { return; } } else { if (cache.putIfAbsent(key, new Value(null, nextTimestamp(), ts.getTimestamp())) == null) { return; } } } }
@Override public boolean put(Object key, Object value, long txTimestamp, final Object version) { // Ideally this would be an entry processor. Unfortunately there is no guarantee that // the versionComparator is Serializable. // // Alternatively this could be implemented using a `map.get` followed by `map.set` wrapped inside a // `map.tryLock` block. Unfortunately this implementation was prone to `IllegalMonitorStateException` when // the lock was released under heavy load or after network partitions. Hence this implementation now uses // a spin loop around atomic operations. long timeout = System.currentTimeMillis() + tryLockAndGetTimeout; do { Expirable previousEntry = map.get(key); Value newValue = new Value(version, txTimestamp, value); if (previousEntry == null) { if (map.putIfAbsent(key, newValue) == null) { return true; } } else if (previousEntry.isReplaceableBy(txTimestamp, version, versionComparator)) { if (map.replace(key, previousEntry, newValue)) { return true; } } else { return false; } } while (System.currentTimeMillis() < timeout); return false; }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { // Ideally this would be an entry processor. Unfortunately there is no guarantee that // the versionComparator is Serializable. // // Alternatively this could be implemented using a `map.get` followed by `map.set` wrapped inside a // `map.tryLock` block. Unfortunately this implementation was prone to `IllegalMonitorStateException` when // the lock was released under heavy load or after network partitions. Hence this implementation now uses // a spin loop around atomic operations. long timeout = System.currentTimeMillis() + tryLockAndGetTimeout; do { Expirable previousEntry = map.get(key); Value newValue = new Value(version, txTimestamp, value); if (previousEntry == null) { if (map.putIfAbsent(key, newValue) == null) { return true; } } else if (previousEntry.isReplaceableBy(txTimestamp, version, versionComparator)) { if (map.replace(key, previousEntry, newValue)) { return true; } } else { return false; } } while (System.currentTimeMillis() < timeout); return false; }
@Override protected void maybeInvalidate(final Object messageObject) { final Timestamp ts = (Timestamp) messageObject; final Object key = ts.getKey(); if (key == null) { // Invalidate the entire region cache. cache.clear(); return; } for (; ; ) { final Expirable value = cache.get(key); final Long current = value != null ? (Long) value.getValue() : null; if (current != null) { if (ts.getTimestamp() > current) { if (cache.replace(key, value, new Value(value.getVersion(), nextTimestamp(), ts.getTimestamp()))) { return; } } else { return; } } else { if (cache.putIfAbsent(key, new Value(null, nextTimestamp(), ts.getTimestamp())) == null) { return; } } } }
@Override public boolean put(final Object key, final Object value, final long txTimestamp, final Object version) { // Ideally this would be an entry processor. Unfortunately there is no guarantee that // the versionComparator is Serializable. // // Alternatively this could be implemented using a `map.get` followed by `map.set` wrapped inside a // `map.tryLock` block. Unfortunately this implementation was prone to `IllegalMonitorStateException` when // the lock was released under heavy load or after network partitions. Hence this implementation now uses // a spin loop around atomic operations. long timeout = System.currentTimeMillis() + tryLockAndGetTimeout; do { Expirable previousEntry = map.get(key); Value newValue = new Value(version, txTimestamp, value); if (previousEntry == null) { if (map.putIfAbsent(key, newValue) == null) { return true; } } else if (previousEntry.isReplaceableBy(txTimestamp, version, versionComparator)) { if (map.replace(key, previousEntry, newValue)) { return true; } } else { return false; } } while (System.currentTimeMillis() < timeout); return false; }
switch (typeId) { case VALUE: result = new Value(); break; case EXPIRY_MARKER:
switch (typeId) { case VALUE: result = new Value(); break; case EXPIRY_MARKER: