public TimestampRid fromLockColumn(StaticBuffer lockKey, TimestampProvider provider) { ReadBuffer r = lockKey.asReadBuffer(); int len = r.length(); long tsNS = r.getLong(); len -= 8; byte[] curRid = new byte[len]; for (int i = 0; r.hasRemaining(); i++) { curRid[i] = r.getByte(); } StaticBuffer rid = new StaticArrayBuffer(curRid); Instant time = provider.getTime(tsNS); return new TimestampRid(time, rid); } }
private void runWithExceptions() throws BackendException { StaticBuffer lockKey = serializer.toLockKey(target.getKey(), target.getColumn()); List<Entry> locks = store.getSlice(new KeySliceQuery(lockKey, LOCK_COL_START, LOCK_COL_END), tx); // TODO reduce LOCK_COL_END based on cutoff ImmutableList.Builder<StaticBuffer> b = ImmutableList.builder(); for (Entry lc : locks) { TimestampRid tr = serializer.fromLockColumn(lc.getColumn(), times); if (tr.getTimestamp().isBefore(cutoff)) { log.info("Deleting expired lock on {} by rid {} with timestamp {} (before or at cutoff {})", new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff }); b.add(lc.getColumn()); } else { log.debug("Ignoring lock on {} by rid {} with timestamp {} (timestamp is after cutoff {})", new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff }); } } List<StaticBuffer> dels = b.build(); if (!dels.isEmpty()) { store.mutate(lockKey, ImmutableList.<Entry>of(), dels, tx); log.info("Deleted {} expired locks (before or at cutoff {})", dels.size(), cutoff); } }
trCount++; if (!rid.equals(tr.getRid())) { final String msg = "Lock on " + target + " already held by " + tr.getRid() + " (we are " + rid + ")"; log.debug(msg); throw new TemporaryLockingException(msg); if (tr.getTimestamp().equals(ls.getWriteTimestamp())) { new Object[]{target, tr.getRid(), tr.getTimestamp(), ls.getWriteTimestamp()});
public TimestampRid fromLockColumn(StaticBuffer lockKey) { ReadBuffer r = lockKey.asReadBuffer(); int len = r.length(); long tsNS = r.getLong(); len -= 8; byte[] curRid = new byte[len]; for (int i = 0; r.hasRemaining(); i++) { curRid[i] = r.getByte(); } StaticBuffer rid = new StaticArrayBuffer(curRid); return new TimestampRid(tsNS, rid); } }
for (TimestampRid tr : iter) { final Instant cutoffTime = now.minus(lockExpire); if (tr.getTimestamp().isBefore(cutoffTime)) { log.warn("Discarded expired claim on {} with timestamp {}", kc, tr.getTimestamp()); if (null != cleanerService) cleanerService.clean(kc, cutoffTime, tx); if (rid.equals(tr.getRid()) && ls.getWriteTimestamp().equals(tr.getTimestamp())) { throw new ExpiredLockException("Expired lock on " + kc.toString() + ": lock timestamp " + tr.getTimestamp() + " " + times.getUnit() + " is older than " + ConfigElement.getPath(GraphDatabaseConfiguration.LOCK_EXPIRE) + "=" + lockExpire);
public TimestampRid fromLockColumn(StaticBuffer lockKey, TimestampProvider provider) { ReadBuffer r = lockKey.asReadBuffer(); int len = r.length(); long tsNS = r.getLong(); len -= 8; byte[] curRid = new byte[len]; for (int i = 0; r.hasRemaining(); i++) { curRid[i] = r.getByte(); } StaticBuffer rid = new StaticArrayBuffer(curRid); Instant time = provider.getTime(tsNS); return new TimestampRid(time, rid); } }
private void runWithExceptions() throws BackendException { StaticBuffer lockKey = serializer.toLockKey(target.getKey(), target.getColumn()); List<Entry> locks = store.getSlice(new KeySliceQuery(lockKey, LOCK_COL_START, LOCK_COL_END), tx); // TODO reduce LOCK_COL_END based on cutoff ImmutableList.Builder<StaticBuffer> b = ImmutableList.builder(); for (Entry lc : locks) { TimestampRid tr = serializer.fromLockColumn(lc.getColumn(), times); if (tr.getTimestamp().isBefore(cutoff)) { log.info("Deleting expired lock on {} by rid {} with timestamp {} (before or at cutoff {})", new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff }); b.add(lc.getColumn()); } else { log.debug("Ignoring lock on {} by rid {} with timestamp {} (timestamp is after cutoff {})", new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff }); } } List<StaticBuffer> dels = b.build(); if (!dels.isEmpty()) { store.mutate(lockKey, ImmutableList.<Entry>of(), dels, tx); log.info("Deleted {} expired locks (before or at cutoff {})", dels.size(), cutoff); } }
private void runWithExceptions() throws BackendException { StaticBuffer lockKey = serializer.toLockKey(target.getKey(), target.getColumn()); List<Entry> locks = store.getSlice(new KeySliceQuery(lockKey, LOCK_COL_START, LOCK_COL_END), tx); // TODO reduce LOCK_COL_END based on cutoff ImmutableList.Builder<StaticBuffer> b = ImmutableList.builder(); for (Entry lc : locks) { TimestampRid tr = serializer.fromLockColumn(lc.getColumn()); if (tr.getTimestamp() < cutoff) { log.info("Deleting expired lock on {} by rid {} with timestamp {} (before or at cutoff {})", new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff }); b.add(lc.getColumn()); } else { log.debug("Ignoring lock on {} by rid {} with timestamp {} (timestamp is after cutoff {})", new Object[] { target, tr.getRid(), tr.getTimestamp(), cutoff }); } } List<StaticBuffer> dels = b.build(); if (!dels.isEmpty()) { store.mutate(lockKey, ImmutableList.<Entry>of(), dels, tx); log.info("Deleted {} expired locks (before or at cutoff {})", dels.size(), cutoff); } }
trCount++; if (!rid.equals(tr.getRid())) { final String msg = "Lock on " + target + " already held by " + tr.getRid() + " (we are " + rid + ")"; log.debug(msg); throw new TemporaryLockingException(msg); if (tr.getTimestamp() == ls.getWriteTimestamp(timeUnit)) { new Object[]{target, tr.getRid(), tr.getTimestamp(), ls.getWriteTimestamp(timeUnit)});
trCount++; if (!rid.equals(tr.getRid())) { final String msg = "Lock on " + target + " already held by " + tr.getRid() + " (we are " + rid + ")"; log.debug(msg); throw new TemporaryLockingException(msg); if (tr.getTimestamp().equals(ls.getWriteTimestamp())) { new Object[]{target, tr.getRid(), tr.getTimestamp(), ls.getWriteTimestamp()});
for (TimestampRid tr : iter) { final Instant cutoffTime = now.minus(lockExpire); if (tr.getTimestamp().isBefore(cutoffTime)) { log.warn("Discarded expired claim on {} with timestamp {}", kc, tr.getTimestamp()); if (null != cleanerService) cleanerService.clean(kc, cutoffTime, tx); if (rid.equals(tr.getRid()) && ls.getWriteTimestamp().equals(tr.getTimestamp())) { throw new ExpiredLockException("Expired lock on " + kc.toString() + ": lock timestamp " + tr.getTimestamp() + " " + times.getUnit() + " is older than " + ConfigElement.getPath(GraphDatabaseConfiguration.LOCK_EXPIRE) + "=" + lockExpire);
for (TimestampRid tr : iter) { final long cutoffTime = now.sub(lockExpire).getTimestamp(timeUnit); if (tr.getTimestamp() < cutoffTime) { log.warn("Discarded expired claim on {} with timestamp {}", kc, tr.getTimestamp()); if (null != cleanerService) cleanerService.clean(kc, cutoffTime, tx); if (rid.equals(tr.getRid()) && ls.getWriteTimestamp(timeUnit) == tr.getTimestamp()) { throw new ExpiredLockException("Expired lock on " + kc.toString() + ": lock timestamp " + tr.getTimestamp() + " " + timeUnit + " is older than " + ConfigElement.getPath(GraphDatabaseConfiguration.LOCK_EXPIRE) + "=" + lockExpire);