org.elasticsearch.threadpool.ThreadPool.relativeTimeInMillis()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.2k)|赞(0)|评价(0)|浏览(145)

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

ThreadPool.relativeTimeInMillis介绍

[英]Returns a value of milliseconds that may be used for relative time calculations. This method should only be used for calculating time deltas. For an epoch based timestamp, see #absoluteTimeInMillis().
[中]返回可用于相对时间计算的毫秒值。此方法只能用于计算时间增量。有关基于历元的时间戳,请参见#absoluteTimeInMillis()。

代码示例

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

private ScheduledPing(TimeValue pingInterval) {
  super(lifecycle, logger);
  this.pingInterval = pingInterval;
  this.lastPingRelativeMillis = threadPool.relativeTimeInMillis();
}

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

@Override
protected void doRunInLifecycle() {
  for (TcpChannel channel : channels) {
    // In the future it is possible that we may want to kill a channel if we have not read from
    // the channel since the last ping. However, this will need to be backwards compatible with
    // pre-6.6 nodes that DO NOT respond to pings
    if (needsKeepAlivePing(channel)) {
      sendPing(channel);
    }
  }
  this.lastPingRelativeMillis = threadPool.relativeTimeInMillis();
}

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

private void contextProcessedSuccessfully(SearchContext context) {
  context.accessed(threadPool.relativeTimeInMillis());
}

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

protected void serverAcceptedChannel(TcpChannel channel) {
  boolean addedOnThisCall = acceptedChannels.add(channel);
  assert addedOnThisCall : "Channel should only be added to accepted channel set once";
  // Mark the channel init time
  channel.getChannelStats().markAccessed(threadPool.relativeTimeInMillis());
  channel.addCloseListener(ActionListener.wrap(() -> acceptedChannels.remove(channel)));
  logger.trace(() -> new ParameterizedMessage("Tcp transport channel accepted: {}", channel));
}

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

@Override
public void maybePruneDeletes() {
  // It's expensive to prune because we walk the deletes map acquiring dirtyLock for each uid so we only do it
  // every 1/4 of gcDeletesInMillis:
  if (engineConfig.isEnableGcDeletes() &&
      engineConfig.getThreadPool().relativeTimeInMillis() - lastDeleteVersionPruneTimeMSec > getGcDeletesInMillis() * 0.25) {
    pruneDeletedTombstones();
  }
}

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

@Override
public void onResponse(Version version) {
  NodeChannels nodeChannels = new NodeChannels(node, channels, connectionProfile, version);
  long relativeMillisTime = threadPool.relativeTimeInMillis();
  nodeChannels.channels.forEach(ch -> {
    // Mark the channel init time
    ch.getChannelStats().markAccessed(relativeMillisTime);
    ch.addCloseListener(ActionListener.wrap(nodeChannels::close));
  });
  keepAlive.registerNodeConnection(nodeChannels.channels, connectionProfile);
  listener.onResponse(nodeChannels);
}

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

@Override
  public void run() {
    final long time = threadPool.relativeTimeInMillis();
    for (SearchContext context : activeContexts.values()) {
      // Use the same value for both checks since lastAccessTime can
      // be modified by another thread between checks!
      final long lastAccessTime = context.lastAccessTime();
      if (lastAccessTime == -1L) { // its being processed or timeout is disabled
        continue;
      }
      if ((time - lastAccessTime > context.keepAlive())) {
        logger.debug("freeing search context [{}], time [{}], lastAccessTime [{}], keepAlive [{}]", context.id(), time,
          lastAccessTime, context.keepAlive());
        freeContext(context.id());
      }
    }
  }
}

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

@Override
public void run() {
  if (responseHandlers.contains(requestId)) {
    long timeoutTime = threadPool.relativeTimeInMillis();
    timeoutInfoHandlers.put(requestId, new TimeoutInfoHolder(node, action, sentTime, timeoutTime));
    // now that we have the information visible via timeoutInfoHandlers, we try to remove the request id
    final Transport.ResponseContext holder = responseHandlers.remove(requestId);
    if (holder != null) {
      assert holder.action().equals(action);
      assert holder.connection().getNode().equals(node);
      holder.handler().handleException(
        new ReceiveTimeoutTransportException(holder.connection().getNode(), holder.action(),
          "request_id [" + requestId + "] timed out after [" + (timeoutTime - sentTime) + "ms]"));
    } else {
      // response was processed, remove timeout info.
      timeoutInfoHandlers.remove(requestId);
    }
  }
}

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

