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); }
public synchronized TimeValue targetThrottling() { return TimeValue.timeValueNanos(targetThrottleTimeInNanos); }
public synchronized TimeValue sourceThrottling() { return TimeValue.timeValueNanos(sourceThrottlingInNanos); }
/** * 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)); } }
/** * Total time recoveries waited due to throttling */ public TimeValue throttleTime() { return TimeValue.timeValueNanos(throttleTimeInNanos.get()); }
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))); }
@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(", "); }
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); }
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); }
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()); }
/** * 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); }
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("], ");
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); }
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("], ");
/** * 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); } } }
removeTaskAndCancel(); } else { TimeValue nextDelay = TimeValue.timeValueNanos(nextDelayNanos); final boolean earlierRerouteNeeded; DelayedRerouteTask existingTask = delayedRerouteTask.get(); TimeValue.timeValueNanos(existingTask.scheduledTimeToRunInNanos() - newTask.scheduledTimeToRunInNanos())); existingTask.cancelScheduling(); earlierRerouteNeeded = true;
"warmed global ordinals for [{}], took [{}]", fieldType.name(), TimeValue.timeValueNanos(System.nanoTime() - start));
@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); } } }
@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)); }
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(); }