|
36 | 36 | */ |
37 | 37 | public class WriteLoadConstraintMonitor { |
38 | 38 | private static final Logger logger = LogManager.getLogger(WriteLoadConstraintMonitor.class); |
| 39 | + private static final int MAX_NODE_IDS_IN_MESSAGE = 3; |
39 | 40 | private final WriteLoadConstraintSettings writeLoadConstraintSettings; |
40 | 41 | private final Supplier<ClusterState> clusterStateSupplier; |
41 | 42 | private final LongSupplier currentTimeMillisSupplier; |
@@ -116,26 +117,33 @@ public void onNewInfo(ClusterInfo clusterInfo) { |
116 | 117 |
|
117 | 118 | if (haveCalledRerouteRecently == false |
118 | 119 | || Sets.difference(nodeIdsExceedingLatencyThreshold, lastSetOfHotSpottedNodes).isEmpty() == false) { |
119 | | - callReroute(nodeIdsExceedingLatencyThreshold); |
| 120 | + final String reason = Strings.format( |
| 121 | + "write load constraint monitor: " |
| 122 | + + "Found %s exceeding the write thread pool queue latency threshold (%s below utilization threshold, %d total)", |
| 123 | + nodeSummary(nodeIdsExceedingLatencyThreshold), |
| 124 | + nodeSummary(nodeIdsBelowUtilizationThreshold), |
| 125 | + state.nodes().size() |
| 126 | + ); |
| 127 | + rerouteService.reroute( |
| 128 | + reason, |
| 129 | + Priority.NORMAL, |
| 130 | + ActionListener.wrap( |
| 131 | + ignored -> logger.trace("{} reroute successful", reason), |
| 132 | + e -> logger.debug(() -> Strings.format("reroute failed, reason: %s", reason), e) |
| 133 | + ) |
| 134 | + ); |
| 135 | + lastRerouteTimeMillis = currentTimeMillisSupplier.getAsLong(); |
| 136 | + lastSetOfHotSpottedNodes = nodeIdsExceedingLatencyThreshold; |
120 | 137 | } else { |
121 | 138 | logger.debug("Not calling reroute because we called reroute recently and there are no new hot spots"); |
122 | 139 | } |
123 | 140 | } |
124 | 141 |
|
125 | | - private void callReroute(Set<String> hotSpottedNodes) { |
126 | | - final String reason = Strings.format( |
127 | | - "write load constraint monitor: Found %d node(s) exceeding the write thread pool queue latency threshold", |
128 | | - hotSpottedNodes.size() |
129 | | - ); |
130 | | - rerouteService.reroute( |
131 | | - reason, |
132 | | - Priority.NORMAL, |
133 | | - ActionListener.wrap( |
134 | | - ignored -> logger.trace("{} reroute successful", reason), |
135 | | - e -> logger.debug(() -> Strings.format("reroute failed, reason: %s", reason), e) |
136 | | - ) |
137 | | - ); |
138 | | - lastRerouteTimeMillis = currentTimeMillisSupplier.getAsLong(); |
139 | | - lastSetOfHotSpottedNodes = hotSpottedNodes; |
| 142 | + private static String nodeSummary(Set<String> nodeIds) { |
| 143 | + if (nodeIds.size() < MAX_NODE_IDS_IN_MESSAGE) { |
| 144 | + return "[" + String.join(", ", nodeIds) + "]"; |
| 145 | + } else { |
| 146 | + return nodeIds.size() + " nodes"; |
| 147 | + } |
140 | 148 | } |
141 | 149 | } |
0 commit comments