Skip to content

Commit 78ee79a

Browse files
committed
Return undesired allocations ratio as double (to match setting)
1 parent bef60ec commit 78ee79a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

server/src/main/java/org/elasticsearch/cluster/routing/allocation/allocator/DesiredBalanceMetrics.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,16 @@ public long undesiredAllocationsExcludingShuttingDownNodes() {
6464
public record RoleAllocationStats(long totalAllocations, long undesiredAllocationsExcludingShuttingDownNodes) {
6565
public static final RoleAllocationStats EMPTY = new RoleAllocationStats(0L, 0L);
6666

67-
public float undesiredAllocationsRatio() {
67+
/**
68+
* Return the ratio of undesired allocations to the total number of allocations.
69+
*
70+
* @return a value in [0.0, 1.0]
71+
*/
72+
public double undesiredAllocationsRatio() {
6873
if (totalAllocations == 0) {
69-
return 0f;
74+
return 0.0;
7075
}
71-
return undesiredAllocationsExcludingShuttingDownNodes / (float) totalAllocations;
76+
return undesiredAllocationsExcludingShuttingDownNodes / (double) totalAllocations;
7277
}
7378
}
7479

0 commit comments

Comments
 (0)