List of usage examples for com.google.common.base Ticker read
public abstract long read();
From source file:com.yahoo.yqlplus.engine.internal.java.runtime.RelativeTicker.java
public RelativeTicker(Ticker base) { this.base = base; this.start = base.read(); }
From source file:com.proofpoint.reporting.MinuteBucketIdProvider.java
public MinuteBucketIdProvider(Ticker ticker) { this.ticker = ticker; this.initialValue = ticker.read(); }
From source file:org.glowroot.agent.model.SyncQueryData.java
public long getTotalDurationNanos(Ticker ticker) { // TODO analyze worst case due to lack of atomicity if (activeCount > 0) { long currTick = ticker.read(); return sumOfEndTicks + currTick * activeCount - sumOfStartTicks; }/*from ww w .j av a 2 s.c om*/ return sumOfEndTicks - sumOfStartTicks; }
From source file:org.apache.brooklyn.policy.ha.ServiceReplacer.java
protected long currentTimeMillis() { Ticker ticker = getConfig(TICKER); return (ticker == null) ? System.currentTimeMillis() : TimeUnit.NANOSECONDS.toMillis(ticker.read()); }
From source file:org.glowroot.agent.model.AsyncQueryData.java
public long getTotalDurationNanos(Ticker ticker) { // TODO analyze worst case due to lack of atomicity, especially because it's possible for // async query to be active at the end of a transaction if (activeCount.get() > 0) { long currTick = ticker.read(); return sumOfEndTicks.get() + currTick * activeCount.get() - sumOfStartTicks.get(); }/*from w w w. ja v a 2s .c o m*/ return sumOfEndTicks.get() - sumOfStartTicks.get(); }
From source file:org.opendaylight.controller.cluster.datastore.actors.client.SequencedQueue.java
SequencedQueue(final Long cookie, final Ticker ticker) { this.cookie = Preconditions.checkNotNull(cookie); this.ticker = Preconditions.checkNotNull(ticker); lastProgress = ticker.read(); }
From source file:com.linecorp.armeria.client.circuitbreaker.SlidingWindowCounter.java
SlidingWindowCounter(Ticker ticker, Duration slidingWindow, Duration updateInterval) { this.ticker = requireNonNull(ticker, "ticker"); slidingWindowNanos = requireNonNull(slidingWindow, "slidingWindow").toNanos(); updateIntervalNanos = requireNonNull(updateInterval, "updateInterval").toNanos(); current = new AtomicReference<>(new Bucket(ticker.read())); }
From source file:com.tinspx.util.concurrent.TimedSemaphore.java
/** * Creates a new {@code TimedSemaphore} with given {@code limit} and * {@code period}. At most {@code limit} permits will be leased over a time * of {@code period}.// w ww. j a v a 2 s. com * * @param limit the maximum number of permits to lease in each * {@code period} * @param period the period during which at most {@code limit} permits may * be acquired * @param ticker the Ticker used to determine the current nano-time * @param unit the time unit of the {@code period} argument */ public TimedSemaphore(int limit, long period, TimeUnit unit, Ticker ticker) { this.limit = checkLimit(limit); this.ticker = checkNotNull(ticker); this.frame = ticker.read(); setPeriodImpl(period, unit); }
From source file:io.airlift.drift.client.DriftMethodInvocation.java
private DriftMethodInvocation(MethodInvoker invoker, MethodMetadata metadata, Map<String, String> headers, List<Object> parameters, RetryPolicy retryPolicy, AddressSelector<A> addressSelector, Optional<String> addressSelectionContext, MethodInvocationStat stat, Ticker ticker) { this.invoker = requireNonNull(invoker, "methodHandler is null"); this.metadata = requireNonNull(metadata, "metadata is null"); this.headers = requireNonNull(headers, "headers is null"); this.parameters = requireNonNull(parameters, "parameters is null"); this.retryPolicy = requireNonNull(retryPolicy, "retryPolicy is null"); this.addressSelector = requireNonNull(addressSelector, "addressSelector is null"); this.addressSelectionContext = requireNonNull(addressSelectionContext, "addressSelectionContext is null"); this.stat = requireNonNull(stat, "stat is null"); this.ticker = requireNonNull(ticker, "ticker is null"); this.startTime = ticker.read(); // if this invocation is canceled, cancel the tasks super.addListener(() -> { if (super.isCancelled()) { onCancel(wasInterrupted());/*from w w w .j av a2s .c o m*/ } }, directExecutor()); }
From source file:org.glowroot.agent.embedded.util.CappedDatabaseOutputStream.java
private CappedDatabaseOutputStream(File file, int requestedSizeKb, Ticker ticker) throws IOException { this.file = file; this.ticker = ticker; boolean newFile = !file.exists() || file.length() == 0; out = new RandomAccessFile(file, "rw"); if (newFile) { currIndex = 0;/*ww w . j ava 2 s. co m*/ sizeKb = requestedSizeKb; sizeBytes = sizeKb * 1024L; lastResizeBaseIndex = 0; out.writeLong(currIndex); out.writeInt(sizeKb); out.writeLong(lastResizeBaseIndex); } else { currIndex = out.readLong(); // have to ignore requested fixedLength for existing files, must explicitly call // resize() since this can be an expensive operation sizeKb = out.readInt(); sizeBytes = sizeKb * 1024L; lastResizeBaseIndex = out.readLong(); } smallestNonOverwrittenId = calculateSmallestNonOverwrittenId(lastResizeBaseIndex, currIndex, sizeBytes); lastFsyncTick.set(ticker.read()); fsyncScheduledRunnable = new FsyncRunnable(); }