本文整理汇总了Java中io.airlift.units.Duration.toMillis方法的典型用法代码示例。如果您正苦于以下问题:Java Duration.toMillis方法的具体用法?Java Duration.toMillis怎么用?Java Duration.toMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.airlift.units.Duration
的用法示例。
在下文中一共展示了Duration.toMillis方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNextPage
import io.airlift.units.Duration; //导入方法依赖的package包/类
@Nullable
public Page getNextPage(Duration maxWaitTime)
throws InterruptedException
{
checkState(!Thread.holdsLock(this), "Can not get next page while holding a lock on this");
throwIfFailed();
if (closed.get()) {
return null;
}
scheduleRequestIfNecessary();
Page page = pageBuffer.poll();
// only wait for a page if we have remote clients
if (page == null && maxWaitTime.toMillis() >= 1 && !allClients.isEmpty()) {
page = pageBuffer.poll(maxWaitTime.toMillis(), TimeUnit.MILLISECONDS);
}
page = postProcessPage(page);
return page;
}
示例2: toMillis
import io.airlift.units.Duration; //导入方法依赖的package包/类
private static Long toMillis(Duration duration)
{
if (duration == null) {
return null;
}
return duration.toMillis();
}
示例3: getTaskInfo
import io.airlift.units.Duration; //导入方法依赖的package包/类
@GET
@Path("{taskId}")
@Produces(MediaType.APPLICATION_JSON)
public void getTaskInfo(@PathParam("taskId") final TaskId taskId,
@HeaderParam(PRESTO_CURRENT_STATE) TaskState currentState,
@HeaderParam(PRESTO_MAX_WAIT) Duration maxWait,
@Context UriInfo uriInfo,
@Suspended AsyncResponse asyncResponse)
{
requireNonNull(taskId, "taskId is null");
if (currentState == null || maxWait == null) {
TaskInfo taskInfo = taskManager.getTaskInfo(taskId);
if (shouldSummarize(uriInfo)) {
taskInfo = taskInfo.summarize();
}
asyncResponse.resume(taskInfo);
return;
}
CompletableFuture<TaskInfo> futureTaskInfo = addTimeout(
taskManager.getTaskInfo(taskId, currentState),
() -> taskManager.getTaskInfo(taskId),
maxWait,
timeoutExecutor);
if (shouldSummarize(uriInfo)) {
futureTaskInfo = futureTaskInfo.thenApply(TaskInfo::summarize);
}
// For hard timeout, add an additional 5 seconds to max wait for thread scheduling contention and GC
Duration timeout = new Duration(maxWait.toMillis() + 5000, MILLISECONDS);
bindAsyncResponse(asyncResponse, futureTaskInfo, responseExecutor)
.withTimeout(timeout);
}
示例4: durationToMillis
import io.airlift.units.Duration; //导入方法依赖的package包/类
@Nullable
private static Long durationToMillis(@Nullable Duration duration)
{
if (duration == null) {
return null;
}
return duration.toMillis();
}
示例5: maxTimestamp
import io.airlift.units.Duration; //导入方法依赖的package包/类
private static Timestamp maxTimestamp(Duration duration)
{
return new Timestamp(System.currentTimeMillis() - duration.toMillis());
}
示例6: HttpRemoteTask
import io.airlift.units.Duration; //导入方法依赖的package包/类
public HttpRemoteTask(Session session,
TaskId taskId,
String nodeId,
int partition,
URI location,
PlanFragment planFragment,
Multimap<PlanNodeId, Split> initialSplits,
OutputBuffers outputBuffers,
HttpClient httpClient,
Executor executor,
ScheduledExecutorService errorScheduledExecutor,
Duration minErrorDuration,
Duration refreshMaxWait,
JsonCodec<TaskInfo> taskInfoCodec,
JsonCodec<TaskUpdateRequest> taskUpdateRequestCodec,
PartitionedSplitCountTracker partitionedSplitCountTracker)
{
requireNonNull(session, "session is null");
requireNonNull(taskId, "taskId is null");
requireNonNull(nodeId, "nodeId is null");
requireNonNull(location, "location is null");
checkArgument(partition >= 0, "partition is negative");
requireNonNull(planFragment, "planFragment1 is null");
requireNonNull(outputBuffers, "outputBuffers is null");
requireNonNull(httpClient, "httpClient is null");
requireNonNull(executor, "executor is null");
requireNonNull(taskInfoCodec, "taskInfoCodec is null");
requireNonNull(taskUpdateRequestCodec, "taskUpdateRequestCodec is null");
requireNonNull(partitionedSplitCountTracker, "partitionedSplitCountTracker is null");
try (SetThreadName ignored = new SetThreadName("HttpRemoteTask-%s", taskId)) {
this.taskId = taskId;
this.session = session;
this.nodeId = nodeId;
this.partition = partition;
this.planFragment = planFragment;
this.outputBuffers.set(outputBuffers);
this.httpClient = httpClient;
this.executor = executor;
this.errorScheduledExecutor = errorScheduledExecutor;
this.taskInfoCodec = taskInfoCodec;
this.taskUpdateRequestCodec = taskUpdateRequestCodec;
this.updateErrorTracker = new RequestErrorTracker(taskId, location, minErrorDuration, errorScheduledExecutor, "updating task");
this.getErrorTracker = new RequestErrorTracker(taskId, location, minErrorDuration, errorScheduledExecutor, "getting info for task");
this.partitionedSplitCountTracker = requireNonNull(partitionedSplitCountTracker, "partitionedSplitCountTracker is null");
for (Entry<PlanNodeId, Split> entry : requireNonNull(initialSplits, "initialSplits is null").entries()) {
ScheduledSplit scheduledSplit = new ScheduledSplit(nextSplitId.getAndIncrement(), entry.getValue());
pendingSplits.put(entry.getKey(), scheduledSplit);
}
if (initialSplits.containsKey(planFragment.getPartitionedSource())) {
pendingSourceSplitCount = initialSplits.get(planFragment.getPartitionedSource()).size();
}
List<BufferInfo> bufferStates = outputBuffers.getBuffers()
.keySet().stream()
.map(outputId -> new BufferInfo(outputId, false, 0, 0, PageBufferInfo.empty()))
.collect(toImmutableList());
TaskStats taskStats = new TaskStats(DateTime.now(), null);
taskInfo = new StateMachine<>("task " + taskId, executor, new TaskInfo(
taskId,
"",
TaskInfo.MIN_VERSION,
TaskState.PLANNED,
location,
DateTime.now(),
new SharedBufferInfo(BufferState.OPEN, true, true, 0, 0, 0, 0, bufferStates),
ImmutableSet.<PlanNodeId>of(),
taskStats,
ImmutableList.<ExecutionFailureInfo>of()));
long timeout = minErrorDuration.toMillis() / 3;
requestTimeout = new Duration(timeout + refreshMaxWait.toMillis(), MILLISECONDS);
continuousTaskInfoFetcher = new ContinuousTaskInfoFetcher(refreshMaxWait);
partitionedSplitCountTracker.setPartitionedSplitCount(getPartitionedSplitCount());
}
}
示例7: SimulationSplit
import io.airlift.units.Duration; //导入方法依赖的package包/类
private SimulationSplit(Duration requiredProcessTime, Duration processTimePerCall)
{
this.requiredProcessMillis = requiredProcessTime.toMillis();
this.processMillisPerCall = processTimePerCall.toMillis();
}