@Test public void testLastEnqueued() { monitor.start(); long req1Start = System.currentTimeMillis(); TransactionFuture req1Future = monitor.register(new ReqId(0, 1), context, timeout); long req1Done = System.currentTimeMillis(); assertEquals(req1Future, monitor.lastEnqueued()); assertTrue(req1Start <= monitor.lastEnqueuedTime()); assertTrue(monitor.lastEnqueuedTime() <= req1Done); Uninterruptibly.sleep(3); long req2Start = System.currentTimeMillis(); TransactionFuture req2Future = monitor.register(new ReqId(0, 2), context, timeout); long req2Done = System.currentTimeMillis(); assertEquals(req2Future, monitor.lastEnqueued()); assertTrue(req2Start <= monitor.lastEnqueuedTime()); assertTrue(monitor.lastEnqueuedTime() <= req2Done); monitor.committed(new ReqId(0, 1)); assertEquals(req2Future, monitor.lastEnqueued()); assertTrue(req2Start <= monitor.lastEnqueuedTime()); assertTrue(monitor.lastEnqueuedTime() <= req2Done); monitor.committed(new ReqId(0, 2)); assertNull(monitor.lastEnqueued()); }
public TransactionFuture lastEnqueued() { synchronized (this) { return lastReqId != null ? registered.get(lastReqId) : null; } }
TransactionMonitor { public TransactionFuture lastEnqueued() { synchronized (this) { return lastReqId != null ? registered.get(lastReqId) : null; } } }
TransactionMonitor { public TransactionFuture lastEnqueued() { synchronized (this) { return lastReqId != null ? registered.get(lastReqId) : null; } } TransactionMonitor(int maxConcurrentTransactions); }
TransactionMonitor { public TransactionFuture lastEnqueued() { synchronized (this) { return lastReqId != null ? registered.get(lastReqId) : null; } } TransactionMonitor(int maxConcurrentTransactions); void close(); boolean start(); boolean stop(); boolean isStopped(); void clear(); int maxCapacity(); TransactionFuture register(ReqId reqId, TransactionContext context, long registrationTimeout); TransactionContext getTransactionContext(ReqId reqId); TransactionContext committed(ReqId reqId); void abort(ReqId reqId); void flush(ReqId reqId); TransactionFuture lastEnqueued(); long lastEnqueuedTime(); int registeredCount(); }
TransactionMonitor { public TransactionFuture lastEnqueued() { synchronized (this) { return lastReqId != null ? registered.get(lastReqId) : null; } } TransactionMonitor(int maxConcurrentTransactions); void close(); boolean start(); boolean stop(); boolean isStopped(); void clear(); int maxCapacity(); TransactionFuture register(ReqId reqId, TransactionContext context, long registrationTimeout); TransactionContext getTransactionContext(ReqId reqId); TransactionContext committed(ReqId reqId); void abort(ReqId reqId); void flush(ReqId reqId); TransactionFuture lastEnqueued(); long lastEnqueuedTime(); int registeredCount();  }