/** * Adjust the for all other nodes' collected stats. In the original ranking paper there is no need to adjust other nodes' stats because * Cassandra sends occasional requests to all copies of the data, so their stats will be updated during that broadcast phase. In * Elasticsearch, however, we do not have that sort of broadcast-to-all behavior. In order to prevent a node that gets a high score and * then never gets any more requests, we must ensure it eventually returns to a more normal score and can be a candidate for serving * requests. * * This adjustment takes the "winning" node's statistics and adds the average of those statistics with each non-winning node. Let's say * the winning node had a queue size of 10 and a non-winning node had a queue of 18. The average queue size is (10 + 18) / 2 = 14 so the * non-winning node will have statistics added for a queue size of 14. This is repeated for the response time and service times as well. */ private static void adjustStats(final ResponseCollectorService collector, final Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> nodeStats, final String minNodeId, final ResponseCollectorService.ComputedNodeStats minStats) { if (minNodeId != null) { for (Map.Entry<String, Optional<ResponseCollectorService.ComputedNodeStats>> entry : nodeStats.entrySet()) { final String nodeId = entry.getKey(); final Optional<ResponseCollectorService.ComputedNodeStats> maybeStats = entry.getValue(); if (nodeId.equals(minNodeId) == false && maybeStats.isPresent()) { final ResponseCollectorService.ComputedNodeStats stats = maybeStats.get(); final int updatedQueue = (minStats.queueSize + stats.queueSize) / 2; final long updatedResponse = (long) (minStats.responseTime + stats.responseTime) / 2; final long updatedService = (long) (minStats.serviceTime + stats.serviceTime) / 2; collector.addNodeStatistics(nodeId, updatedQueue, updatedResponse, updatedService); } } } }
public AdaptiveSelectionStats getAdaptiveStats(Map<String, Long> clientSearchConnections) { return new AdaptiveSelectionStats(clientSearchConnections, getAllNodeStatistics()); }
private static Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> getNodeStats(final Set<String> nodeIds, final ResponseCollectorService collector) { final Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> nodeStats = new HashMap<>(nodeIds.size()); for (String nodeId : nodeIds) { nodeStats.put(nodeId, collector.getNodeStatistics(nodeId)); } return nodeStats; }
@Override public void clusterChanged(ClusterChangedEvent event) { if (event.nodesRemoved()) { for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) { removeNode(removedNode.getId()); } } }
public NodeStats stats(CommonStatsFlags indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean fs, boolean transport, boolean http, boolean circuitBreaker, boolean script, boolean discoveryStats, boolean ingest, boolean adaptiveSelection) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) return new NodeStats(transportService.getLocalNode(), System.currentTimeMillis(), indices.anySet() ? indicesService.stats(true, indices) : null, os ? monitorService.osService().stats() : null, process ? monitorService.processService().stats() : null, jvm ? monitorService.jvmService().stats() : null, threadPool ? this.threadPool.stats() : null, fs ? monitorService.fsService().stats() : null, transport ? transportService.stats() : null, http ? (httpServerTransport == null ? null : httpServerTransport.stats()) : null, circuitBreaker ? circuitBreakerService.stats() : null, script ? scriptService.stats() : null, discoveryStats ? discovery.stats() : null, ingest ? ingestService.stats() : null, adaptiveSelection ? responseCollectorService.getAdaptiveStats(searchTransportService.getPendingSearchRequests()) : null ); }
final TransportService transportService = newTransportService(settings, transport, threadPool, networkModule.getTransportInterceptor(), localNodeFactory, settingsModule.getClusterSettings(), taskHeaders); final ResponseCollectorService responseCollectorService = new ResponseCollectorService(clusterService); final SearchTransportService searchTransportService = new SearchTransportService(transportService, SearchExecutionStatsCollector.makeWrapper(responseCollectorService));
@Override public void clusterChanged(ClusterChangedEvent event) { if (event.nodesRemoved()) { for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) { removeNode(removedNode.getId()); } } }
public NodeStats stats(CommonStatsFlags indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean fs, boolean transport, boolean http, boolean circuitBreaker, boolean script, boolean discoveryStats, boolean ingest, boolean adaptiveSelection) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) return new NodeStats(transportService.getLocalNode(), System.currentTimeMillis(), indices.anySet() ? indicesService.stats(true, indices) : null, os ? monitorService.osService().stats() : null, process ? monitorService.processService().stats() : null, jvm ? monitorService.jvmService().stats() : null, threadPool ? this.threadPool.stats() : null, fs ? monitorService.fsService().stats() : null, transport ? transportService.stats() : null, http ? (httpServerTransport == null ? null : httpServerTransport.stats()) : null, circuitBreaker ? circuitBreakerService.stats() : null, script ? scriptService.stats() : null, discoveryStats ? discovery.stats() : null, ingest ? ingestService.getPipelineExecutionService().stats() : null, adaptiveSelection ? responseCollectorService.getAdaptiveStats(searchTransportService.getPendingSearchRequests()) : null ); }
final TransportService transportService = newTransportService(settings, transport, threadPool, networkModule.getTransportInterceptor(), localNodeFactory, settingsModule.getClusterSettings(), taskHeaders); final ResponseCollectorService responseCollectorService = new ResponseCollectorService(this.settings, clusterService); final SearchTransportService searchTransportService = new SearchTransportService(settings, transportService, SearchExecutionStatsCollector.makeWrapper(responseCollectorService));
@Override public void onResponse(SearchPhaseResult response) { QuerySearchResult queryResult = response.queryResult(); if (nodeId != null && queryResult != null) { final long serviceTimeEWMA = queryResult.serviceTimeEWMA(); final int queueSize = queryResult.nodeQueueSize(); final long responseDuration = System.nanoTime() - startNanos; // EWMA/queue size may be -1 if the query node doesn't support capturing it if (serviceTimeEWMA > 0 && queueSize >= 0) { collector.addNodeStatistics(nodeId, queueSize, responseDuration, serviceTimeEWMA); } } listener.onResponse(response); }
private static Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> getNodeStats(final Set<String> nodeIds, final ResponseCollectorService collector) { final Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> nodeStats = new HashMap<>(nodeIds.size()); for (String nodeId : nodeIds) { nodeStats.put(nodeId, collector.getNodeStatistics(nodeId)); } return nodeStats; }
@Override public void clusterChanged(ClusterChangedEvent event) { if (event.nodesRemoved()) { for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) { removeNode(removedNode.getId()); } } }
public AdaptiveSelectionStats getAdaptiveStats(Map<String, Long> clientSearchConnections) { return new AdaptiveSelectionStats(clientSearchConnections, getAllNodeStatistics()); }
public NodeStats stats(CommonStatsFlags indices, boolean os, boolean process, boolean jvm, boolean threadPool, boolean fs, boolean transport, boolean http, boolean circuitBreaker, boolean script, boolean discoveryStats, boolean ingest, boolean adaptiveSelection) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) return new NodeStats(transportService.getLocalNode(), System.currentTimeMillis(), indices.anySet() ? indicesService.stats(true, indices) : null, os ? monitorService.osService().stats() : null, process ? monitorService.processService().stats() : null, jvm ? monitorService.jvmService().stats() : null, threadPool ? this.threadPool.stats() : null, fs ? monitorService.fsService().stats() : null, transport ? transportService.stats() : null, http ? (httpServerTransport == null ? null : httpServerTransport.stats()) : null, circuitBreaker ? circuitBreakerService.stats() : null, script ? scriptService.stats() : null, discoveryStats ? discovery.stats() : null, ingest ? ingestService.stats() : null, adaptiveSelection ? responseCollectorService.getAdaptiveStats(searchTransportService.getPendingSearchRequests()) : null ); }
final TransportService transportService = newTransportService(settings, transport, threadPool, networkModule.getTransportInterceptor(), localNodeFactory, settingsModule.getClusterSettings(), taskHeaders); final ResponseCollectorService responseCollectorService = new ResponseCollectorService(this.settings, clusterService); final SearchTransportService searchTransportService = new SearchTransportService(settings, transportService, SearchExecutionStatsCollector.makeWrapper(responseCollectorService));
/** * Adjust the for all other nodes' collected stats. In the original ranking paper there is no need to adjust other nodes' stats because * Cassandra sends occasional requests to all copies of the data, so their stats will be updated during that broadcast phase. In * Elasticsearch, however, we do not have that sort of broadcast-to-all behavior. In order to prevent a node that gets a high score and * then never gets any more requests, we must ensure it eventually returns to a more normal score and can be a candidate for serving * requests. * * This adjustment takes the "winning" node's statistics and adds the average of those statistics with each non-winning node. Let's say * the winning node had a queue size of 10 and a non-winning node had a queue of 18. The average queue size is (10 + 18) / 2 = 14 so the * non-winning node will have statistics added for a queue size of 14. This is repeated for the response time and service times as well. */ private static void adjustStats(final ResponseCollectorService collector, final Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> nodeStats, final String minNodeId, final ResponseCollectorService.ComputedNodeStats minStats) { if (minNodeId != null) { for (Map.Entry<String, Optional<ResponseCollectorService.ComputedNodeStats>> entry : nodeStats.entrySet()) { final String nodeId = entry.getKey(); final Optional<ResponseCollectorService.ComputedNodeStats> maybeStats = entry.getValue(); if (nodeId.equals(minNodeId) == false && maybeStats.isPresent()) { final ResponseCollectorService.ComputedNodeStats stats = maybeStats.get(); final int updatedQueue = (minStats.queueSize + stats.queueSize) / 2; final long updatedResponse = (long) (minStats.responseTime + stats.responseTime) / 2; final long updatedService = (long) (minStats.serviceTime + stats.serviceTime) / 2; collector.addNodeStatistics(nodeId, updatedQueue, updatedResponse, updatedService); } } } }
private static Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> getNodeStats(final Set<String> nodeIds, final ResponseCollectorService collector) { final Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> nodeStats = new HashMap<>(nodeIds.size()); for (String nodeId : nodeIds) { nodeStats.put(nodeId, collector.getNodeStatistics(nodeId)); } return nodeStats; }
public AdaptiveSelectionStats getAdaptiveStats(Map<String, Long> clientSearchConnections) { return new AdaptiveSelectionStats(clientSearchConnections, getAllNodeStatistics()); }
/** * Adjust the for all other nodes' collected stats. In the original ranking paper there is no need to adjust other nodes' stats because * Cassandra sends occasional requests to all copies of the data, so their stats will be updated during that broadcast phase. In * Elasticsearch, however, we do not have that sort of broadcast-to-all behavior. In order to prevent a node that gets a high score and * then never gets any more requests, we must ensure it eventually returns to a more normal score and can be a candidate for serving * requests. * * This adjustment takes the "winning" node's statistics and adds the average of those statistics with each non-winning node. Let's say * the winning node had a queue size of 10 and a non-winning node had a queue of 18. The average queue size is (10 + 18) / 2 = 14 so the * non-winning node will have statistics added for a queue size of 14. This is repeated for the response time and service times as well. */ private static void adjustStats(final ResponseCollectorService collector, final Map<String, Optional<ResponseCollectorService.ComputedNodeStats>> nodeStats, final String minNodeId, final ResponseCollectorService.ComputedNodeStats minStats) { if (minNodeId != null) { for (Map.Entry<String, Optional<ResponseCollectorService.ComputedNodeStats>> entry : nodeStats.entrySet()) { final String nodeId = entry.getKey(); final Optional<ResponseCollectorService.ComputedNodeStats> maybeStats = entry.getValue(); if (nodeId.equals(minNodeId) == false && maybeStats.isPresent()) { final ResponseCollectorService.ComputedNodeStats stats = maybeStats.get(); final int updatedQueue = (minStats.queueSize + stats.queueSize) / 2; final long updatedResponse = (long) (minStats.responseTime + stats.responseTime) / 2; final long updatedService = (long) (minStats.serviceTime + stats.serviceTime) / 2; collector.addNodeStatistics(nodeId, updatedQueue, updatedResponse, updatedService); } } } }
@Override public void onResponse(SearchPhaseResult response) { QuerySearchResult queryResult = response.queryResult(); if (nodeId != null && queryResult != null) { final long serviceTimeEWMA = queryResult.serviceTimeEWMA(); final int queueSize = queryResult.nodeQueueSize(); final long responseDuration = System.nanoTime() - startNanos; // EWMA/queue size may be -1 if the query node doesn't support capturing it if (serviceTimeEWMA > 0 && queueSize >= 0) { collector.addNodeStatistics(nodeId, queueSize, responseDuration, serviceTimeEWMA); } } listener.onResponse(response); }