private void pruneDeletedTombstones() {
  /*
   * We need to deploy two different trimming strategies for GC deletes on primary and replicas. Delete operations on primary
   * are remembered for at least one GC delete cycle and trimmed periodically. This is, at the moment, the best we can do on
   * primary for user facing APIs but this arbitrary time limit is problematic for replicas. On replicas however we should
   * trim only deletes whose seqno at most the local checkpoint. This requirement is explained as follows.
   *
   * Suppose o1 and o2 are two operations on the same document with seq#(o1) < seq#(o2), and o2 arrives before o1 on the replica.
   * o2 is processed normally since it arrives first; when o1 arrives it should be discarded:
   * - If seq#(o1) <= LCP, then it will be not be added to Lucene, as it was already previously added.
   * - If seq#(o1)  > LCP, then it depends on the nature of o2:
   *   *) If o2 is a delete then its seq# is recorded in the VersionMap, since seq#(o2) > seq#(o1) > LCP,
   *      so a lookup can find it and determine that o1 is stale.
   *   *) If o2 is an indexing then its seq# is either in Lucene (if refreshed) or the VersionMap (if not refreshed yet),
   *      so a real-time lookup can find it and determine that o1 is stale.
   *
   * Here we prefer to deploy a single trimming strategy, which satisfies two constraints, on both primary and replicas because:
   * - It's simpler - no need to distinguish if an engine is running at primary mode or replica mode or being promoted.
   * - If a replica subsequently is promoted, user experience is maintained as that replica remembers deletes for the last GC cycle.
   *
   * However, the version map may consume less memory if we deploy two different trimming strategies for primary and replicas.
   */
  final long timeMSec = engineConfig.getThreadPool().relativeTimeInMillis();
  final long maxTimestampToPrune = timeMSec - engineConfig.getIndexSettings().getGcDeletesInMillis();
  versionMap.pruneTombstones(maxTimestampToPrune, localCheckpointTracker.getCheckpoint());
  lastDeleteVersionPruneTimeMSec = timeMSec;
}

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

private void checkForTimeout(long requestId) {
  // lets see if its in the timeout holder, but sync on mutex to make sure any ongoing timeout handling has finished
  final DiscoveryNode sourceNode;
  final String action;
  assert responseHandlers.contains(requestId) == false;
  TimeoutInfoHolder timeoutInfoHolder = timeoutInfoHandlers.remove(requestId);
  if (timeoutInfoHolder != null) {
    long time = threadPool.relativeTimeInMillis();
    logger.warn("Received response for a request that has timed out, sent [{}ms] ago, timed out [{}ms] ago, " +
        "action [{}], node [{}], id [{}]", time - timeoutInfoHolder.sentTime(), time - timeoutInfoHolder.timeoutTime(),
      timeoutInfoHolder.action(), timeoutInfoHolder.node(), requestId);
    action = timeoutInfoHolder.action();
    sourceNode = timeoutInfoHolder.node();
  } else {
    logger.warn("Transport response handler not found of id [{}]", requestId);
    action = null;
    sourceNode = null;
  }
  // call tracer out of lock
  if (traceEnabled() == false) {
    return;
  }
  if (action == null) {
    assert sourceNode == null;
    traceUnresolvedResponse(requestId);
  } else if (shouldTraceAction(action)) {
    traceReceivedResponse(requestId, sourceNode, action);
  }
}

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

/**
 * sends a message to the given channel, using the given callbacks.
 */
private void internalSendMessage(TcpChannel channel, BytesReference message, ActionListener<Void> listener) {
  channel.getChannelStats().markAccessed(threadPool.relativeTimeInMillis());
  transportLogger.logOutboundMessage(channel, message);
  try {
    channel.sendMessage(message, new SendListener(channel, message.length(), listener));
  } catch (Exception ex) {
    // call listener to ensure that any resources are released
    listener.onFailure(ex);
    onException(channel, ex);
  }
}

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

