99
1010package org .elasticsearch .cluster .routing .allocation .allocator ;
1111
12+ import org .elasticsearch .cluster .routing .allocation .allocator .BalancingRoundSummary .NodesWeightsChanges ;
1213import org .elasticsearch .telemetry .metric .DoubleWithAttributes ;
1314import org .elasticsearch .telemetry .metric .LongWithAttributes ;
1415import org .elasticsearch .telemetry .metric .MeterRegistry ;
1516
16- import org .elasticsearch .cluster .routing .allocation .allocator .BalancingRoundSummary .NodesWeightsChanges ;
17-
1817import java .util .ArrayList ;
19- import java .util .Collection ;
2018import java .util .Collections ;
2119import java .util .List ;
2220import java .util .Map ;
2321import java .util .concurrent .atomic .AtomicReference ;
24- import java .util .function .Supplier ;
25- import java .util .function .ToLongFunction ;
2622
2723/**
2824 * A telemetry metrics sender for {@link BalancingRoundSummary.CombinedBalancingRoundSummary}
@@ -70,57 +66,27 @@ public AllocationBalancingRoundMetrics(MeterRegistry meterRegistry) {
7066 this ::getShardMoves
7167 );
7268
73- meterRegistry .registerLongsGauge (
74- NUMBER_OF_SHARDS_METRIC_NAME ,
75- "Current number of shards" ,
76- "unit" ,
77- this ::getShardCount
78- );
69+ meterRegistry .registerLongsGauge (NUMBER_OF_SHARDS_METRIC_NAME , "Current number of shards" , "unit" , this ::getShardCount );
7970 meterRegistry .registerLongsGauge (
8071 NUMBER_OF_SHARDS_DELTA_METRIC_NAME ,
8172 "Current number of shard moves" ,
8273 "{shard}" ,
8374 this ::getShardCountDelta
8475 );
8576
86- meterRegistry .registerDoublesGauge (
87- DISK_USAGE_BYTES_METRIC_NAME ,
88- "Disk usage in bytes" ,
89- "unit" ,
90- this ::getDiskUsage
91- );
77+ meterRegistry .registerDoublesGauge (DISK_USAGE_BYTES_METRIC_NAME , "Disk usage in bytes" , "unit" , this ::getDiskUsage );
9278 meterRegistry .registerDoublesGauge (
9379 DISK_USAGE_BYTES_DELTA_METRIC_NAME ,
9480 "Disk usage delta in bytes" ,
9581 "{shard}" ,
9682 this ::getDiskUsageDelta
9783 );
9884
99- meterRegistry .registerDoublesGauge (
100- WRITE_LOAD_METRIC_NAME ,
101- "Write load" ,
102- "1.0" ,
103- this ::getWriteLoad
104- );
105- meterRegistry .registerDoublesGauge (
106- WRITE_LOAD_DELTA_METRIC_NAME ,
107- "Write load" ,
108- "1.0" ,
109- this ::getWriteLoadDelta
110- );
85+ meterRegistry .registerDoublesGauge (WRITE_LOAD_METRIC_NAME , "Write load" , "1.0" , this ::getWriteLoad );
86+ meterRegistry .registerDoublesGauge (WRITE_LOAD_DELTA_METRIC_NAME , "Write load" , "1.0" , this ::getWriteLoadDelta );
11187
112- meterRegistry .registerDoublesGauge (
113- TOTAL_WEIGHT_METRIC_NAME ,
114- "Total weight" ,
115- "1.0" ,
116- this ::getTotalWeight
117- );
118- meterRegistry .registerDoublesGauge (
119- TOTAL_WEIGHT_DELTA_METRIC_NAME ,
120- "Total weight delta" ,
121- "1.0" ,
122- this ::getTotalWeightDelta
123- );
88+ meterRegistry .registerDoublesGauge (TOTAL_WEIGHT_METRIC_NAME , "Total weight" , "1.0" , this ::getTotalWeight );
89+ meterRegistry .registerDoublesGauge (TOTAL_WEIGHT_DELTA_METRIC_NAME , "Total weight delta" , "1.0" , this ::getTotalWeightDelta );
12490 }
12591
12692 public void updateRoundMetrics (BalancingRoundSummary .CombinedBalancingRoundSummary summary ) {
@@ -176,7 +142,9 @@ private List<LongWithAttributes> getShardCountDelta() {
176142 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
177143 List <LongWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
178144 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
179- metrics .add (new LongWithAttributes (nodeWeights .getValue ().weightsDiff ().shardCountDiff (), getNodeAttributes (nodeWeights .getKey ())));
145+ metrics .add (
146+ new LongWithAttributes (nodeWeights .getValue ().weightsDiff ().shardCountDiff (), getNodeAttributes (nodeWeights .getKey ()))
147+ );
180148 }
181149 return metrics ;
182150 }
@@ -190,7 +158,9 @@ private List<DoubleWithAttributes> getDiskUsage() {
190158 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
191159 List <DoubleWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
192160 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
193- metrics .add (new DoubleWithAttributes (nodeWeights .getValue ().baseWeights ().diskUsageInBytes (), getNodeAttributes (nodeWeights .getKey ())));
161+ metrics .add (
162+ new DoubleWithAttributes (nodeWeights .getValue ().baseWeights ().diskUsageInBytes (), getNodeAttributes (nodeWeights .getKey ()))
163+ );
194164 }
195165 return metrics ;
196166 }
@@ -204,7 +174,12 @@ private List<DoubleWithAttributes> getDiskUsageDelta() {
204174 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
205175 List <DoubleWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
206176 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
207- metrics .add (new DoubleWithAttributes (nodeWeights .getValue ().weightsDiff ().diskUsageInBytesDiff (), getNodeAttributes (nodeWeights .getKey ())));
177+ metrics .add (
178+ new DoubleWithAttributes (
179+ nodeWeights .getValue ().weightsDiff ().diskUsageInBytesDiff (),
180+ getNodeAttributes (nodeWeights .getKey ())
181+ )
182+ );
208183 }
209184 return metrics ;
210185 }
@@ -218,7 +193,9 @@ private List<DoubleWithAttributes> getWriteLoad() {
218193 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
219194 List <DoubleWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
220195 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
221- metrics .add (new DoubleWithAttributes (nodeWeights .getValue ().baseWeights ().writeLoad (), getNodeAttributes (nodeWeights .getKey ())));
196+ metrics .add (
197+ new DoubleWithAttributes (nodeWeights .getValue ().baseWeights ().writeLoad (), getNodeAttributes (nodeWeights .getKey ()))
198+ );
222199 }
223200 return metrics ;
224201 }
@@ -232,7 +209,9 @@ private List<DoubleWithAttributes> getWriteLoadDelta() {
232209 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
233210 List <DoubleWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
234211 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
235- metrics .add (new DoubleWithAttributes (nodeWeights .getValue ().weightsDiff ().writeLoadDiff (), getNodeAttributes (nodeWeights .getKey ())));
212+ metrics .add (
213+ new DoubleWithAttributes (nodeWeights .getValue ().weightsDiff ().writeLoadDiff (), getNodeAttributes (nodeWeights .getKey ()))
214+ );
236215 }
237216 return metrics ;
238217 }
@@ -246,7 +225,9 @@ private List<DoubleWithAttributes> getTotalWeight() {
246225 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
247226 List <DoubleWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
248227 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
249- metrics .add (new DoubleWithAttributes (nodeWeights .getValue ().baseWeights ().nodeWeight (), getNodeAttributes (nodeWeights .getKey ())));
228+ metrics .add (
229+ new DoubleWithAttributes (nodeWeights .getValue ().baseWeights ().nodeWeight (), getNodeAttributes (nodeWeights .getKey ()))
230+ );
250231 }
251232 return metrics ;
252233 }
@@ -260,7 +241,9 @@ private List<DoubleWithAttributes> getTotalWeightDelta() {
260241 Map <String , NodesWeightsChanges > nodeNameToWeightChanges = combinedSummary .nodeNameToWeightChanges ();
261242 List <DoubleWithAttributes > metrics = new ArrayList <>(nodeNameToWeightChanges .size ());
262243 for (var nodeWeights : nodeNameToWeightChanges .entrySet ()) {
263- metrics .add (new DoubleWithAttributes (nodeWeights .getValue ().weightsDiff ().totalWeightDiff (), getNodeAttributes (nodeWeights .getKey ())));
244+ metrics .add (
245+ new DoubleWithAttributes (nodeWeights .getValue ().weightsDiff ().totalWeightDiff (), getNodeAttributes (nodeWeights .getKey ()))
246+ );
264247 }
265248 return metrics ;
266249 }
0 commit comments