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

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

本文整理了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

  1. private ScheduledPing(TimeValue pingInterval) {
  2. super(lifecycle, logger);
  3. this.pingInterval = pingInterval;
  4. this.lastPingRelativeMillis = threadPool.relativeTimeInMillis();
  5. }

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

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

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

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

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

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

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

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

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

  1. @Override
  2. public void onResponse(Version version) {
  3. NodeChannels nodeChannels = new NodeChannels(node, channels, connectionProfile, version);
  4. long relativeMillisTime = threadPool.relativeTimeInMillis();
  5. nodeChannels.channels.forEach(ch -> {
  6. // Mark the channel init time
  7. ch.getChannelStats().markAccessed(relativeMillisTime);
  8. ch.addCloseListener(ActionListener.wrap(nodeChannels::close));
  9. });
  10. keepAlive.registerNodeConnection(nodeChannels.channels, connectionProfile);
  11. listener.onResponse(nodeChannels);
  12. }

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

  1. @Override
  2. public void run() {
  3. final long time = threadPool.relativeTimeInMillis();
  4. for (SearchContext context : activeContexts.values()) {
  5. // Use the same value for both checks since lastAccessTime can
  6. // be modified by another thread between checks!
  7. final long lastAccessTime = context.lastAccessTime();
  8. if (lastAccessTime == -1L) { // its being processed or timeout is disabled
  9. continue;
  10. }
  11. if ((time - lastAccessTime > context.keepAlive())) {
  12. logger.debug("freeing search context [{}], time [{}], lastAccessTime [{}], keepAlive [{}]", context.id(), time,
  13. lastAccessTime, context.keepAlive());
  14. freeContext(context.id());
  15. }
  16. }
  17. }
  18. }

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

  1. @Override
  2. public void run() {
  3. if (responseHandlers.contains(requestId)) {
  4. long timeoutTime = threadPool.relativeTimeInMillis();
  5. timeoutInfoHandlers.put(requestId, new TimeoutInfoHolder(node, action, sentTime, timeoutTime));
  6. // now that we have the information visible via timeoutInfoHandlers, we try to remove the request id
  7. final Transport.ResponseContext holder = responseHandlers.remove(requestId);
  8. if (holder != null) {
  9. assert holder.action().equals(action);
  10. assert holder.connection().getNode().equals(node);
  11. holder.handler().handleException(
  12. new ReceiveTimeoutTransportException(holder.connection().getNode(), holder.action(),
  13. "request_id [" + requestId + "] timed out after [" + (timeoutTime - sentTime) + "ms]"));
  14. } else {
  15. // response was processed, remove timeout info.
  16. timeoutInfoHandlers.remove(requestId);
  17. }
  18. }
  19. }

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

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

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

  1. private void checkForTimeout(long requestId) {
  2. // lets see if its in the timeout holder, but sync on mutex to make sure any ongoing timeout handling has finished
  3. final DiscoveryNode sourceNode;
  4. final String action;
  5. assert responseHandlers.contains(requestId) == false;
  6. TimeoutInfoHolder timeoutInfoHolder = timeoutInfoHandlers.remove(requestId);
  7. if (timeoutInfoHolder != null) {
  8. long time = threadPool.relativeTimeInMillis();
  9. logger.warn("Received response for a request that has timed out, sent [{}ms] ago, timed out [{}ms] ago, " +
  10. "action [{}], node [{}], id [{}]", time - timeoutInfoHolder.sentTime(), time - timeoutInfoHolder.timeoutTime(),
  11. timeoutInfoHolder.action(), timeoutInfoHolder.node(), requestId);
  12. action = timeoutInfoHolder.action();
  13. sourceNode = timeoutInfoHolder.node();
  14. } else {
  15. logger.warn("Transport response handler not found of id [{}]", requestId);
  16. action = null;
  17. sourceNode = null;
  18. }
  19. // call tracer out of lock
  20. if (traceEnabled() == false) {
  21. return;
  22. }
  23. if (action == null) {
  24. assert sourceNode == null;
  25. traceUnresolvedResponse(requestId);
  26. } else if (shouldTraceAction(action)) {
  27. traceReceivedResponse(requestId, sourceNode, action);
  28. }
  29. }

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

  1. /**
  2. * sends a message to the given channel, using the given callbacks.
  3. */
  4. private void internalSendMessage(TcpChannel channel, BytesReference message, ActionListener<Void> listener) {
  5. channel.getChannelStats().markAccessed(threadPool.relativeTimeInMillis());
  6. transportLogger.logOutboundMessage(channel, message);
  7. try {
  8. channel.sendMessage(message, new SendListener(channel, message.length(), listener));
  9. } catch (Exception ex) {
  10. // call listener to ensure that any resources are released
  11. listener.onFailure(ex);
  12. onException(channel, ex);
  13. }
  14. }

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

  1. /**
  2. * Handles inbound message that has been decoded.
  3. *
  4. * @param channel the channel the message if fomr
  5. * @param message the message
  6. */
  7. public void inboundMessage(TcpChannel channel, BytesReference message) {
  8. try {
  9. channel.getChannelStats().markAccessed(threadPool.relativeTimeInMillis());
  10. transportLogger.logInboundMessage(channel, message);
  11. // Message length of 0 is a ping
  12. if (message.length() != 0) {
  13. messageReceived(message, channel);
  14. } else {
  15. keepAlive.receiveKeepAlive(channel);
  16. }
  17. } catch (Exception e) {
  18. onException(channel, e);
  19. }
  20. }

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

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

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

  1. /** resolves the current version of the document, returning null if not found */
  2. private VersionValue resolveDocVersion(final Operation op, boolean loadSeqNo) throws IOException {
  3. assert incrementVersionLookup(); // used for asserting in tests
  4. VersionValue versionValue = getVersionFromMap(op.uid().bytes());
  5. if (versionValue == null) {
  6. assert incrementIndexVersionLookup(); // used for asserting in tests
  7. final VersionsAndSeqNoResolver.DocIdAndVersion docIdAndVersion;
  8. try (Searcher searcher = acquireSearcher("load_version", SearcherScope.INTERNAL)) {
  9. docIdAndVersion = VersionsAndSeqNoResolver.loadDocIdAndVersion(searcher.reader(), op.uid(), loadSeqNo);
  10. }
  11. if (docIdAndVersion != null) {
  12. versionValue = new IndexVersionValue(null, docIdAndVersion.version, docIdAndVersion.seqNo, docIdAndVersion.primaryTerm);
  13. }
  14. } else if (engineConfig.isEnableGcDeletes() && versionValue.isDelete() &&
  15. (engineConfig.getThreadPool().relativeTimeInMillis() - ((DeleteVersionValue)versionValue).time) > getGcDeletesInMillis()) {
  16. versionValue = null;
  17. }
  18. return versionValue;
  19. }

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

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

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

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

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

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

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

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

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

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

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

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

相关文章