Skip to content

Commit

Permalink
Fix breaking API changes introduced during the release window (opense…
Browse files Browse the repository at this point in the history
…arch-project#15980)

Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Sep 18, 2024
1 parent 79867fb commit 681194f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions server/src/main/java/org/opensearch/wlm/ResourceType.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import org.opensearch.common.annotation.PublicApi;
import org.opensearch.core.common.io.stream.StreamOutput;
import org.opensearch.tasks.Task;
import org.opensearch.wlm.tracker.CpuUsageCalculator;
import org.opensearch.wlm.tracker.MemoryUsageCalculator;
import org.opensearch.wlm.tracker.ResourceUsageCalculator;
Expand Down Expand Up @@ -69,6 +70,21 @@ public String getName() {
return name;
}

/**
* Gets the resource usage for a given resource type and task.
*
* @param task the task for which to calculate resource usage
* @return the resource usage
*/
@Deprecated(forRemoval = true)
public long getResourceUsage(Task task) {
if (name.equals(CPU.name)) {
return task.getTotalResourceStats().getCpuTimeInNanos();
} else {
return task.getTotalResourceStats().getMemoryInBytes();
}
}

public boolean hasStatsEnabled() {
return statsEnabled;
}
Expand Down

0 comments on commit 681194f

Please sign in to comment.