/** * Connects to all remote clusters in a blocking fashion. This should be called on node startup to establish an initial connection * to all configured seed nodes. */ void initializeRemoteClusters() { final TimeValue timeValue = REMOTE_INITIAL_CONNECTION_TIMEOUT_SETTING.get(settings); final PlainActionFuture<Void> future = new PlainActionFuture<>(); Map<String, Tuple<String, List<Tuple<String, Supplier<DiscoveryNode>>>>> seeds = RemoteClusterAware.buildRemoteClustersDynamicConfig(settings); updateRemoteClusters(seeds, future); try { future.get(timeValue.millis(), TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } catch (TimeoutException ex) { logger.warn("failed to connect to remote clusters within {}", timeValue.toString()); } catch (Exception e) { throw new IllegalStateException("failed to connect to remote clusters", e); } }
@Override public void run() { if (logger.isTraceEnabled()) { logger.trace("Submitting new rescheduling cluster info update job"); } try { threadPool.executor(executorName()).execute(() -> { try { maybeRefresh(); } finally { //schedule again after we refreshed if (isMaster) { if (logger.isTraceEnabled()) { logger.trace("Scheduling next run for updating cluster info in: {}", updateFrequency.toString()); } try { threadPool.schedule(updateFrequency, executorName(), this); } catch (EsRejectedExecutionException ex) { logger.debug("Reschedule cluster info service was rejected", ex); } } } }); } catch (EsRejectedExecutionException ex) { if (logger.isDebugEnabled()) { logger.debug("Couldn't re-schedule cluster info update task - node might be shutting down", ex); } } } }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("adaptive_selection"); Set<String> allNodeIds = Sets.union(clientOutgoingConnections.keySet(), nodeComputedStats.keySet()); for (String nodeId : allNodeIds) { builder.startObject(nodeId); ResponseCollectorService.ComputedNodeStats stats = nodeComputedStats.get(nodeId); if (stats != null) { long outgoingSearches = clientOutgoingConnections.getOrDefault(nodeId, 0L); builder.field("outgoing_searches", outgoingSearches); builder.field("avg_queue_size", stats.queueSize); if (builder.humanReadable()) { builder.field("avg_service_time", new TimeValue((long) stats.serviceTime, TimeUnit.NANOSECONDS).toString()); } builder.field("avg_service_time_ns", (long) stats.serviceTime); if (builder.humanReadable()) { builder.field("avg_response_time", new TimeValue((long) stats.responseTime, TimeUnit.NANOSECONDS).toString()); } builder.field("avg_response_time_ns", (long) stats.responseTime); builder.field("rank", String.format(Locale.ROOT, "%.1f", stats.rank(outgoingSearches))); } builder.endObject(); } builder.endObject(); return builder; }
return Long.toString(v.days()); } else { return v.toString();
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(name); builder.field(Fields.TYPE, type.getType()); if (min != -1) { builder.field(Fields.MIN, min); } if (max != -1) { builder.field(Fields.MAX, max); } if (keepAlive != null) { builder.field(Fields.KEEP_ALIVE, keepAlive.toString()); } if (queueSize == null) { builder.field(Fields.QUEUE_SIZE, -1); } else { builder.field(Fields.QUEUE_SIZE, queueSize.singles()); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.field("node", taskId.getNodeId()); builder.field("id", taskId.getId()); builder.field("type", type); builder.field("action", action); if (status != null) { builder.field("status", status, params); } if (description != null) { builder.field("description", description); } builder.timeField("start_time_in_millis", "start_time", startTime); if (builder.humanReadable()) { builder.field("running_time", new TimeValue(runningTimeNanos, TimeUnit.NANOSECONDS).toString()); } builder.field("running_time_in_nanos", runningTimeNanos); builder.field("cancellable", cancellable); if (parentTaskId.isSet()) { builder.field("parent_task_id", parentTaskId.toString()); } builder.startObject("headers"); for(Map.Entry<String, String> attribute : headers.entrySet()) { builder.field(attribute.getKey(), attribute.getValue()); } builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); builder.field(TYPE.getPreferredName(), type); builder.field(DESCRIPTION.getPreferredName(), description); if (builder.humanReadable()) { builder.field(NODE_TIME.getPreferredName(), new TimeValue(getTime(), TimeUnit.NANOSECONDS).toString()); } builder.field(NODE_TIME_RAW.getPreferredName(), getTime()); builder.field(BREAKDOWN.getPreferredName(), timings); if (!children.isEmpty()) { builder = builder.startArray(CHILDREN.getPreferredName()); for (ProfileResult child : children) { builder = child.toXContent(builder, params); } builder = builder.endArray(); } builder = builder.endObject(); return builder; }
@Override public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException { builder = builder.startObject(); builder.field(NAME.getPreferredName(), getName()); builder.field(REASON.getPreferredName(), getReason()); if (builder.humanReadable()) { builder.field(TIME.getPreferredName(), new TimeValue(getTime(), TimeUnit.NANOSECONDS).toString()); } builder.field(TIME_NANOS.getPreferredName(), getTime()); if (!children.isEmpty()) { builder = builder.startArray(CHILDREN.getPreferredName()); for (CollectorResult child : children) { builder = child.toXContent(builder, params); } builder = builder.endArray(); } builder = builder.endObject(); return builder; }
/** * Sets an enum setting with the provided setting key and enum instance. * * @param key The setting key * @param enumValue The setting value * @return The builder */ public Builder put(String key, Enum<?> enumValue) { return put(key, enumValue.toString()); }
/** * Sets a time value setting with the provided setting key and value. * * @param key The setting key * @param timeValue The setting timeValue * @return The builder */ public Builder put(String key, TimeValue timeValue) { return put(key, timeValue.toString()); }
keepAlive = poolInfo.getKeepAlive().toString();
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(); }
public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, TimeValue timeValue) throws IOException { if (humanReadable) { field(readableFieldName, timeValue.toString()); } field(rawFieldName, timeValue.millis()); return this; }
public XContentBuilder timeValueField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, TimeValue timeValue) throws IOException { if (humanReadable) { field(readableFieldName, timeValue.toString()); } field(rawFieldName, timeValue.millis()); return this; }
public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, long rawTime, TimeUnit timeUnit) throws IOException { if (humanReadable) { field(readableFieldName, new TimeValue(rawTime, timeUnit).toString()); } field(rawFieldName, rawTime); return this; }
public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, long rawTime) throws IOException { if (humanReadable) { field(readableFieldName, new TimeValue(rawTime).toString()); } field(rawFieldName, rawTime); return this; }
public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, long rawTime, TimeUnit timeUnit) throws IOException { if (humanReadable) { field(readableFieldName, new TimeValue(rawTime, timeUnit).toString()); } field(rawFieldName, rawTime); return this; }
public XContentBuilder timeValueField(String rawFieldName, String readableFieldName, TimeValue timeValue) throws IOException { if (humanReadable) { field(readableFieldName, timeValue.toString()); } field(rawFieldName, timeValue.millis()); return this; }
public XContentBuilder timeValueField(XContentBuilderString rawFieldName, XContentBuilderString readableFieldName, long rawTime) throws IOException { if (humanReadable) { field(readableFieldName, new TimeValue(rawTime).toString()); } field(rawFieldName, rawTime); return this; }
private void registerBackfillMetrics() { Metrics.gauge("backfill", () -> () -> totalBackfillItems); // memoize so the backfill per partition isn't logged twice every time the stats are reported final Supplier<Long> remainingBackfillItemsSupplier = Suppliers.memoizeWithExpiration(() -> { if (remainingBackfillItems != 0) { updateBackfillProgress(); } return remainingBackfillItems; }, 250, TimeUnit.MILLISECONDS); final Gauge backfillRemainingGauge = Metrics.gauge("backfillRemaining", () -> remainingBackfillItemsSupplier::get); Metrics.gauge("backfillEstTimeLeft", () -> () -> { final long remaining = (long) backfillRemainingGauge.getValue(); return new TimeValue((long) (remaining * Metrics.indexTimePerDocument().getSnapshot().getMean()), TimeUnit.NANOSECONDS).toString(); }); }