private void updateLastModified(String name) { try { // Update file timestamp manually to mimic last updated time updates without sleeping CLOCK.waitUntil(CLOCK.getTime() + TimeUnit.SECONDS.toMillis(2)); File f = new File(directory, name); f.setLastModified(CLOCK.getTimeIncreasing()); } catch (InterruptedException ie) { // ignored } }
private static long getTime() { try { return Clock.SIMPLE.getTimeIncreasing(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Clock.SIMPLE.getTimeMonotonic(); } } }
public static String configureUniqueId(NodeBuilder definition) { NodeBuilder status = definition.child(IndexDefinition.STATUS_NODE); String uid = status.getString(IndexDefinition.PROP_UID); if (uid == null) { try { uid = String.valueOf(Clock.SIMPLE.getTimeIncreasing()); } catch (InterruptedException e) { Thread.currentThread().interrupt(); uid = String.valueOf(Clock.SIMPLE.getTime()); } status.setProperty(IndexDefinition.PROP_UID, uid); } return uid; }
@Override public void run() { time = ACCURATE.getTime(); } }, FAST_CLOCK_INTERVAL, FAST_CLOCK_INTERVAL, TimeUnit.MILLISECONDS);
@Before public void before() throws Exception { clock.waitUntil(System.currentTimeMillis()); Revision.setClock(clock); }
/** * Waits until the given point in time is reached. The current thread * is suspended until the {@link #getTimeIncreasing()} method returns * a time that's equal or greater than the given point in time. * * @param timestamp time in milliseconds since epoch * @throws InterruptedException if the wait was interrupted */ public void waitUntil(long timestamp) throws InterruptedException { long now = getTimeIncreasing(); while (now < timestamp) { Thread.sleep(timestamp - now); now = getTimeIncreasing(); } }
/** * Convenience method that returns the {@link #getTimeMonotonic()} value * as a {@link Date} instance. * * @return monotonically increasing time */ public Date getDateMonotonic() { return new Date(getTimeMonotonic()); }
public Counters(Clock clock) { long time = clock.getTime(); this.clock = clock; this.loginTime = time; this.accessTime = time; }
@Before public void setup() throws Exception { clock = new Clock.Virtual(); clock.waitUntil(System.currentTimeMillis()); ClusterNodeInfo.setClock(clock); store = new MemoryDocumentStore(); wd1 = UUID.randomUUID().toString(); wd2 = UUID.randomUUID().toString(); }
/** * Convenience method that returns the {@link #getTimeIncreasing()} value * as a {@link Date} instance. * * @return strictly increasing time */ public Date getDateIncreasing() throws InterruptedException { return new Date(getTimeIncreasing()); }
/** * Convenience method that returns the {@link #getTimeMonotonic()} value * as a {@link Date} instance. * * @return monotonically increasing time */ public Date getDateMonotonic() { return new Date(getTimeMonotonic()); }
@Override public void cleaned(long reclaimed, long current) { lastCleanup = clock.getTime(); lastReclaimedSize = reclaimed; lastRepositorySize = current; }
protected Clock getTestClock() throws InterruptedException { Clock clock = new Clock.Virtual(); clock.waitUntil(getCurrentTimestamp()); return clock; }
/** * Convenience method that returns the {@link #getTimeIncreasing()} value * as a {@link Date} instance. * * @return strictly increasing time */ public Date getDateIncreasing() throws InterruptedException { return new Date(getTimeIncreasing()); }
private static long getTime() { try { return Clock.SIMPLE.getTimeIncreasing(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return Clock.SIMPLE.getTimeMonotonic(); } } }
/** * starts the clock */ public void start() { clock = new Clock.Fast(executor); start = clock.getTimeMonotonic(); }
public Counters(Clock clock) { long time = clock.getTime(); this.clock = clock; this.loginTime = time; this.accessTime = time; }