File tree 1 file changed +16
-0
lines changed
server/src/main/java/org/opensearch/wlm 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 10
10
11
11
import org .opensearch .common .annotation .PublicApi ;
12
12
import org .opensearch .core .common .io .stream .StreamOutput ;
13
+ import org .opensearch .tasks .Task ;
13
14
import org .opensearch .wlm .tracker .CpuUsageCalculator ;
14
15
import org .opensearch .wlm .tracker .MemoryUsageCalculator ;
15
16
import org .opensearch .wlm .tracker .ResourceUsageCalculator ;
@@ -69,6 +70,21 @@ public String getName() {
69
70
return name ;
70
71
}
71
72
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
+
72
88
public boolean hasStatsEnabled () {
73
89
return statsEnabled ;
74
90
}
You can’t perform that action at this time.
0 commit comments