@Override protected void deleteSingleLock(KeyColumn kc, ConsistentKeyLockStatus ls, StoreTransaction tx) { List<StaticBuffer> dels = ImmutableList.of(serializer.toLockCol(ls.getWriteTimestamp(), rid, times)); for (int i = 0; i < lockRetryCount; i++) { try { StoreTransaction newTx = overrideTimestamp(tx, times.getTime()); store.mutate(serializer.toLockKey(kc.getKey(), kc.getColumn()), ImmutableList.<Entry>of(), dels, newTx); return; } catch (TemporaryBackendException e) { log.warn("Temporary storage exception while deleting lock", e); // don't return -- iterate and retry } catch (BackendException e) { log.error("Storage exception while deleting lock", e); return; // give up on this lock } } }
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); } }
KeySliceQuery ksq = new KeySliceQuery(serializer.toLockKey(kc.getKey(), kc.getColumn()), LOCK_COL_START, LOCK_COL_END); List<Entry> claimEntries = getSliceWithRetries(ksq, tx);
protected ConsistentKeyLockStatus writeSingleLock(KeyColumn lockID, StoreTransaction txh) throws Throwable { final StaticBuffer lockKey = serializer.toLockKey(lockID.getKey(), lockID.getColumn()); StaticBuffer oldLockCol = null;
@Override protected void deleteSingleLock(KeyColumn kc, ConsistentKeyLockStatus ls, StoreTransaction tx) { List<StaticBuffer> dels = ImmutableList.of(serializer.toLockCol(ls.getWriteTimestamp(), rid, times)); for (int i = 0; i < lockRetryCount; i++) { try { StoreTransaction newTx = overrideTimestamp(tx, times.getTime()); store.mutate(serializer.toLockKey(kc.getKey(), kc.getColumn()), ImmutableList.<Entry>of(), dels, newTx); return; } catch (TemporaryBackendException e) { log.warn("Temporary storage exception while deleting lock", e); // don't return -- iterate and retry } catch (BackendException e) { log.error("Storage exception while deleting lock", e); return; // give up on this lock } } }
@Override protected void deleteSingleLock(KeyColumn kc, ConsistentKeyLockStatus ls, StoreTransaction tx) { List<StaticBuffer> dels = ImmutableList.of(serializer.toLockCol(ls.getWriteTimestamp(timeUnit), rid)); for (int i = 0; i < lockRetryCount; i++) { try { StoreTransaction newTx = overrideTimestamp(tx, times.getTime()); store.mutate(serializer.toLockKey(kc.getKey(), kc.getColumn()), ImmutableList.<Entry>of(), dels, newTx); return; } catch (TemporaryBackendException e) { log.warn("Temporary storage exception while deleting lock", e); // don't return -- iterate and retry } catch (BackendException e) { log.error("Storage exception while deleting lock", e); return; // give up on this lock } } }
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); } }
KeySliceQuery ksq = new KeySliceQuery(serializer.toLockKey(kc.getKey(), kc.getColumn()), LOCK_COL_START, LOCK_COL_END); List<Entry> claimEntries = getSliceWithRetries(ksq, tx);
KeySliceQuery ksq = new KeySliceQuery(serializer.toLockKey(kc.getKey(), kc.getColumn()), LOCK_COL_START, LOCK_COL_END); List<Entry> claimEntries = getSliceWithRetries(ksq, tx);
protected ConsistentKeyLockStatus writeSingleLock(KeyColumn lockID, StoreTransaction txh) throws Throwable { final StaticBuffer lockKey = serializer.toLockKey(lockID.getKey(), lockID.getColumn()); StaticBuffer oldLockCol = null;
protected ConsistentKeyLockStatus writeSingleLock(KeyColumn lockID, StoreTransaction txh) throws Throwable { final StaticBuffer lockKey = serializer.toLockKey(lockID.getKey(), lockID.getColumn()); StaticBuffer oldLockCol = null;