/** * Updates timestamp for a received event * * @param ts Object that implements Timestamped interface * @return updated timestamp */ public long update(HybridTimestamp ts) { return update(ts.getLogicalTime(), ts.getLogicalCounter()); }
/** * Updates timestamp for a received event * * @param ts Object that implements Timestamped interface * @return updated timestamp */ public long update(HybridTimestamp ts) { return update(ts.getLogicalTime(), ts.getLogicalCounter()); }
@Test public void initialTimestamp() { HybridTimestamp timestamp = new HybridTimestamp(physicalTimeProvider); TimeStamp ntpTime = new TimeStamp(timestamp.getLogicalTime()); assertEquals(ntpTime.getDate(), new Date(0)); }
@Test public void testTimestamp() { HybridTimestamp timestamp = new HybridTimestamp(physicalTimeProvider); timestamp.update(); timestamp.update(); assertTrue(timestamp.getLogicalCounter() > 0); HybridTimestamp timestamp1 = new HybridTimestamp(physicalTimeProvider, timestamp.getLogicalTime(), timestamp.getLogicalCounter()); assertEquals(timestamp1.getLogicalCounter(), timestamp.getLogicalCounter()); }
physicalTimeProvider.setPhysicalTime(ts); timestamp.update(); assertEquals(ts, timestamp.getLogicalTime()); assertEquals(0, timestamp.getLogicalCounter()); physicalTimeProvider.setPhysicalTime(ts); timestamp.update(); assertEquals(ts, timestamp.getLogicalTime()); assertEquals(1, timestamp.getLogicalCounter()); ts_ = timestamp.getLogicalTime(); timestamp.update(); assertEquals(ts_, timestamp.getLogicalTime()); assertEquals(2, timestamp.getLogicalCounter()); physicalTimeProvider.setPhysicalTime(ts); timestamp.update(); assertEquals(ts, timestamp.getLogicalTime()); assertEquals(0, timestamp.getLogicalCounter()); physicalTimeProvider.setPhysicalTime(ts); timestamp.update((long) 1 << 32 | 2, 3); assertEquals(ts, timestamp.getLogicalTime()); assertEquals(0, timestamp.getLogicalCounter()); physicalTimeProvider.setPhysicalTime(ts); timestamp.update((long) 1 << 32 | 2, 3); assertEquals(ts, timestamp.getLogicalTime()); assertEquals(1, timestamp.getLogicalCounter());