@Override public TimestampRange getFreshTimestamps(int numTimestampsRequested) { int numTimestampsToReturn = cleanUpTimestampRequest(numTimestampsRequested); TimestampRange range = timestamp.incrementBy(numTimestampsToReturn); DebugLogger.handedOutTimestamps(range); return range; }
@Override public synchronized void storeUpperLimit(long limit) { failures.verifyWeShouldIssueMoreTimestamps(); throwIfInterrupted(); try { delegate.storeUpperLimit(limit); } catch (Throwable t) { throw failures.responseTo(t); } }
public TimestampRange incrementBy(long delta) { TimestampRange range = timestamp.incrementBy(delta); upperLimit.increaseToAtLeast(range.getUpperBound()); return range; }
private static TimestampRange getFreshTimestampsFromDelegate(TimestampService timestampService, int timestamps) { if (timestamps == 1) { long timestamp = timestampService.getFreshTimestamp(); return TimestampRange.createInclusiveRange(timestamp, timestamp); } return timestampService.getFreshTimestamps(timestamps); }
private void getTimestampAndIgnoreErrors() { try { getTimestampService().getFreshTimestamp(); } catch (Exception e) { // expected } } }
@Test(expected = ServiceNotAvailableException.class) public void throwsAserviceNotAvailableExceptionIfThereAreMultipleServersRunning() { timestampBoundStore.pretendMultipleServersAreRunning(); getTimestampService().getFreshTimestamp(); }
public static PersistentTimestampService create(TimestampBoundStore store) { return create(new ErrorCheckingTimestampBoundStore(store), AtlasDbConstants.DEFAULT_INITIALIZE_ASYNC); }
private void storeUpperLimit(long upperLimit) { DebugLogger.willStoreNewUpperLimit(upperLimit); store.storeUpperLimit(upperLimit); DebugLogger.didStoreNewUpperLimit(upperLimit); }
@Override public long getFreshTimestamp() { return getFreshTimestamps(1).getLowerBound(); }
@Override public long getFreshTimestamp() { TimestampRange range = getFreshTimestamps(1); return range.getLowerBound(); }
private PersistentTimestampService getSingletonTimestampService() { if (timestampBoundStore == null || persistentTimestampService == null) { timestampBoundStore = new InMemoryTimestampBoundStore(); persistentTimestampService = PersistentTimestampServiceImpl.create(timestampBoundStore); } return persistentTimestampService; }
private void tryInitialize() { long latestTimestamp = store.getUpperLimit(); PersistentUpperLimit upperLimit = new PersistentUpperLimit(store); timestamp = new PersistentTimestamp(upperLimit, latestTimestamp); }
public static PersistentTimestampService create(ErrorCheckingTimestampBoundStore store, boolean initializeAsync) { PersistentTimestampServiceImpl service = new PersistentTimestampServiceImpl(store); service.wrapper.initialize(initializeAsync); return service.wrapper.isInitialized() ? service : service.wrapper; }
public void increaseTo(long newTimestamp) { timestamp.increaseTo(newTimestamp); upperLimit.increaseToAtLeast(newTimestamp); }
public PersistentTimestamp(PersistentUpperLimit upperLimit, long lastKnownValue) { this.upperLimit = upperLimit; this.timestamp = new AtomicTimestamp(lastKnownValue); DebugLogger.createdPersistentTimestamp(); }
private void fastForwardTimestampByOneHundredMillion() { long currentTimestamp = timestamps.getFreshTimestamp(); timestamps.fastForwardTimestamp(currentTimestamp + ONE_HUNDRED_MILLION); } }
@Override public PersistentTimestampService delegate() { checkInitialized(); return PersistentTimestampServiceImpl.this; }
public void increaseToAtLeast(long newLimit) { if (newLimit > currentLimit) { updateLimit(newLimit); } }
private void ignoringExceptions(Action action) { try { action.perform(); } catch (Exception e) { // Do nothing with expected exception } } }
public static PersistentTimestampService create(TimestampBoundStore store, boolean initializeAsync) { return create(new ErrorCheckingTimestampBoundStore(store), initializeAsync); }