/**
 * Handles inbound message that has been decoded.
 *
 * @param channel the channel the message if fomr
 * @param message the message
 */
public void inboundMessage(TcpChannel channel, BytesReference message) {
  try {
    channel.getChannelStats().markAccessed(threadPool.relativeTimeInMillis());
    transportLogger.logInboundMessage(channel, message);
    // Message length of 0 is a ping
    if (message.length() != 0) {
      messageReceived(message, channel);
    } else {
      keepAlive.receiveKeepAlive(channel);
    }
  } catch (Exception e) {
    onException(channel, e);
  }
}

代码示例来源:origin: apache/servicemix-bundles

private void contextProcessedSuccessfully(SearchContext context) {
  context.accessed(threadPool.relativeTimeInMillis());
}

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

/** resolves the current version of the document, returning null if not found */
private VersionValue resolveDocVersion(final Operation op, boolean loadSeqNo) throws IOException {
  assert incrementVersionLookup(); // used for asserting in tests
  VersionValue versionValue = getVersionFromMap(op.uid().bytes());
  if (versionValue == null) {
    assert incrementIndexVersionLookup(); // used for asserting in tests
    final VersionsAndSeqNoResolver.DocIdAndVersion docIdAndVersion;
    try (Searcher searcher = acquireSearcher("load_version", SearcherScope.INTERNAL)) {
       docIdAndVersion = VersionsAndSeqNoResolver.loadDocIdAndVersion(searcher.reader(), op.uid(), loadSeqNo);
    }
    if (docIdAndVersion != null) {
      versionValue = new IndexVersionValue(null, docIdAndVersion.version, docIdAndVersion.seqNo, docIdAndVersion.primaryTerm);
    }
  } else if (engineConfig.isEnableGcDeletes() && versionValue.isDelete() &&
    (engineConfig.getThreadPool().relativeTimeInMillis() - ((DeleteVersionValue)versionValue).time) > getGcDeletesInMillis()) {
    versionValue = null;
  }
  return versionValue;
}

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

versionMap.putDeleteUnderLock(delete.uid().bytes(),
  new DeleteVersionValue(plan.versionOfDeletion, plan.seqNoOfDeletion, delete.primaryTerm(),
    engineConfig.getThreadPool().relativeTimeInMillis()));

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

private void contextProcessedSuccessfully(SearchContext context) {
  context.accessed(threadPool.relativeTimeInMillis());
}

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

boolean success = false;
try {
  this.lastDeleteVersionPruneTimeMSec = engineConfig.getThreadPool().relativeTimeInMillis();

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

private void maybePruneDeletedTombstones() {
  // It's expensive to prune because we walk the deletes map acquiring dirtyLock for each uid so we only do it
  // every 1/4 of gcDeletesInMillis:
  if (engineConfig.isEnableGcDeletes() && engineConfig.getThreadPool().relativeTimeInMillis() - lastDeleteVersionPruneTimeMSec > getGcDeletesInMillis() * 0.25) {
    pruneDeletedTombstones();
  }
}

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

@Override
public void maybePruneDeletes() {
  // It's expensive to prune because we walk the deletes map acquiring dirtyLock for each uid so we only do it
  // every 1/4 of gcDeletesInMillis:
  if (engineConfig.isEnableGcDeletes() && engineConfig.getThreadPool().relativeTimeInMillis() - lastDeleteVersionPruneTimeMSec > getGcDeletesInMillis() * 0.25) {
    pruneDeletedTombstones();
  }
}

代码示例来源:origin: com.strapdata.elasticsearch/elasticsearch

private void maybePruneDeletedTombstones() {
  // It's expensive to prune because we walk the deletes map acquiring dirtyLock for each uid so we only do it
  // every 1/4 of gcDeletesInMillis:
  if (engineConfig.isEnableGcDeletes() && engineConfig.getThreadPool().relativeTimeInMillis() - lastDeleteVersionPruneTimeMSec > getGcDeletesInMillis() * 0.25) {
    pruneDeletedTombstones();
  }
}

相关文章