[Java] Fix: task spec's resource map should contain CPU (#2987)

This commit is contained in:
Hao Chen
2018-09-29 03:23:38 +08:00
committed by Robert Nishihara
parent 68cf194e90
commit 4ffe1e3556
3 changed files with 27 additions and 10 deletions
@@ -1,5 +1,6 @@
package org.ray.runtime;
import java.util.HashMap;
import org.ray.api.id.UniqueId;
import org.ray.runtime.config.WorkerMode;
import org.ray.runtime.task.TaskSpec;
@@ -83,7 +84,7 @@ public class WorkerContext {
0,
null,
null,
null,
new HashMap<>(),
null);
}
}
@@ -18,15 +18,16 @@ public class ResourceUtil {
*/
public static Map<String, Double> getResourcesMapFromArray(RayRemote remoteAnnotation) {
Map<String, Double> resourceMap = new HashMap<>();
if (remoteAnnotation == null) {
return resourceMap;
}
for (ResourceItem item : remoteAnnotation.resources()) {
if (!item.name().isEmpty()) {
resourceMap.put(item.name(), item.value());
if (remoteAnnotation != null) {
for (ResourceItem item : remoteAnnotation.resources()) {
if (!item.name().isEmpty()) {
resourceMap.put(item.name(), item.value());
}
}
}
if (!resourceMap.containsKey(CPU_LITERAL)) {
resourceMap.put(CPU_LITERAL, 0.0);
}
return resourceMap;
}