Skip to content

Commit 681194f

Browse files
authored
Fix breaking API changes introduced during the release window (#15980)
Signed-off-by: Andriy Redko <andriy.redko@aiven.io>
1 parent 79867fb commit 681194f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

server/src/main/java/org/opensearch/wlm/ResourceType.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.opensearch.common.annotation.PublicApi;
1212
import org.opensearch.core.common.io.stream.StreamOutput;
13+
import org.opensearch.tasks.Task;
1314
import org.opensearch.wlm.tracker.CpuUsageCalculator;
1415
import org.opensearch.wlm.tracker.MemoryUsageCalculator;
1516
import org.opensearch.wlm.tracker.ResourceUsageCalculator;
@@ -69,6 +70,21 @@ public String getName() {
6970
return name;
7071
}
7172

73+
/**
74+
* Gets the resource usage for a given resource type and task.
75+
*
76+
* @param task the task for which to calculate resource usage
77+
* @return the resource usage
78+
*/
79+
@Deprecated(forRemoval = true)
80+
public long getResourceUsage(Task task) {
81+
if (name.equals(CPU.name)) {
82+
return task.getTotalResourceStats().getCpuTimeInNanos();
83+
} else {
84+
return task.getTotalResourceStats().getMemoryInBytes();
85+
}
86+
}
87+
7288
public boolean hasStatsEnabled() {
7389
return statsEnabled;
7490
}

0 commit comments

Comments
 (0)