@Override public int compareTo(Delayed o) { if (this.expiryTime.getTimestamp(TimeUnit.NANOSECONDS) < ((ExpirableKeyColumn) o).expiryTime.getTimestamp(TimeUnit.NANOSECONDS)) { return -1; } if (this.expiryTime.getTimestamp(TimeUnit.NANOSECONDS) > ((ExpirableKeyColumn) o).expiryTime.getTimestamp(TimeUnit.NANOSECONDS)) { return 1; } return 0; }
@Override protected void waitCondition() throws InterruptedException { if (lastInvocation!=null) times.sleepPast(lastInvocation.add(CLEAN_SLEEP_TIME)); }
public String toString() { TimeUnit u = times.getUnit(); if (start==null) return "Initialized"; if (stop==null) return String.format("Started at %d %s",start.getNativeTimestamp(),u); return String.format("%d %s", stop.getNativeTimestamp() - start.getNativeTimestamp(), u); } }
public long getNativeDeletionTime() { assert t.getProvider().equals(times); return t.getNativeTimestamp() & 0xFFFFFFFFFFFFFFFEL; // zero the LSB }
public Timepoint getAdditionTime() { return new StandardTimepoint(getAdditionTime(t.getNativeUnit()), t.getProvider()); } }
futureTime = futureTime.add(new StandardDuration(1L, TimeUnit.MILLISECONDS)); while ((now = getTime()).compareTo(futureTime) <= 0) { long delta = futureTime.getTimestamp(unit) - now.getTimestamp(unit); if (0L == delta) delta = 1L;
final Timepoint maxSafeMessageTime = currentTime.sub(readLagTime); 0 > maxSafeMessageTime.compareTo(timesliceEnd) /* maxSafeMessageTime < timesliceEnd */ ? maxSafeMessageTime : timesliceEnd; if (0 > messageTimeStart.compareTo(messageTimeEnd)) { final long delta = messageTimeStart.getNativeTimestamp() - messageTimeEnd.getNativeTimestamp(); Preconditions.checkState(messageTimeStart.compareTo(messageTimeEnd) < 0); Preconditions.checkState(messageTimeEnd.compareTo(currentTime) <= 0, "Attempting to read messages from the future: messageTimeEnd=% vs currentTime=%s", messageTimeEnd, currentTime); Preconditions.checkState(times.getUnit().equals(messageTimeStart.getNativeUnit()), "Expected TimestampProvider TimeUnit %s to match nextTimepoint unit %s", times.getUnit(), messageTimeStart.getNativeUnit()); Preconditions.checkState(times.getUnit().equals(messageTimeEnd.getNativeUnit()), "Expected Timestampprovider TimeUnit %s to match timeWindowEnd unit %s", times.getUnit(), messageTimeStart.getNativeUnit()); KeySliceQuery query = new KeySliceQuery(logKey, BufferUtil.getLongBuffer(messageTimeStart.getNativeTimestamp()), BufferUtil.getLongBuffer(messageTimeEnd.getNativeTimestamp())); query.setLimit(maxReadMsg); log.trace("Converted MessagePuller time window to {}", query); messageTimeEnd = messageTimeEnd.add(TWO_MICROSECONDS); log.debug("Extended time window to {}", messageTimeEnd); query = new KeySliceQuery(logKey, BufferUtil.nextBiggerBuffer(lastEntry.getColumn()), BufferUtil.getLongBuffer(messageTimeEnd.getNativeTimestamp())); log.debug("Converted extended MessagePuller time window to {}", query); List<Entry> extraEntries = BackendOperation.execute(getOperation(query),KCVSLog.this,times,maxReadTime);
private Duration timeSinceFirstMsg() { Duration sinceFirst = ZeroDuration.INSTANCE; if (!toSend.isEmpty()) { Timepoint firstTimestamp = toSend.get(0).message.getMessage().getTimestampMicro(); Timepoint nowTimestamp = times.getTime(); if (firstTimestamp.compareTo(nowTimestamp) < 0) { long firstRaw = firstTimestamp.getTimestamp(times.getUnit()); long nowRaw = nowTimestamp.getTimestamp(times.getUnit()); assert firstRaw < nowRaw; sinceFirst = new StandardDuration(nowRaw - firstRaw, times.getUnit()); } } return sinceFirst; }
final Timepoint now = times.sleepPast(ls.getWriteTimestamp().add(lockWait)); final long cutoffTime = now.sub(lockExpire).getTimestamp(timeUnit); if (tr.getTimestamp() < cutoffTime) { log.warn("Discarded expired claim on {} with timestamp {}", kc, tr.getTimestamp());
@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 forceCloseInstance(String instanceId) { Preconditions.checkArgument(!graph.getConfiguration().getUniqueGraphId().equals(instanceId), "Cannot force close this current instance [%s]. Properly shut down the graph instead.",instanceId); Preconditions.checkArgument(modifyConfig.has(REGISTRATION_TIME,instanceId),"Instance [%s] is not currently open",instanceId); Timepoint registrationTime = modifyConfig.get(REGISTRATION_TIME,instanceId); Preconditions.checkArgument(registrationTime.compareTo(txStartTime)<0,"The to-be-closed instance [%s] was started after this transaction" + "which indicates a successful restart and can hence not be closed: %s vs %s",instanceId,registrationTime,txStartTime); modifyConfig.remove(REGISTRATION_TIME,instanceId); }
public long getNativeAdditionTime() { assert t.getProvider().equals(times); return (t.getNativeTimestamp() & 0xFFFFFFFFFFFFFFFEL) | 1L; // force the LSB to 1 }
public Timepoint getDeletionTime() { return new StandardTimepoint(getDeletionTime(t.getNativeUnit()), t.getProvider()); }
@Override public int compareTo(Delayed o) { if (this.expiryTime.getTimestamp(TimeUnit.NANOSECONDS) < ((ExpirableKeyColumn) o).expiryTime.getTimestamp(TimeUnit.NANOSECONDS)) { return -1; } if (this.expiryTime.getTimestamp(TimeUnit.NANOSECONDS) > ((ExpirableKeyColumn) o).expiryTime.getTimestamp(TimeUnit.NANOSECONDS)) { return 1; } return 0; }
public Duration elapsed() { if (null == start) { return ZeroDuration.INSTANCE; } final Timepoint stopTime = (null==stop? times.getTime() : stop); return new StandardDuration(stopTime.getNativeTimestamp() - start.getNativeTimestamp(), times.getUnit()); }
} else if (0 > inmap.expires.compareTo(times.getTime())) {
private boolean lockLocally(KeyColumn lockID, StoreTransaction tx) { return lockLocally(lockID, times.getTime().add(lockExpire), tx); }
@Override public long getDelay(TimeUnit unit) { return expiryTime.getTimestamp(TimeUnit.NANOSECONDS); }
public void updateSchemaVertex(TitanSchemaVertex schemaVertex) { setProperty(schemaVertex, BaseKey.SchemaUpdateTime, times.getTime().getNativeTimestamp()); }
} else if (0 > inmap.expires.compareTo(times.getTime())) {