@Override public Timepoint getTime(long sinceEpoch, TimeUnit unit) { return new StandardTimepoint(getUnit().convert(sinceEpoch,unit),this); } }
@Override public String toString() { return name(); }
@Test public void testTimeSequence() throws Exception { Random r = new Random(); Timepoint[] times = new Timepoint[10]; for (int i = 0; i < times.length; i++) { times[i] = Timestamps.NANO.getTime(); if (i > 0) assertTrue(times[i] + " > " + times[i - 1], times[i].compareTo(times[i - 1])>0); Thread.sleep(r.nextInt(50) + 2); } }
@Override public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws BackendException { KeyColumn lockID = new KeyColumn(key, column); logger.debug("Attempting to acquireLock on {} ", lockID); int trialCount = 0; boolean locked; while (trialCount < lockMaxRetries) { final Timepoint lockStartTime = Timestamps.MILLI.getTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); locked = localLockMediator.lock(lockID, txh, lockStartTime.add(lockExpiryTimeMs)); trialCount++; if (!locked) { handleLockFailure(txh, lockID, trialCount); } else { logger.debug("Acquired lock on {}, {}", lockID, txh); break; } } ((HBaseTransaction) txh).updateLocks(lockID, expectedValue); }
@Override public void acquireLock(StaticBuffer key, StaticBuffer column, StaticBuffer expectedValue, StoreTransaction txh) throws BackendException { KeyColumn lockID = new KeyColumn(key, column); logger.debug("Attempting to acquireLock on {} ", lockID); int trialCount = 0; boolean locked; while (trialCount < lockMaxRetries) { final Timepoint lockStartTime = Timestamps.MILLI.getTime(System.currentTimeMillis(), TimeUnit.MILLISECONDS); locked = localLockMediator.lock(lockID, txh, lockStartTime.add(lockExpiryTimeMs)); trialCount++; if (!locked) { handleLockFailure(txh, lockID, trialCount); } else { logger.debug("Acquired lock on {}, {}", lockID, txh); break; } } ((HBaseTransaction) txh).updateLocks(lockID, expectedValue); }