[Java] Implement GcsClient (#4601)

This commit is contained in:
Wang Qing
2019-04-12 22:44:47 +08:00
committed by Hao Chen
parent fe07a5b4b1
commit 5cfbfe5df6
16 changed files with 364 additions and 105 deletions
@@ -1,6 +1,8 @@
package org.ray.api;
import java.util.List;
import org.ray.api.gcs.GcsClient;
import org.ray.api.id.UniqueId;
import org.ray.api.runtime.RayRuntime;
import org.ray.api.runtime.RayRuntimeFactory;
@@ -127,4 +129,11 @@ public final class Ray extends RayCall {
public static RuntimeContext getRuntimeContext() {
return runtime.getRuntimeContext();
}
/**
* Get gcs client.
*/
public static GcsClient getGcsClient() {
return runtime.getGcsClient();
}
}
@@ -0,0 +1,15 @@
package org.ray.api.gcs;
import java.util.List;
/**
* The client used to interface with the GCS.
*/
public interface GcsClient {
/**
* Get all node information in Ray cluster.
*/
List<NodeInfo> getAllNodeInfo();
}
@@ -0,0 +1,36 @@
package org.ray.api.gcs;
import java.util.Map;
import org.ray.api.id.UniqueId;
/**
* A class that represents the information of a node.
*/
public class NodeInfo {
public final UniqueId nodeId;
public final String nodeAddress;
public final boolean isAlive;
public final Map<String, Double> resources;
public NodeInfo(UniqueId nodeId, String nodeAddress,
boolean isAlive, Map<String, Double> resources) {
this.nodeId = nodeId;
this.nodeAddress = nodeAddress;
this.isAlive = isAlive;
this.resources = resources;
}
public String toString() {
return "NodeInfo{"
+ "nodeId='" + nodeId + '\''
+ ", nodeAddress='" + nodeAddress + "\'"
+ ", isAlive=" + isAlive
+ ", resources=" + resources
+ "}";
}
}
@@ -7,6 +7,7 @@ import org.ray.api.RayPyActor;
import org.ray.api.RuntimeContext;
import org.ray.api.WaitResult;
import org.ray.api.function.RayFunc;
import org.ray.api.gcs.GcsClient;
import org.ray.api.id.UniqueId;
import org.ray.api.options.ActorCreationOptions;
import org.ray.api.options.CallOptions;
@@ -131,4 +132,6 @@ public interface RayRuntime {
*/
RayPyActor createPyActor(String moduleName, String className, Object[] args,
ActorCreationOptions options);
GcsClient getGcsClient();
}