From 0236df00d24c639797bf74a171ee093a0a0844f9 Mon Sep 17 00:00:00 2001 From: Dianna Hohensee Date: Thu, 10 Jul 2025 08:24:55 -0700 Subject: [PATCH] Create a Builder for ClusterInfo --- .../elasticsearch/cluster/ClusterInfo.java | 68 +++++++++++++++++++ .../ExpectedShardSizeEstimatorTests.java | 11 +-- .../AllocationStatsServiceTests.java | 13 +--- .../allocation/DiskThresholdMonitorTests.java | 2 +- .../ExpectedShardSizeAllocationTests.java | 23 +++---- .../BalancedShardsAllocatorTests.java | 27 +++----- .../ClusterAllocationSimulationTests.java | 7 +- .../allocator/ClusterBalanceStatsTests.java | 33 ++++----- .../allocator/ClusterInfoSimulatorTests.java | 16 ++--- .../DesiredBalanceComputerTests.java | 14 +++- .../DiskThresholdDeciderUnitTests.java | 30 +++----- ...oscalingCalculateCapacityServiceTests.java | 4 +- .../FrozenStorageDeciderServiceTests.java | 2 +- .../ProactiveStorageDeciderServiceTests.java | 2 +- .../ReactiveStorageDeciderServiceTests.java | 8 ++- ...nsportNodeDeprecationCheckActionTests.java | 13 +--- 16 files changed, 154 insertions(+), 119 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java b/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java index 7c627638e9b0b..6d11700500c24 100644 --- a/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java +++ b/server/src/main/java/org/elasticsearch/cluster/ClusterInfo.java @@ -452,4 +452,72 @@ public Builder add(ShardId shardId, long reservedBytes) { } } } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private Map leastAvailableSpaceUsage = Map.of(); + private Map mostAvailableSpaceUsage = Map.of(); + private Map shardSizes = Map.of(); + private Map shardDataSetSizes = Map.of(); + private Map dataPath = Map.of(); + private Map reservedSpace = Map.of(); + private Map estimatedHeapUsages = Map.of(); + private Map nodeUsageStatsForThreadPools = Map.of(); + + public ClusterInfo build() { + return new ClusterInfo( + leastAvailableSpaceUsage, + mostAvailableSpaceUsage, + shardSizes, + shardDataSetSizes, + dataPath, + reservedSpace, + estimatedHeapUsages, + nodeUsageStatsForThreadPools + ); + } + + public Builder leastAvailableSpaceUsage(Map leastAvailableSpaceUsage) { + this.leastAvailableSpaceUsage = leastAvailableSpaceUsage; + return this; + } + + public Builder mostAvailableSpaceUsage(Map mostAvailableSpaceUsage) { + this.mostAvailableSpaceUsage = mostAvailableSpaceUsage; + return this; + } + + public Builder shardSizes(Map shardSizes) { + this.shardSizes = shardSizes; + return this; + } + + public Builder shardDataSetSizes(Map shardDataSetSizes) { + this.shardDataSetSizes = shardDataSetSizes; + return this; + } + + public Builder dataPath(Map dataPath) { + this.dataPath = dataPath; + return this; + } + + public Builder reservedSpace(Map reservedSpace) { + this.reservedSpace = reservedSpace; + return this; + } + + public Builder estimatedHeapUsages(Map estimatedHeapUsages) { + this.estimatedHeapUsages = estimatedHeapUsages; + return this; + } + + public Builder nodeUsageStatsForThreadPools(Map nodeUsageStatsForThreadPools) { + this.nodeUsageStatsForThreadPools = nodeUsageStatsForThreadPools; + return this; + } + } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java index 96e277284a659..fcc372a53f517 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/ExpectedShardSizeEstimatorTests.java @@ -199,16 +199,7 @@ private static Metadata metadata(IndexMetadata.Builder... indices) { } private static ClusterInfo createClusterInfo(ShardRouting shard, Long size) { - return new ClusterInfo( - Map.of(), - Map.of(), - Map.of(ClusterInfo.shardIdentifierFromRouting(shard), size), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + return ClusterInfo.builder().shardSizes(Map.of(ClusterInfo.shardIdentifierFromRouting(shard), size)).build(); } private ClusterState buildRoutingTable(ClusterState state) { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationStatsServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationStatsServiceTests.java index 8b54cecb29580..4ce195721b228 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationStatsServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/AllocationStatsServiceTests.java @@ -72,16 +72,9 @@ public void testShardStats() { ) .build(); - var clusterInfo = new ClusterInfo( - Map.of(), - Map.of(), - Map.of(ClusterInfo.shardIdentifierFromRouting(shardId, true), currentShardSize), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + var clusterInfo = ClusterInfo.builder() + .shardSizes(Map.of(ClusterInfo.shardIdentifierFromRouting(shardId, true), currentShardSize)) + .build(); var queue = new DeterministicTaskQueue(); try (var clusterService = ClusterServiceUtils.createClusterService(state, queue.getThreadPool())) { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorTests.java index 170677ff3632f..c896d8a8f20fd 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/DiskThresholdMonitorTests.java @@ -1580,7 +1580,7 @@ private static ClusterInfo clusterInfo( Map diskUsages, Map reservedSpace ) { - return new ClusterInfo(diskUsages, Map.of(), Map.of(), Map.of(), Map.of(), reservedSpace, Map.of(), Map.of()); + return ClusterInfo.builder().leastAvailableSpaceUsage(diskUsages).reservedSpace(reservedSpace).build(); } private static DiscoveryNode newFrozenOnlyNode(String nodeId) { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java index 5ab57a2bba607..4a79e76b944ab 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ExpectedShardSizeAllocationTests.java @@ -249,22 +249,17 @@ public void testExpectedSizeOnMove() { } private static ClusterInfo createClusterInfoWith(ShardId shardId, long size) { - return new ClusterInfo( - Map.of(), - Map.of(), - Map.ofEntries( - Map.entry(ClusterInfo.shardIdentifierFromRouting(shardId, true), size), - Map.entry(ClusterInfo.shardIdentifierFromRouting(shardId, false), size) - ), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + return ClusterInfo.builder() + .shardSizes( + Map.ofEntries( + Map.entry(ClusterInfo.shardIdentifierFromRouting(shardId, true), size), + Map.entry(ClusterInfo.shardIdentifierFromRouting(shardId, false), size) + ) + ) + .build(); } private static ClusterInfo createClusterInfo(Map diskUsage, Map shardSizes) { - return new ClusterInfo(diskUsage, diskUsage, shardSizes, Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + return ClusterInfo.builder().leastAvailableSpaceUsage(diskUsage).mostAvailableSpaceUsage(diskUsage).shardSizes(shardSizes).build(); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocatorTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocatorTests.java index 50ace093019ed..3667de9c65e4e 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocatorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/BalancedShardsAllocatorTests.java @@ -597,21 +597,16 @@ public void testShardSizeDiscrepancyWithinIndex() { var allocationService = createAllocationService( Settings.EMPTY, - () -> new ClusterInfo( - Map.of(), - Map.of(), - Map.of( - ClusterInfo.shardIdentifierFromRouting(new ShardId(index, 0), true), - 0L, - ClusterInfo.shardIdentifierFromRouting(new ShardId(index, 1), true), - ByteSizeUnit.GB.toBytes(500) - ), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ) + () -> ClusterInfo.builder() + .shardSizes( + Map.of( + ClusterInfo.shardIdentifierFromRouting(new ShardId(index, 0), true), + 0L, + ClusterInfo.shardIdentifierFromRouting(new ShardId(index, 1), true), + ByteSizeUnit.GB.toBytes(500) + ) + ) + .build() ); assertSame(clusterState, reroute(allocationService, clusterState)); @@ -706,7 +701,7 @@ private RoutingAllocation createRoutingAllocation(ClusterState clusterState) { } private static ClusterInfo createClusterInfo(Map indexSizes) { - return new ClusterInfo(Map.of(), Map.of(), indexSizes, Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + return ClusterInfo.builder().shardSizes(indexSizes).build(); } private static IndexMetadata.Builder anIndex(String name) { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterAllocationSimulationTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterAllocationSimulationTests.java index 44e9eb7ff5232..6ef622948f5c5 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterAllocationSimulationTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterAllocationSimulationTests.java @@ -561,7 +561,12 @@ public ClusterInfo getClusterInfo() { dataPath.put(new ClusterInfo.NodeAndShard(shardRouting.currentNodeId(), shardRouting.shardId()), "/data"); } - return new ClusterInfo(diskSpaceUsage, diskSpaceUsage, shardSizes, Map.of(), dataPath, Map.of(), Map.of(), Map.of()); + return ClusterInfo.builder() + .leastAvailableSpaceUsage(diskSpaceUsage) + .mostAvailableSpaceUsage(diskSpaceUsage) + .shardSizes(shardSizes) + .dataPath(dataPath) + .build(); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStatsTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStatsTests.java index 73d0d7ac00796..00cf85609bf38 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStatsTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterBalanceStatsTests.java @@ -329,26 +329,21 @@ private static Tuple startedIndex( } private ClusterInfo createClusterInfo(List> shardSizes) { - return new ClusterInfo( - Map.of(), - Map.of(), - shardSizes.stream() - .flatMap( - entry -> IntStream.range(0, entry.v2().length) - .mapToObj( - index -> Map.entry( - ClusterInfo.shardIdentifierFromRouting(new ShardId(entry.v1(), "_na_", index), true), - entry.v2()[index] + return ClusterInfo.builder() + .shardSizes( + shardSizes.stream() + .flatMap( + entry -> IntStream.range(0, entry.v2().length) + .mapToObj( + index -> Map.entry( + ClusterInfo.shardIdentifierFromRouting(new ShardId(entry.v1(), "_na_", index), true), + entry.v2()[index] + ) ) - ) - ) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + ) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)) + ) + .build(); } private static Tuple indexSizes(String name, long... sizes) { diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterInfoSimulatorTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterInfoSimulatorTests.java index 921e9046a57e5..ea6a1522ec141 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterInfoSimulatorTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/ClusterInfoSimulatorTests.java @@ -690,16 +690,12 @@ public ClusterInfoTestBuilder withReservedSpace(String nodeId, String path, long } public ClusterInfo build() { - return new ClusterInfo( - leastAvailableSpaceUsage, - mostAvailableSpaceUsage, - shardSizes, - Map.of(), - Map.of(), - reservedSpace, - Map.of(), - Map.of() - ); + return ClusterInfo.builder() + .leastAvailableSpaceUsage(leastAvailableSpaceUsage) + .mostAvailableSpaceUsage(mostAvailableSpaceUsage) + .shardSizes(shardSizes) + .reservedSpace(reservedSpace) + .build(); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java index 9c8147f507961..d204c1c925d40 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceComputerTests.java @@ -690,7 +690,12 @@ public void testDesiredBalanceShouldConvergeInABigCluster() { .stream() .collect(toMap(Map.Entry::getKey, it -> new DiskUsage(it.getKey(), it.getKey(), "/data", diskSize, diskSize - it.getValue()))); - var clusterInfo = new ClusterInfo(diskUsage, diskUsage, shardSizes, Map.of(), dataPath, Map.of(), Map.of(), Map.of()); + var clusterInfo = ClusterInfo.builder() + .leastAvailableSpaceUsage(diskUsage) + .mostAvailableSpaceUsage(diskUsage) + .shardSizes(shardSizes) + .dataPath(dataPath) + .build(); var settings = Settings.EMPTY; @@ -1196,7 +1201,12 @@ public ClusterInfoTestBuilder withReservedSpace(String nodeId, long size, ShardI } public ClusterInfo build() { - return new ClusterInfo(diskUsage, diskUsage, shardSizes, Map.of(), Map.of(), reservedSpace, Map.of(), Map.of()); + return ClusterInfo.builder() + .leastAvailableSpaceUsage(diskUsage) + .mostAvailableSpaceUsage(diskUsage) + .shardSizes(shardSizes) + .reservedSpace(reservedSpace) + .build(); } } diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java index dc98cf5349c09..117afe0cec877 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/decider/DiskThresholdDeciderUnitTests.java @@ -843,16 +843,11 @@ public void testDecidesYesIfWatermarksIgnored() { allFullUsages.put("node_0", new DiskUsage("node_0", "node_0", "_na_", 100, 0)); // all full allFullUsages.put("node_1", new DiskUsage("node_1", "node_1", "_na_", 100, 0)); // all full - final ClusterInfo clusterInfo = new ClusterInfo( - allFullUsages, - allFullUsages, - Map.of("[test][0][p]", 10L), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + final ClusterInfo clusterInfo = ClusterInfo.builder() + .leastAvailableSpaceUsage(allFullUsages) + .mostAvailableSpaceUsage(allFullUsages) + .shardSizes(Map.of("[test][0][p]", 10L)) + .build(); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), clusterState, @@ -912,16 +907,11 @@ public void testCannotForceAllocateOver100PercentUsage() { // bigger than available space final long shardSize = randomIntBetween(1, 10); shardSizes.put("[test][0][p]", shardSize); - ClusterInfo clusterInfo = new ClusterInfo( - leastAvailableUsages, - mostAvailableUsage, - shardSizes, - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + ClusterInfo clusterInfo = ClusterInfo.builder() + .leastAvailableSpaceUsage(leastAvailableUsages) + .mostAvailableSpaceUsage(mostAvailableUsage) + .shardSizes(shardSizes) + .build(); RoutingAllocation allocation = new RoutingAllocation( new AllocationDeciders(Collections.singleton(decider)), clusterState, diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityServiceTests.java index a5ce2ff894817..dfc44b64cb691 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/AutoscalingCalculateCapacityServiceTests.java @@ -262,7 +262,7 @@ public void testContext() { } } state = ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).build(); - info = new ClusterInfo(leastUsages, mostUsages, Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + info = ClusterInfo.builder().leastAvailableSpaceUsage(leastUsages).mostAvailableSpaceUsage(mostUsages).build(); context = new AutoscalingCalculateCapacityService.DefaultAutoscalingDeciderContext( roleNames, state, @@ -311,7 +311,7 @@ public void testContext() { ) ); - info = new ClusterInfo(leastUsages, mostUsages, Map.of(), Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + info = ClusterInfo.builder().leastAvailableSpaceUsage(leastUsages).mostAvailableSpaceUsage(mostUsages).build(); context = new AutoscalingCalculateCapacityService.DefaultAutoscalingDeciderContext( roleNames, state, diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java index e28f2b7ba2ec8..286b5e48010ea 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/FrozenStorageDeciderServiceTests.java @@ -109,7 +109,7 @@ public Tuple sizeAndClusterInfo(IndexMetadata indexMetadata) // add irrelevant shards noise for completeness (should not happen IRL). sizes.put(new ShardId(index, i), randomLongBetween(0, Integer.MAX_VALUE)); } - ClusterInfo info = new ClusterInfo(Map.of(), Map.of(), Map.of(), sizes, Map.of(), Map.of(), Map.of(), Map.of()); + ClusterInfo info = ClusterInfo.builder().shardDataSetSizes(sizes).build(); return Tuple.tuple(totalSize, info); } } diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ProactiveStorageDeciderServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ProactiveStorageDeciderServiceTests.java index dec4e3bd146c8..0d054f45367bc 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ProactiveStorageDeciderServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ProactiveStorageDeciderServiceTests.java @@ -408,7 +408,7 @@ private ClusterInfo randomClusterInfo(ProjectState projectState) { for (var id : projectState.cluster().nodes().getDataNodes().keySet()) { diskUsage.put(id, new DiskUsage(id, id, "/test", Long.MAX_VALUE, Long.MAX_VALUE)); } - return new ClusterInfo(diskUsage, diskUsage, shardSizes, Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + return ClusterInfo.builder().leastAvailableSpaceUsage(diskUsage).mostAvailableSpaceUsage(diskUsage).shardSizes(shardSizes).build(); } private ProjectMetadata applyCreatedDates(ProjectMetadata project, DataStream ds, long last, long decrement) { diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java index 94364e3e90c27..18115a35039b2 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/storage/ReactiveStorageDeciderServiceTests.java @@ -379,7 +379,7 @@ public void validateSizeOf(ClusterState clusterState, ShardRouting subjectShard, } private ReactiveStorageDeciderService.AllocationState createAllocationState(Map shardSize, ClusterState clusterState) { - ClusterInfo info = new ClusterInfo(Map.of(), Map.of(), shardSize, Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + ClusterInfo info = ClusterInfo.builder().shardSizes(shardSize).build(); ReactiveStorageDeciderService.AllocationState allocationState = new ReactiveStorageDeciderService.AllocationState( clusterState, null, @@ -544,7 +544,11 @@ public void testUnmovableSize() { } var diskUsages = Map.of(nodeId, new DiskUsage(nodeId, null, null, ByteSizeUnit.KB.toBytes(100), ByteSizeUnit.KB.toBytes(5))); - ClusterInfo info = new ClusterInfo(diskUsages, diskUsages, shardSize, Map.of(), Map.of(), Map.of(), Map.of(), Map.of()); + ClusterInfo info = ClusterInfo.builder() + .leastAvailableSpaceUsage(diskUsages) + .mostAvailableSpaceUsage(diskUsages) + .shardSizes(shardSize) + .build(); ReactiveStorageDeciderService.AllocationState allocationState = new ReactiveStorageDeciderService.AllocationState( clusterState, diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java index 905dd93c3ff1b..0a323140c7e09 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/TransportNodeDeprecationCheckActionTests.java @@ -167,16 +167,9 @@ public void testCheckDiskLowWatermark() { String nodeId = "123"; long totalBytesOnMachine = 100; long totalBytesFree = 70; - ClusterInfo clusterInfo = new ClusterInfo( - Map.of(), - Map.of(nodeId, new DiskUsage(nodeId, "", "", totalBytesOnMachine, totalBytesFree)), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of(), - Map.of() - ); + ClusterInfo clusterInfo = ClusterInfo.builder() + .mostAvailableSpaceUsage(Map.of(nodeId, new DiskUsage(nodeId, "", "", totalBytesOnMachine, totalBytesFree))) + .build(); DeprecationIssue issue = TransportNodeDeprecationCheckAction.checkDiskLowWatermark( nodeSettings, dynamicSettings,