org.elasticsearch.common.unit.TimeValue.timeValueNanos()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.4k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中org.elasticsearch.common.unit.TimeValue.timeValueNanos()方法的一些代码示例,展示了TimeValue.timeValueNanos()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TimeValue.timeValueNanos()方法的具体详情如下:
包路径:org.elasticsearch.common.unit.TimeValue
类名称:TimeValue
方法名:timeValueNanos

TimeValue.timeValueNanos介绍

暂无

代码示例

代码示例来源:origin: org.elasticsearch/elasticsearch

public UpdateIndexShardSnapshotStatusRequest(Snapshot snapshot, ShardId shardId, ShardSnapshotStatus status) {
  this.snapshot = snapshot;
  this.shardId = shardId;
  this.status = status;
  // By default, we keep trying to post snapshot status messages to avoid snapshot processes getting stuck.
  this.masterNodeTimeout = TimeValue.timeValueNanos(Long.MAX_VALUE);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public synchronized TimeValue targetThrottling() {
  return TimeValue.timeValueNanos(targetThrottleTimeInNanos);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public synchronized TimeValue sourceThrottling() {
  return TimeValue.timeValueNanos(sourceThrottlingInNanos);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
   * Scale back remaining delay to fit the new delay.
   */
  TimeValue newDelay(long remainingDelay, float newRequestsPerSecond) {
    if (remainingDelay < 0) {
      return timeValueNanos(0);
    }
    return timeValueNanos(round(remainingDelay * requestsPerSecond / newRequestsPerSecond));
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Total time recoveries waited due to throttling
 */
public TimeValue throttleTime() {
  return TimeValue.timeValueNanos(throttleTimeInNanos.get());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

TimeValue throttledUntil() {
  DelayedPrepareBulkRequest delayed = delayedPrepareBulkRequestReference.get();
  if (delayed == null) {
    return timeValueNanos(0);
  }
  if (delayed.future == null) {
    return timeValueNanos(0);
  }
  return timeValueNanos(max(0, delayed.future.getDelay(TimeUnit.NANOSECONDS)));
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
protected void appendThreadPoolExecutorDetails(StringBuilder sb) {
  sb.append("min queue capacity = ").append(minQueueSize).append(", ");
  sb.append("max queue capacity = ").append(maxQueueSize).append(", ");
  sb.append("frame size = ").append(tasksPerFrame).append(", ");
  sb.append("targeted response rate = ").append(TimeValue.timeValueNanos(targetedResponseTimeNanos)).append(", ");
  sb.append("task execution EWMA = ").append(TimeValue.timeValueNanos((long) executionEWMA.getAverage())).append(", ");
  sb.append("adjustment amount = ").append(QUEUE_ADJUSTMENT_AMOUNT).append(", ");
}

代码示例来源:origin: org.elasticsearch/elasticsearch

private BulkResponse getAccumulatedResponse() {
  BulkItemResponse[] itemResponses;
  synchronized (responses) {
    itemResponses = responses.toArray(new BulkItemResponse[1]);
  }
  long stopTimestamp = System.nanoTime();
  long totalLatencyMs = TimeValue.timeValueNanos(stopTimestamp - startTimestampNanos).millis();
  return new BulkResponse(itemResponses, totalLatencyMs);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public TimeValue throttleWaitTime(TimeValue lastBatchStartTime, TimeValue now, int lastBatchSize) {
  long earliestNextBatchStartTime = now.nanos() + (long) perfectlyThrottledBatchTime(lastBatchSize);
  long waitTime = min(MAX_THROTTLE_WAIT_TIME.nanos(), max(0, earliestNextBatchStartTime - System.nanoTime()));
  return timeValueNanos(waitTime);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

public BulkByScrollTask.Status getStatus() {
  return new BulkByScrollTask.Status(
    sliceId,
    total.get(),
    updated.get(),
    created.get(),
    deleted.get(),
    batch.get(),
    versionConflicts.get(),
    noops.get(),
    bulkRetries.get(),
    searchRetries.get(),
    timeValueNanos(throttledNanos.get()),
    getRequestsPerSecond(),
    task.getReasonCancelled(),
    throttledUntil());
}

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Returns the waiting time of the first task in the queue
 */
public TimeValue getMaxTaskWaitTime() {
  if (getQueue().size() == 0) {
    return NO_WAIT_TIME_VALUE;
  }
  long now = System.nanoTime();
  long oldestCreationDateInNanos = now;
  for (Runnable queuedRunnable : getQueue()) {
    if (queuedRunnable instanceof PrioritizedRunnable) {
      oldestCreationDateInNanos = Math.min(oldestCreationDateInNanos,
          ((PrioritizedRunnable) queuedRunnable).getCreationDateInNanos());
    }
  }
  return TimeValue.timeValueNanos(now - oldestCreationDateInNanos);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

StringBuilder sb = new StringBuilder();
sb.append(index).append(" ");
sb.append("took[").append(TimeValue.timeValueNanos(tookInNanos)).append("], ");
sb.append("took_millis[").append(TimeUnit.NANOSECONDS.toMillis(tookInNanos)).append("], ");
sb.append("type[").append(doc.type()).append("], ");

代码示例来源:origin: org.elasticsearch/elasticsearch

public BulkByScrollResponse(Iterable<BulkByScrollResponse> toMerge, @Nullable String reasonCancelled) {
  long mergedTook = 0;
  List<BulkByScrollTask.StatusOrException> statuses = new ArrayList<>();
  bulkFailures = new ArrayList<>();
  searchFailures = new ArrayList<>();
  for (BulkByScrollResponse response : toMerge) {
    mergedTook = max(mergedTook, response.getTook().nanos());
    statuses.add(new BulkByScrollTask.StatusOrException(response.status));
    bulkFailures.addAll(response.getBulkFailures());
    searchFailures.addAll(response.getSearchFailures());
    timedOut |= response.isTimedOut();
  }
  took = timeValueNanos(mergedTook);
  status = new BulkByScrollTask.Status(statuses, reasonCancelled);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

sb.append(context.indexShard().shardId())
    .append(" ")
    .append("took[").append(TimeValue.timeValueNanos(tookInNanos)).append("], ")
    .append("took_millis[").append(TimeUnit.NANOSECONDS.toMillis(tookInNanos)).append("], ")
    .append("total_hits[").append(context.queryResult().getTotalHits()).append("], ");

代码示例来源:origin: org.elasticsearch/elasticsearch

/**
 * Schedule prepareBulkRequestRunnable to run after some delay. This is where throttling plugs into reindexing so the request can be
 * rescheduled over and over again.
 */
public void delayPrepareBulkRequest(ThreadPool threadPool, TimeValue lastBatchStartTime, int lastBatchSize,
                  AbstractRunnable prepareBulkRequestRunnable) {
  // Synchronize so we are less likely to schedule the same request twice.
  synchronized (delayedPrepareBulkRequestReference) {
    TimeValue delay = throttleWaitTime(lastBatchStartTime, timeValueNanos(System.nanoTime()), lastBatchSize);
    logger.debug("[{}]: preparing bulk request for [{}]", task.getId(), delay);
    try {
      delayedPrepareBulkRequestReference.set(new DelayedPrepareBulkRequest(threadPool, getRequestsPerSecond(),
        delay, new RunOnce(prepareBulkRequestRunnable)));
    } catch (EsRejectedExecutionException e) {
      prepareBulkRequestRunnable.onRejection(e);
    }
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

removeTaskAndCancel();
} else {
  TimeValue nextDelay = TimeValue.timeValueNanos(nextDelayNanos);
  final boolean earlierRerouteNeeded;
  DelayedRerouteTask existingTask = delayedRerouteTask.get();
      TimeValue.timeValueNanos(existingTask.scheduledTimeToRunInNanos() - newTask.scheduledTimeToRunInNanos()));
    existingTask.cancelScheduling();
    earlierRerouteNeeded = true;

代码示例来源:origin: org.elasticsearch/elasticsearch

"warmed global ordinals for [{}], took [{}]",
fieldType.name(),
TimeValue.timeValueNanos(System.nanoTime() - start));

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public void onCommit(TimeValue commitTime) {
  TimeValue ackTimeout = ackedTaskListener.ackTimeout();
  if (ackTimeout == null) {
    ackTimeout = TimeValue.ZERO;
  }
  final TimeValue timeLeft = TimeValue.timeValueNanos(Math.max(0, ackTimeout.nanos() - commitTime.nanos()));
  if (timeLeft.nanos() == 0L) {
    onTimeout();
  } else if (countDown.countDown()) {
    finish();
  } else {
    this.ackTimeoutCallback = threadPool.schedule(timeLeft, ThreadPool.Names.GENERIC, this::onTimeout);
    // re-check if onNodeAck has not completed while we were scheduling the timeout
    if (countDown.isCountedDown()) {
      FutureUtils.cancel(ackTimeoutCallback);
    }
  }
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
protected void doStartNextScroll(String scrollId, TimeValue extraKeepAlive, Consumer<? super Response> onResponse) {
  searchWithRetry(listener -> {
    SearchScrollRequest request = new SearchScrollRequest();
    // Add the wait time into the scroll timeout so it won't timeout while we wait for throttling
    request.scrollId(scrollId).scroll(timeValueNanos(firstSearchRequest.scroll().keepAlive().nanos() + extraKeepAlive.nanos()));
    client.searchScroll(request, listener);
  }, r -> consume(r, onResponse));
}

代码示例来源:origin: org.elasticsearch/elasticsearch

private void buildRow(Table table, boolean fullId, boolean detailed, DiscoveryNodes discoveryNodes, TaskInfo taskInfo) {
  table.startRow();
  String nodeId = taskInfo.getTaskId().getNodeId();
  DiscoveryNode node = discoveryNodes.get(nodeId);
  table.addCell(taskInfo.getId());
  table.addCell(taskInfo.getAction());
  table.addCell(taskInfo.getTaskId().toString());
  if (taskInfo.getParentTaskId().isSet()) {
    table.addCell(taskInfo.getParentTaskId().toString());
  } else {
    table.addCell("-");
  }
  table.addCell(taskInfo.getType());
  table.addCell(taskInfo.getStartTime());
  table.addCell(FORMATTER.format(Instant.ofEpochMilli(taskInfo.getStartTime())));
  table.addCell(taskInfo.getRunningTimeNanos());
  table.addCell(TimeValue.timeValueNanos(taskInfo.getRunningTimeNanos()).toString());
  // Node information. Note that the node may be null because it has left the cluster between when we got this response and now.
  table.addCell(fullId ? nodeId : Strings.substring(nodeId, 0, 4));
  table.addCell(node == null ? "-" : node.getHostAddress());
  table.addCell(node.getAddress().address().getPort());
  table.addCell(node == null ? "-" : node.getName());
  table.addCell(node == null ? "-" : node.getVersion().toString());
  if (detailed) {
    table.addCell(taskInfo.getDescription());
  }
  table.endRow();
}

相关文章