mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 07:50:30 +08:00
[JavaWorker] Java code lint check and binding to CI (#2225)
* add java code lint check and fix the java code lint error * add java doc lint check and fix the java doc lint error * add java code and doc lint to the CI
This commit is contained in:
committed by
Philipp Moritz
parent
5789a247f9
commit
3b5e700fd7
@@ -1,15 +1,15 @@
|
||||
<assembly>
|
||||
<id>ear</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<useProjectArtifact>true</useProjectArtifact>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets>
|
||||
<id>ear</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<dependencySets>
|
||||
<dependencySet>
|
||||
<useProjectArtifact>true</useProjectArtifact>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
</dependencySet>
|
||||
</dependencySets>
|
||||
<fileSets>
|
||||
|
||||
</fileSets>
|
||||
</fileSets>
|
||||
</assembly>
|
||||
|
||||
+70
-70
@@ -1,82 +1,82 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.ray.parent</groupId>
|
||||
<artifactId>ray-superpom</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-native</artifactId>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-native</artifactId>
|
||||
|
||||
<name>native runtime for ray</name>
|
||||
<description>native runtime for ray</description>
|
||||
<url></url>
|
||||
<name>native runtime for ray</name>
|
||||
<description>native runtime for ray</description>
|
||||
<url></url>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.ray</groupId>
|
||||
<artifactId>ray-runtime-common</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.lingala.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.lingala.zip4j</groupId>
|
||||
<artifactId>zip4j</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>ray-runtime-deploy</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>19.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.arrow</groupId>
|
||||
<artifactId>arrow-plasma</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>ray-runtime-deploy</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -5,10 +5,11 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.arrow.plasma.ObjectStoreLink;
|
||||
import org.apache.arrow.plasma.PlasmaClient;
|
||||
import org.ray.api.*;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayRemote;
|
||||
import org.ray.api.UniqueID;
|
||||
import org.ray.api.funcs.RayFunc_2_1;
|
||||
import org.ray.core.RayRuntime;
|
||||
import org.ray.core.UniqueIdHelper;
|
||||
@@ -31,7 +32,7 @@ import org.ray.util.exception.TaskExecutionException;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* native runtime for local box and cluster run
|
||||
* native runtime for local box and cluster run.
|
||||
*/
|
||||
public class RayNativeRuntime extends RayRuntime {
|
||||
|
||||
@@ -44,25 +45,12 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
private StateStoreProxy stateStoreProxy;
|
||||
private KeyValueStoreLink kvStore = null;
|
||||
private RunManager manager = null;
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
if (null != manager) {
|
||||
manager.cleanup(true);
|
||||
}
|
||||
}
|
||||
private Object actor = null;
|
||||
private UniqueID actorId = UniqueID.nil;
|
||||
|
||||
protected RayNativeRuntime() {
|
||||
}
|
||||
|
||||
private void initStateStore(String redisAddress) throws Exception {
|
||||
kvStore = new RedisClient();
|
||||
kvStore.SetAddr(redisAddress);
|
||||
stateStoreProxy = new StateStoreProxyImpl(kvStore);
|
||||
//stateStoreProxy.setStore(kvStore);
|
||||
stateStoreProxy.initializeGlobalState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start(RayParameters params) throws Exception {
|
||||
boolean isWorker = (params.worker_mode == WorkerMode.WORKER);
|
||||
@@ -86,13 +74,14 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
}
|
||||
|
||||
// initialize remote function manager
|
||||
RemoteFunctionManager funcMgr = params.run_mode.isStaticRewrite() ?
|
||||
new NativeRemoteFunctionManager(kvStore) :
|
||||
RemoteFunctionManager funcMgr = params.run_mode.isStaticRewrite()
|
||||
? new NativeRemoteFunctionManager(kvStore) :
|
||||
new NopRemoteFunctionManager(params.driver_id);
|
||||
|
||||
// initialize worker context
|
||||
if (params.worker_mode == WorkerMode.DRIVER) {
|
||||
// TODO: The relationship between workerID, driver_id and dummy_task.driver_id should be recheck carefully
|
||||
// TODO: The relationship between workerID, driver_id and dummy_task.driver_id should be
|
||||
// recheck carefully
|
||||
WorkerContext.workerID = params.driver_id;
|
||||
}
|
||||
WorkerContext.init(params);
|
||||
@@ -109,20 +98,21 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
if (params.worker_mode != WorkerMode.NONE) {
|
||||
String overwrites = "";
|
||||
// initialize the links
|
||||
int release_delay = RayRuntime.configReader
|
||||
int releaseDelay = RayRuntime.configReader
|
||||
.getIntegerValue("ray", "plasma_default_release_delay", 0,
|
||||
"how many release requests should be delayed in plasma client");
|
||||
ObjectStoreLink pLink = new PlasmaClient(params.object_store_name, params.object_store_manager_name, release_delay);
|
||||
ObjectStoreLink plink = new PlasmaClient(params.object_store_name, params
|
||||
.object_store_manager_name, releaseDelay);
|
||||
|
||||
LocalSchedulerLink sLink = new DefaultLocalSchedulerClient(
|
||||
LocalSchedulerLink slink = new DefaultLocalSchedulerClient(
|
||||
params.local_scheduler_name,
|
||||
WorkerContext.currentWorkerID(),
|
||||
WorkerContext.currentWorkerId(),
|
||||
UniqueID.nil,
|
||||
isWorker,
|
||||
0
|
||||
);
|
||||
|
||||
init(sLink, pLink, funcMgr, pathConfig);
|
||||
init(slink, plink, funcMgr, pathConfig);
|
||||
|
||||
// register
|
||||
registerWorker(isWorker, params.node_ip_address, params.object_store_name,
|
||||
@@ -136,24 +126,48 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUp() {
|
||||
if (null != manager) {
|
||||
manager.cleanup(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getLocalActor(UniqueID id) {
|
||||
if (actorId.equals(id)) {
|
||||
return actor;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void startOnebox(RayParameters params, PathConfig paths) throws Exception {
|
||||
params.cleanup = true;
|
||||
manager = new RunManager(params, paths, RayRuntime.configReader);
|
||||
manager.startRayHead();
|
||||
|
||||
params.redis_address = manager.info().redisAddress;
|
||||
params.object_store_name = manager.info().local_stores.get(0).storeName;
|
||||
params.object_store_manager_name = manager.info().local_stores.get(0).managerName;
|
||||
params.local_scheduler_name = manager.info().local_stores.get(0).schedulerName;
|
||||
params.object_store_name = manager.info().localStores.get(0).storeName;
|
||||
params.object_store_manager_name = manager.info().localStores.get(0).managerName;
|
||||
params.local_scheduler_name = manager.info().localStores.get(0).schedulerName;
|
||||
//params.node_ip_address = NetworkUtil.getIpAddress();
|
||||
}
|
||||
|
||||
private void registerWorker(boolean isWorker, String node_ip_address, String storeName,
|
||||
String managerName, String schedulerName) {
|
||||
private void initStateStore(String redisAddress) throws Exception {
|
||||
kvStore = new RedisClient();
|
||||
kvStore.setAddr(redisAddress);
|
||||
stateStoreProxy = new StateStoreProxyImpl(kvStore);
|
||||
//stateStoreProxy.setStore(kvStore);
|
||||
stateStoreProxy.initializeGlobalState();
|
||||
}
|
||||
|
||||
private void registerWorker(boolean isWorker, String nodeIpAddress, String storeName,
|
||||
String managerName, String schedulerName) {
|
||||
Map<String, String> workerInfo = new HashMap<>();
|
||||
String workerId = new String(WorkerContext.currentWorkerID().getBytes());
|
||||
String workerId = new String(WorkerContext.currentWorkerId().getBytes());
|
||||
if (!isWorker) {
|
||||
workerInfo.put("node_ip_address", node_ip_address);
|
||||
workerInfo.put("node_ip_address", nodeIpAddress);
|
||||
workerInfo.put("driver_id", workerId);
|
||||
workerInfo.put("start_time", String.valueOf(System.currentTimeMillis()));
|
||||
workerInfo.put("plasma_store_socket", storeName);
|
||||
@@ -161,31 +175,17 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
workerInfo.put("local_scheduler_socket", schedulerName);
|
||||
workerInfo.put("name", System.getProperty("user.dir"));
|
||||
//TODO: worker.redis_client.hmset(b"Drivers:" + worker.workerId, driver_info)
|
||||
kvStore.Hmset("Drivers:" + workerId, workerInfo);
|
||||
kvStore.hmset("Drivers:" + workerId, workerInfo);
|
||||
} else {
|
||||
workerInfo.put("node_ip_address", node_ip_address);
|
||||
//TODO:
|
||||
/*
|
||||
"stdout_file": os.path.abspath(log_stdout_file.name),
|
||||
"stderr_file": os.path.abspath(log_stderr_file.name),
|
||||
*/
|
||||
workerInfo.put("node_ip_address", nodeIpAddress);
|
||||
workerInfo.put("plasma_store_socket", storeName);
|
||||
workerInfo.put("plasma_manager_socket", managerName);
|
||||
workerInfo.put("local_scheduler_socket", schedulerName);
|
||||
//TODO: b"Workers:" + worker.workerId,
|
||||
kvStore.Hmset("Workers:" + workerId, workerInfo);
|
||||
kvStore.hmset("Workers:" + workerId, workerInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private Object _actor = null;
|
||||
private UniqueID actorID = UniqueID.nil;
|
||||
|
||||
@RayRemote
|
||||
public static byte[] createActorInActor(byte[] actorId, String className) {
|
||||
((RayNativeRuntime) RayRuntime.getInstance()).localCreateActorInActor(actorId, className);
|
||||
return actorId;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> RayActor<T> create(Class<T> cls) {
|
||||
@@ -202,7 +202,7 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
RayFunc_2_1.class,
|
||||
createActorLambda,
|
||||
1,
|
||||
new Object[]{actorId.getBytes(), cls.getName()}
|
||||
new Object[] {actorId.getBytes(), cls.getName()}
|
||||
).getObjs()[0].getId();
|
||||
} else {
|
||||
cursorId = worker.rpcCreateActor(
|
||||
@@ -210,16 +210,22 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
actorId,
|
||||
() -> RayNativeRuntime.createActorInActor(null, null),
|
||||
1,
|
||||
new Object[]{actorId.getBytes(), cls.getName()}
|
||||
new Object[] {actorId.getBytes(), cls.getName()}
|
||||
).getObjs()[0].getId();
|
||||
}
|
||||
actor.setTaskCursor(cursorId);
|
||||
return actor;
|
||||
}
|
||||
|
||||
@RayRemote
|
||||
public static byte[] createActorInActor(byte[] actorId, String className) {
|
||||
((RayNativeRuntime) RayRuntime.getInstance()).localCreateActorInActor(actorId, className);
|
||||
return actorId;
|
||||
}
|
||||
|
||||
public Object localCreateActorInActor(byte[] actorId, String className) {
|
||||
try {
|
||||
actorID = new UniqueID(actorId);
|
||||
this.actorId = new UniqueID(actorId);
|
||||
Class<?> cls = Class.forName(className, true, Thread.currentThread().getContextClassLoader());
|
||||
|
||||
Constructor<?>[] cts = cls.getConstructors();
|
||||
@@ -227,25 +233,18 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
System.err.println(ct.getName() + ", param count = " + ct.getParameterCount());
|
||||
}
|
||||
|
||||
_actor = cls.getConstructor(new Class<?>[0]).newInstance();
|
||||
RayLog.core.info("create actor " + actorID + " inside actor ok");
|
||||
return _actor;
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
|
||||
actor = cls.getConstructor(new Class<?>[0]).newInstance();
|
||||
RayLog.core.info("create actor " + this.actorId + " inside actor ok");
|
||||
return actor;
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException
|
||||
| IllegalArgumentException | InvocationTargetException | NoSuchMethodException
|
||||
| SecurityException e) {
|
||||
e.printStackTrace();
|
||||
String log = "create actor " + actorID + " for " + className + " failed, ex = " + e
|
||||
String log = "create actor " + this.actorId + " for " + className + " failed, ex = " + e
|
||||
.getMessage();
|
||||
System.err.println(log);
|
||||
RayLog.core.error(log, e);
|
||||
throw new TaskExecutionException(log, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getLocalActor(UniqueID id) {
|
||||
if (actorID.equals(id)) {
|
||||
return _actor;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,23 +6,17 @@ import java.util.List;
|
||||
import org.ray.spi.model.AddressInfo;
|
||||
|
||||
/**
|
||||
* information of kinds of processes
|
||||
* information of kinds of processes.
|
||||
*/
|
||||
public class RunInfo {
|
||||
|
||||
public String redisAddress;
|
||||
public List<String> redisShards;
|
||||
public List<AddressInfo> local_stores = new ArrayList<>();
|
||||
public List<AddressInfo> localStores = new ArrayList<>();
|
||||
public ArrayList<List<ProcessInfo>> allProcesses = initProcessInfoArray();
|
||||
public ArrayList<List<Process>> toBeCleanedProcesses = initProcessArray();
|
||||
public ArrayList<ProcessInfo> deadProcess = new ArrayList<>();
|
||||
|
||||
public enum ProcessType {
|
||||
PT_WORKER, PT_LOCAL_SCHEDULER, PT_PLASMA_MANAGER, PT_PLASMA_STORE,
|
||||
PT_GLOBAL_SCHEDULER, PT_REDIS_SERVER, PT_WEB_UI,
|
||||
PT_DRIVER
|
||||
}
|
||||
|
||||
private ArrayList<List<Process>> initProcessArray() {
|
||||
ArrayList<List<Process>> processes = new ArrayList<>();
|
||||
for (ProcessType ignored : ProcessType.values()) {
|
||||
@@ -38,4 +32,10 @@ public class RunInfo {
|
||||
}
|
||||
return processes;
|
||||
}
|
||||
|
||||
public enum ProcessType {
|
||||
PT_WORKER, PT_LOCAL_SCHEDULER, PT_PLASMA_MANAGER, PT_PLASMA_STORE,
|
||||
PT_GLOBAL_SCHEDULER, PT_REDIS_SERVER, PT_WEB_UI,
|
||||
PT_DRIVER
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.ray.util.logger.RayLog;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
/**
|
||||
* Ray service management on one box
|
||||
* Ray service management on one box.
|
||||
*/
|
||||
public class RunManager {
|
||||
|
||||
@@ -40,6 +40,21 @@ public class RunManager {
|
||||
|
||||
private RunInfo runInfo = new RunInfo();
|
||||
|
||||
public RunManager(RayParameters params, PathConfig paths, ConfigReader configReader) {
|
||||
this.params = params;
|
||||
this.paths = paths;
|
||||
this.configReader = configReader;
|
||||
}
|
||||
|
||||
private static boolean killProcess(Process p) {
|
||||
if (p.isAlive()) {
|
||||
p.destroyForcibly();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public RunInfo info() {
|
||||
return runInfo;
|
||||
}
|
||||
@@ -56,12 +71,6 @@ public class RunManager {
|
||||
return procStderrFileName;
|
||||
}
|
||||
|
||||
public RunManager(RayParameters params, PathConfig paths, ConfigReader configReader) {
|
||||
this.params = params;
|
||||
this.paths = paths;
|
||||
this.configReader = configReader;
|
||||
}
|
||||
|
||||
public void startRayHead() throws Exception {
|
||||
if (params.redis_address.length() != 0) {
|
||||
throw new Exception("Redis address must be empty in head node.");
|
||||
@@ -99,6 +108,44 @@ public class RunManager {
|
||||
startRayProcesses();
|
||||
}
|
||||
|
||||
public Process startDriver(String mainClass, String redisAddress, UniqueID driverId,
|
||||
String workDir, String ip,
|
||||
String driverClass, String additonalClassPaths, String
|
||||
additionalConfigs) {
|
||||
String driverConfigs =
|
||||
"ray.java.start.driver_id=" + driverId + ";ray.java.start.driver_class=" + driverClass;
|
||||
if (null != additionalConfigs) {
|
||||
additionalConfigs += ";" + driverConfigs;
|
||||
} else {
|
||||
additionalConfigs = driverConfigs;
|
||||
}
|
||||
|
||||
return startJavaProcess(
|
||||
RunInfo.ProcessType.PT_DRIVER,
|
||||
mainClass,
|
||||
additonalClassPaths,
|
||||
additionalConfigs,
|
||||
"",
|
||||
workDir,
|
||||
ip,
|
||||
redisAddress,
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
private Process startJavaProcess(RunInfo.ProcessType pt, String mainClass,
|
||||
String additonalClassPaths, String additionalConfigs,
|
||||
String additionalJvmArgs, String workDir, String ip, String
|
||||
redisAddr, boolean redirect,
|
||||
boolean cleanup, String agentlibAddr) {
|
||||
|
||||
String cmd = buildJavaProcessCommand(pt, mainClass, additonalClassPaths, additionalConfigs,
|
||||
additionalJvmArgs, workDir, ip, redisAddr, agentlibAddr);
|
||||
return startProcess(cmd.split(" "), null, pt, workDir, redisAddr, ip, redirect, cleanup);
|
||||
}
|
||||
|
||||
private String buildJavaProcessCommand(
|
||||
RunInfo.ProcessType pt, String mainClass, String additionalClassPaths,
|
||||
String additionalConfigs,
|
||||
@@ -137,44 +184,89 @@ public class RunManager {
|
||||
return cmd;
|
||||
}
|
||||
|
||||
private Process startJavaProcess(RunInfo.ProcessType pt, String mainClass,
|
||||
String additonalClassPaths, String additionalConfigs,
|
||||
String additionalJvmArgs, String workDir, String ip, String redisAddr, boolean redirect,
|
||||
boolean cleanup, String agentlibAddr) {
|
||||
|
||||
String cmd = buildJavaProcessCommand(pt, mainClass, additonalClassPaths, additionalConfigs,
|
||||
additionalJvmArgs, workDir, ip, redisAddr, agentlibAddr);
|
||||
return startProcess(cmd.split(" "), null, pt, workDir, redisAddr, ip, redirect, cleanup);
|
||||
}
|
||||
|
||||
public Process startDriver(String mainClass, String redisAddress, UniqueID driverId,
|
||||
String workDir, String ip,
|
||||
String driverClass, String additonalClassPaths, String additionalConfigs) {
|
||||
String driverConfigs =
|
||||
"ray.java.start.driver_id=" + driverId + ";ray.java.start.driver_class=" + driverClass;
|
||||
if (null != additionalConfigs) {
|
||||
additionalConfigs += ";" + driverConfigs;
|
||||
} else {
|
||||
additionalConfigs = driverConfigs;
|
||||
private Process startProcess(String[] cmd, Map<String, String> env, RunInfo.ProcessType type,
|
||||
String workDir,
|
||||
String redisAddress, String ip, boolean redirect,
|
||||
boolean cleanup) {
|
||||
File wdir = new File(workDir);
|
||||
if (!wdir.exists()) {
|
||||
wdir.mkdirs();
|
||||
}
|
||||
|
||||
return startJavaProcess(
|
||||
RunInfo.ProcessType.PT_DRIVER,
|
||||
mainClass,
|
||||
additonalClassPaths,
|
||||
additionalConfigs,
|
||||
"",
|
||||
workDir,
|
||||
ip,
|
||||
redisAddress,
|
||||
true,
|
||||
false,
|
||||
null
|
||||
);
|
||||
int processIndex = runInfo.allProcesses.get(type.ordinal()).size();
|
||||
ProcessBuilder builder;
|
||||
List<String> newCmd = Arrays.stream(cmd).filter(s -> s.length() > 0)
|
||||
.collect(Collectors.toList());
|
||||
builder = new ProcessBuilder(newCmd);
|
||||
builder.directory(new File(workDir));
|
||||
if (redirect) {
|
||||
String stdoutFile;
|
||||
String stderrFile;
|
||||
stdoutFile = workDir + "/" + processIndex + ".out.txt";
|
||||
stderrFile = workDir + "/" + processIndex + ".err.txt";
|
||||
builder.redirectOutput(new File(stdoutFile));
|
||||
builder.redirectError(new File(stderrFile));
|
||||
List<String> stdFileList = new ArrayList<>();
|
||||
stdFileList.add(stdoutFile);
|
||||
stdFileList.add(stderrFile);
|
||||
record_log_files_in_redis(redisAddress, ip, stdFileList);
|
||||
procStdoutFileName = stdoutFile;
|
||||
procStderrFileName = stderrFile;
|
||||
}
|
||||
|
||||
if (env != null && !env.isEmpty()) {
|
||||
builder.environment().putAll(env);
|
||||
}
|
||||
|
||||
Process p = null;
|
||||
try {
|
||||
p = builder.start();
|
||||
} catch (IOException e) {
|
||||
RayLog.core
|
||||
.error("Start process " + Arrays.toString(cmd).replace(',', ' ') + " in working dir '"
|
||||
+ workDir + "' failed",
|
||||
e);
|
||||
return null;
|
||||
}
|
||||
|
||||
RayLog.core.info(
|
||||
"Start process " + p.hashCode() + " OK, cmd = " + Arrays.toString(cmd).replace(',', ' ')
|
||||
+ ", working dir = '" + workDir + "'" + (redirect ? ", redirect" : ", no redirect"));
|
||||
|
||||
if (cleanup) {
|
||||
runInfo.toBeCleanedProcesses.get(type.ordinal()).add(p);
|
||||
}
|
||||
|
||||
ProcessInfo processInfo = new ProcessInfo();
|
||||
processInfo.cmd = cmd;
|
||||
processInfo.type = type;
|
||||
processInfo.workDir = workDir;
|
||||
processInfo.redisAddress = redisAddress;
|
||||
processInfo.ip = ip;
|
||||
processInfo.redirect = redirect;
|
||||
processInfo.cleanup = cleanup;
|
||||
processInfo.process = p;
|
||||
runInfo.allProcesses.get(type.ordinal()).add(processInfo);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private void record_log_files_in_redis(String redisAddress, String nodeIpAddress,
|
||||
List<String> logfiles) {
|
||||
if (redisAddress != null && !redisAddress.isEmpty() && nodeIpAddress != null
|
||||
&& !nodeIpAddress.isEmpty() && logfiles.size() > 0) {
|
||||
String[] ipPort = redisAddress.split(":");
|
||||
Jedis jedisClient = new Jedis(ipPort[0], Integer.parseInt(ipPort[1]));
|
||||
String logFileListKey = String.format("LOG_FILENAMES:{%s}", nodeIpAddress);
|
||||
for (String logfile : logfiles) {
|
||||
jedisClient.rpush(logFileListKey, logfile);
|
||||
}
|
||||
jedisClient.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void startRayProcesses() {
|
||||
Jedis _redis_client = null;
|
||||
Jedis redisClient = null;
|
||||
|
||||
RayLog.core.info("start ray processes @ " + params.node_ip_address + " ...");
|
||||
|
||||
@@ -185,14 +277,14 @@ public class RunManager {
|
||||
params.redis_address = primaryShards.get(0);
|
||||
|
||||
String[] args = params.redis_address.split(":");
|
||||
_redis_client = new Jedis(args[0], Integer.parseInt(args[1]));
|
||||
redisClient = new Jedis(args[0], Integer.parseInt(args[1]));
|
||||
|
||||
// Register the number of Redis shards in the primary shard, so that clients
|
||||
// know how many redis shards to expect under RedisShards.
|
||||
_redis_client.set("NumRedisShards", Integer.toString(params.num_redis_shards));
|
||||
redisClient.set("NumRedisShards", Integer.toString(params.num_redis_shards));
|
||||
} else {
|
||||
String[] args = params.redis_address.split(":");
|
||||
_redis_client = new Jedis(args[0], Integer.parseInt(args[1]));
|
||||
redisClient = new Jedis(args[0], Integer.parseInt(args[1]));
|
||||
}
|
||||
runInfo.redisAddress = params.redis_address;
|
||||
|
||||
@@ -206,10 +298,10 @@ public class RunManager {
|
||||
// Store redis shard information in the primary redis shard.
|
||||
for (int i = 0; i < runInfo.redisShards.size(); i++) {
|
||||
String addr = runInfo.redisShards.get(i);
|
||||
_redis_client.rpush("RedisShards", addr);
|
||||
redisClient.rpush("RedisShards", addr);
|
||||
}
|
||||
}
|
||||
_redis_client.close();
|
||||
redisClient.close();
|
||||
|
||||
// start global scheduler
|
||||
if (params.include_global_scheduler) {
|
||||
@@ -236,12 +328,12 @@ public class RunManager {
|
||||
assert (params.num_gpus.length == params.num_local_schedulers);
|
||||
}
|
||||
|
||||
int[] local_num_workers = new int[params.num_local_schedulers];
|
||||
int[] localNumWorkers = new int[params.num_local_schedulers];
|
||||
if (params.num_workers == 0) {
|
||||
System.arraycopy(params.num_cpus, 0, local_num_workers, 0, params.num_local_schedulers);
|
||||
System.arraycopy(params.num_cpus, 0, localNumWorkers, 0, params.num_local_schedulers);
|
||||
} else {
|
||||
for (int i = 0; i < params.num_local_schedulers; i++) {
|
||||
local_num_workers[i] = params.num_workers;
|
||||
localNumWorkers[i] = params.num_workers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,7 +349,7 @@ public class RunManager {
|
||||
params.working_directory + "/storeManager", params.redis_address,
|
||||
params.node_ip_address, params.redirect, params.cleanup);
|
||||
|
||||
runInfo.local_stores.add(info);
|
||||
runInfo.localStores.add(info);
|
||||
}
|
||||
|
||||
// start local scheduler
|
||||
@@ -265,11 +357,11 @@ public class RunManager {
|
||||
int workerCount = 0;
|
||||
|
||||
if (params.start_workers_from_local_scheduler) {
|
||||
workerCount = local_num_workers[i];
|
||||
local_num_workers[i] = 0;
|
||||
workerCount = localNumWorkers[i];
|
||||
localNumWorkers[i] = 0;
|
||||
}
|
||||
|
||||
startLocalScheduler(i, runInfo.local_stores.get(i),
|
||||
startLocalScheduler(i, runInfo.localStores.get(i),
|
||||
params.num_cpus[i], params.num_gpus[i], workerCount,
|
||||
params.working_directory + "/localScheduler", params.redis_address,
|
||||
params.node_ip_address, params.redirect, params.cleanup);
|
||||
@@ -277,13 +369,13 @@ public class RunManager {
|
||||
|
||||
// start local workers
|
||||
for (int i = 0; i < params.num_local_schedulers; i++) {
|
||||
runInfo.local_stores.get(i).workerCount = local_num_workers[i];
|
||||
for (int j = 0; j < local_num_workers[i]; j++) {
|
||||
startWorker(runInfo.local_stores.get(i).storeName,
|
||||
runInfo.local_stores.get(i).managerName, runInfo.local_stores.get(i).schedulerName,
|
||||
params.working_directory + "/worker" + i + "." + j, params.redis_address,
|
||||
params.node_ip_address, UniqueID.nil, "",
|
||||
params.redirect, params.cleanup);
|
||||
runInfo.localStores.get(i).workerCount = localNumWorkers[i];
|
||||
for (int j = 0; j < localNumWorkers[i]; j++) {
|
||||
startWorker(runInfo.localStores.get(i).storeName,
|
||||
runInfo.localStores.get(i).managerName, runInfo.localStores.get(i).schedulerName,
|
||||
params.working_directory + "/worker" + i + "." + j, params.redis_address,
|
||||
params.node_ip_address, UniqueID.nil, "",
|
||||
params.redirect, params.cleanup);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,10 +394,11 @@ public class RunManager {
|
||||
}
|
||||
|
||||
ProcessInfo p;
|
||||
for (int j = 0; j < runInfo.allProcesses.get(i).size();) {
|
||||
for (int j = 0; j < runInfo.allProcesses.get(i).size(); ) {
|
||||
p = runInfo.allProcesses.get(i).get(j);
|
||||
if (!p.process.isAlive()) {
|
||||
RayLog.core.error("Process " + p.hashCode() + " is not alive!" + " Process Type " + types[i].name());
|
||||
RayLog.core.error("Process " + p.hashCode() + " is not alive!" + " Process Type "
|
||||
+ types[i].name());
|
||||
runInfo.deadProcess.add(p);
|
||||
runInfo.allProcesses.get(i).remove(j);
|
||||
} else {
|
||||
@@ -378,96 +471,6 @@ public class RunManager {
|
||||
}
|
||||
}
|
||||
|
||||
private void record_log_files_in_redis(String redis_address, String node_ip_address,
|
||||
List<String> logfiles) {
|
||||
if (redis_address != null && !redis_address.isEmpty() && node_ip_address != null
|
||||
&& !node_ip_address.isEmpty() && logfiles.size() > 0) {
|
||||
String[] ip_port = redis_address.split(":");
|
||||
Jedis jedis_client = new Jedis(ip_port[0], Integer.parseInt(ip_port[1]));
|
||||
String log_file_list_key = String.format("LOG_FILENAMES:{%s}", node_ip_address);
|
||||
for (String logfile : logfiles) {
|
||||
jedis_client.rpush(log_file_list_key, logfile);
|
||||
}
|
||||
jedis_client.close();
|
||||
}
|
||||
}
|
||||
|
||||
private Process startProcess(String[] cmd, Map<String, String> env, RunInfo.ProcessType type,
|
||||
String workDir,
|
||||
String redisAddress, String ip, boolean redirect,
|
||||
boolean cleanup) {
|
||||
File wdir = new File(workDir);
|
||||
if (!wdir.exists()) {
|
||||
wdir.mkdirs();
|
||||
}
|
||||
|
||||
int processIndex = runInfo.allProcesses.get(type.ordinal()).size();
|
||||
ProcessBuilder builder;
|
||||
List<String> newCmd = Arrays.stream(cmd).filter(s -> s.length() > 0)
|
||||
.collect(Collectors.toList());
|
||||
builder = new ProcessBuilder(newCmd);
|
||||
builder.directory(new File(workDir));
|
||||
if (redirect) {
|
||||
String stdout_file;
|
||||
String stderr_file;
|
||||
stdout_file = workDir + "/" + processIndex + ".out.txt";
|
||||
stderr_file = workDir + "/" + processIndex + ".err.txt";
|
||||
builder.redirectOutput(new File(stdout_file));
|
||||
builder.redirectError(new File(stderr_file));
|
||||
List<String> std_file_list = new ArrayList<>();
|
||||
std_file_list.add(stdout_file);
|
||||
std_file_list.add(stderr_file);
|
||||
record_log_files_in_redis(redisAddress, ip, std_file_list);
|
||||
procStdoutFileName = stdout_file;
|
||||
procStderrFileName = stderr_file;
|
||||
}
|
||||
|
||||
if (env != null && !env.isEmpty()) {
|
||||
builder.environment().putAll(env);
|
||||
}
|
||||
|
||||
Process p = null;
|
||||
try {
|
||||
p = builder.start();
|
||||
} catch (IOException e) {
|
||||
RayLog.core
|
||||
.error("Start process " + Arrays.toString(cmd).replace(',', ' ') + " in working dir '"
|
||||
+ workDir + "' failed",
|
||||
e);
|
||||
return null;
|
||||
}
|
||||
|
||||
RayLog.core.info(
|
||||
"Start process " + p.hashCode() + " OK, cmd = " + Arrays.toString(cmd).replace(',', ' ')
|
||||
+ ", working dir = '" + workDir + "'" + (redirect ? ", redirect" : ", no redirect"));
|
||||
|
||||
if (cleanup) {
|
||||
runInfo.toBeCleanedProcesses.get(type.ordinal()).add(p);
|
||||
}
|
||||
|
||||
ProcessInfo processInfo = new ProcessInfo();
|
||||
processInfo.cmd = cmd;
|
||||
processInfo.type = type;
|
||||
processInfo.workDir = workDir;
|
||||
processInfo.redisAddress = redisAddress;
|
||||
processInfo.ip = ip;
|
||||
processInfo.redirect = redirect;
|
||||
processInfo.cleanup = cleanup;
|
||||
processInfo.process = p;
|
||||
runInfo.allProcesses.get(type.ordinal()).add(processInfo);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private static boolean killProcess(Process p) {
|
||||
if (p.isAlive()) {
|
||||
p.destroyForcibly();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// start a redis server
|
||||
//
|
||||
@@ -481,7 +484,7 @@ public class RunManager {
|
||||
// @return primary redis shard address
|
||||
//
|
||||
private List<String> startRedis(String workDir, String ip, int port, int numOfShards,
|
||||
boolean redirect, boolean cleanup) {
|
||||
boolean redirect, boolean cleanup) {
|
||||
ArrayList<String> shards = new ArrayList<>();
|
||||
String addr;
|
||||
for (int i = 0; i < numOfShards; i++) {
|
||||
@@ -509,7 +512,7 @@ public class RunManager {
|
||||
// @return redis server address
|
||||
//
|
||||
private String startRedisInstance(String workDir, String ip, int port,
|
||||
boolean redirect, boolean cleanup) {
|
||||
boolean redirect, boolean cleanup) {
|
||||
String redisFilePath = paths.redis_server;
|
||||
String redisModule = paths.redis_module;
|
||||
|
||||
@@ -531,6 +534,7 @@ public class RunManager {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(300);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Jedis client = new Jedis(params.node_ip_address, port);
|
||||
@@ -546,7 +550,7 @@ public class RunManager {
|
||||
}
|
||||
|
||||
private void startGlobalScheduler(String workDir, String redisAddress, String ip,
|
||||
boolean redirect, boolean cleanup) {
|
||||
boolean redirect, boolean cleanup) {
|
||||
String filePath = paths.global_scheduler;
|
||||
String cmd = filePath + " -r " + redisAddress + " -h " + ip;
|
||||
|
||||
@@ -592,9 +596,9 @@ public class RunManager {
|
||||
* start
|
||||
*/
|
||||
private void startLocalScheduler(int index, AddressInfo info, int numCpus,
|
||||
int numGpus, int numWorkers, String workDir,
|
||||
String redisAddress, String ip, boolean redirect,
|
||||
boolean cleanup) {
|
||||
int numGpus, int numWorkers, String workDir,
|
||||
String redisAddress, String ip, boolean redirect,
|
||||
boolean cleanup) {
|
||||
//if (numCpus <= 0)
|
||||
// numCpus = Runtime.getRuntime().availableProcessors();
|
||||
if (numGpus <= 0) {
|
||||
@@ -606,7 +610,7 @@ public class RunManager {
|
||||
String name = "/tmp/scheduler" + rpcPort;
|
||||
String rpcAddr = "";
|
||||
String cmd = filePath + " -s " + name + " -p " + info.storeName + " -h " + ip + " -n "
|
||||
+ numWorkers + " -c " + "CPU," + INT16_MAX +",GPU,0";
|
||||
+ numWorkers + " -c " + "CPU," + INT16_MAX + ",GPU,0";
|
||||
|
||||
assert (info.managerName.length() > 0);
|
||||
assert (info.storeName.length() > 0);
|
||||
@@ -616,7 +620,7 @@ public class RunManager {
|
||||
|
||||
String workerCmd = null;
|
||||
workerCmd = buildWorkerCommand(true, info.storeName, info.managerName, name, UniqueID.nil,
|
||||
"", workDir + rpcPort, ip, redisAddress);
|
||||
"", workDir + rpcPort, ip, redisAddress);
|
||||
cmd += " -w \"" + workerCmd + "\"";
|
||||
|
||||
if (redisAddress.length() > 0) {
|
||||
@@ -627,7 +631,7 @@ public class RunManager {
|
||||
}
|
||||
|
||||
Map<String, String> env = null;
|
||||
String[] cmds = StringUtil.Split(cmd, " ", "\"", "\"").toArray(new String[0]);
|
||||
String[] cmds = StringUtil.split(cmd, " ", "\"", "\"").toArray(new String[0]);
|
||||
Process p = startProcess(cmds, env, RunInfo.ProcessType.PT_LOCAL_SCHEDULER,
|
||||
workDir + rpcPort, redisAddress, ip, redirect, cleanup);
|
||||
|
||||
@@ -635,6 +639,7 @@ public class RunManager {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -649,8 +654,9 @@ public class RunManager {
|
||||
}
|
||||
|
||||
private String buildWorkerCommand(boolean isFromLocalScheduler, String storeName,
|
||||
String storeManagerName, String localSchedulerName,
|
||||
UniqueID actorId, String actorClass, String workDir, String ip, String redisAddress) {
|
||||
String storeManagerName, String localSchedulerName,
|
||||
UniqueID actorId, String actorClass, String workDir, String
|
||||
ip, String redisAddress) {
|
||||
String workerConfigs = "ray.java.start.object_store_name=" + storeName
|
||||
+ ";ray.java.start.object_store_manager_name=" + storeManagerName
|
||||
+ ";ray.java.start.worker_mode=WORKER"
|
||||
@@ -680,9 +686,9 @@ public class RunManager {
|
||||
}
|
||||
|
||||
private void startObjectStore(int index, AddressInfo info, String workDir, String redisAddress,
|
||||
String ip, boolean redirect, boolean cleanup) {
|
||||
int occupiedMemoryMB = params.object_store_occupied_memory_MB;
|
||||
long memoryBytes = occupiedMemoryMB * 1000000;
|
||||
String ip, boolean redirect, boolean cleanup) {
|
||||
int occupiedMemoryMb = params.object_store_occupied_memory_MB;
|
||||
long memoryBytes = occupiedMemoryMb * 1000000;
|
||||
String filePath = paths.store;
|
||||
int rpcPort = params.object_store_rpc_port + index;
|
||||
String name = "/tmp/plasma_store" + rpcPort;
|
||||
@@ -697,6 +703,7 @@ public class RunManager {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -711,8 +718,8 @@ public class RunManager {
|
||||
}
|
||||
|
||||
private AddressInfo startObjectManager(int index, AddressInfo info, String workDir,
|
||||
String redisAddress, String ip, boolean redirect,
|
||||
boolean cleanup) {
|
||||
String redisAddress, String ip, boolean redirect,
|
||||
boolean cleanup) {
|
||||
String filePath = paths.store_manager;
|
||||
int rpcPort = params.object_store_manager_rpc_port + index;
|
||||
String name = "/tmp/plasma_manager" + rpcPort;
|
||||
@@ -730,6 +737,7 @@ public class RunManager {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,9 +752,9 @@ public class RunManager {
|
||||
}
|
||||
|
||||
public void startWorker(String storeName, String storeManagerName,
|
||||
String localSchedulerName, String workDir, String redisAddress,
|
||||
String ip, UniqueID actorId, String actorClass,
|
||||
boolean redirect, boolean cleanup) {
|
||||
String localSchedulerName, String workDir, String redisAddress,
|
||||
String ip, UniqueID actorId, String actorClass,
|
||||
boolean redirect, boolean cleanup) {
|
||||
String cmd = buildWorkerCommand(false, storeName, storeManagerName, localSchedulerName, actorId,
|
||||
actorClass, workDir, ip, redisAddress);
|
||||
startProcess(cmd.split(" "), null, RunInfo.ProcessType.PT_WORKER, workDir, redisAddress, ip,
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.ray.core.RayRuntime;
|
||||
import org.ray.core.model.WorkerMode;
|
||||
|
||||
/**
|
||||
*
|
||||
* The main function of DefaultDriver.
|
||||
*/
|
||||
public class DefaultDriver {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class DefaultDriver {
|
||||
.getStringValue("ray.java.start", "driver_class", "",
|
||||
"java class which main is served as the driver in a java worker");
|
||||
Class<?> cls = Class.forName(driverClass);
|
||||
cls.getMethod("main", String[].class).invoke(null, (Object) new String[]{});
|
||||
cls.getMethod("main", String[].class).invoke(null, (Object) new String[] {});
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
System.exit(-1);
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.ray.core.RayRuntime;
|
||||
import org.ray.core.model.WorkerMode;
|
||||
|
||||
/**
|
||||
* default worker implementation
|
||||
* default worker implementation.
|
||||
*/
|
||||
public class DefaultWorker {
|
||||
|
||||
|
||||
@@ -5,9 +5,6 @@ import java.io.DataOutputStream;
|
||||
|
||||
public interface FileStoreLink {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
boolean mkdirs(String f);
|
||||
|
||||
/**
|
||||
@@ -32,11 +29,12 @@ public interface FileStoreLink {
|
||||
boolean isFile(String f);
|
||||
|
||||
/**
|
||||
* Delete a file.
|
||||
* delete a file.
|
||||
*
|
||||
* @param f the path to delete.
|
||||
* @param f the path to delete.
|
||||
* @param recursive if path is a directory and set to true, the directory is deleted else throws
|
||||
* an exception. In case of a file the recursive can be set to either true or false.
|
||||
* an exception. In case of a file the recursive can be set to either true or
|
||||
* false.
|
||||
* @return true if delete is successful else false.
|
||||
*/
|
||||
boolean delete(String f, boolean recursive);
|
||||
|
||||
@@ -5,94 +5,94 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Ray K/V abstraction
|
||||
* Ray K/V abstraction.
|
||||
*/
|
||||
public interface KeyValueStoreLink {
|
||||
|
||||
/**
|
||||
* set address of kv store: format "ip:port"
|
||||
* set address of kv store: format "ip:port".
|
||||
*/
|
||||
void SetAddr(String addr);
|
||||
void setAddr(String addr);
|
||||
|
||||
/**
|
||||
* check if the kvstore client connected
|
||||
* check if the kvstore client connected.
|
||||
*/
|
||||
void CheckConnected() throws Exception;
|
||||
void checkConnected() throws Exception;
|
||||
|
||||
/**
|
||||
* Set Key-value into State Store, such as redis
|
||||
* set Key-value into State Store, such as redis.
|
||||
*
|
||||
* @param key the key to set
|
||||
* @param key the key to set
|
||||
* @param value the value to set
|
||||
* @param field the field is being set when the item is a hash If it is not hash field should be
|
||||
* filled with null
|
||||
* filled with null
|
||||
* @return If the key(or field) already exists, and the StateStoreSet just produced an update of
|
||||
* the value, 0 is returned, otherwise if a new key(or field) is created 1 is returned.
|
||||
* the value, 0 is returned, otherwise if a new key(or field) is created 1 is returned.
|
||||
*/
|
||||
Long Set(final String key, final String value, final String field);
|
||||
Long set(final String key, final String value, final String field);
|
||||
|
||||
Long Set(final byte[] key, final byte[] value, final byte[] field);
|
||||
Long set(final byte[] key, final byte[] value, final byte[] field);
|
||||
|
||||
/**
|
||||
* multi hash value set
|
||||
* multi hash value set.
|
||||
*
|
||||
* @param key the key in kvStore
|
||||
* @param key the key in kvStore
|
||||
* @param hash the multi hash value to be set
|
||||
* @return Return OK or Exception if hash is empty
|
||||
*/
|
||||
String Hmset(final String key, final Map<String, String> hash);
|
||||
String hmset(final String key, final Map<String, String> hash);
|
||||
|
||||
String Hmset(final byte[] key, final Map<byte[], byte[]> hash);
|
||||
String hmset(final byte[] key, final Map<byte[], byte[]> hash);
|
||||
|
||||
/**
|
||||
* multi hash value get
|
||||
* multi hash value get.
|
||||
*
|
||||
* @param key the key in kvStore
|
||||
* @param key the key in kvStore
|
||||
* @param fields the fields to be get
|
||||
* @return Multi Bulk Reply specifically a list of all the values associated with the specified
|
||||
* fields, in the same order of the request.
|
||||
* fields, in the same order of the request.
|
||||
*/
|
||||
List<String> Hmget(final String key, final String... fields);
|
||||
List<String> hmget(final String key, final String... fields);
|
||||
|
||||
List<byte[]> Hmget(final byte[] key, final byte[]... fields);
|
||||
List<byte[]> hmget(final byte[] key, final byte[]... fields);
|
||||
|
||||
/**
|
||||
* Get the value of the specified key from State Store
|
||||
* get the value of the specified key from State Store.
|
||||
*
|
||||
* @param key the key to get
|
||||
* @param key the key to get
|
||||
* @param field the field is being got when the item is a hash If it is not hash field should be
|
||||
* filled with null
|
||||
* filled with null
|
||||
* @return Bulk reply If the key does not exist null is returned.
|
||||
*/
|
||||
String Get(final String key, final String field);
|
||||
String get(final String key, final String field);
|
||||
|
||||
byte[] Get(final byte[] key, final byte[] field);
|
||||
byte[] get(final byte[] key, final byte[] field);
|
||||
|
||||
/**
|
||||
* Delete the key(or the specified field of the key) from State Store
|
||||
* delete the key(or the specified field of the key) from State Store.
|
||||
*
|
||||
* @param key the key to delete
|
||||
* @param key the key to delete
|
||||
* @param field the field is to delete when the item is a hash If it is not hash field should be
|
||||
* filled with null
|
||||
* filled with null
|
||||
* @return Integer reply, specifically: an integer greater than 0 if the key(or the field) was
|
||||
* removed 0 if none of the specified key existed
|
||||
* removed 0 if none of the specified key existed
|
||||
*/
|
||||
Long Delete(final String key, final String field);
|
||||
Long delete(final String key, final String field);
|
||||
|
||||
Long Delete(final byte[] key, final byte[] field);
|
||||
Long delete(final byte[] key, final byte[] field);
|
||||
|
||||
/**
|
||||
* get all keys which fit the pattern
|
||||
* get all keys which fit the pattern.
|
||||
*/
|
||||
Set<byte[]> Keys(final byte[] pattern);
|
||||
Set<byte[]> keys(final byte[] pattern);
|
||||
|
||||
/**
|
||||
* get all keys which fit the pattern
|
||||
* get all keys which fit the pattern.
|
||||
*/
|
||||
Set<String> Keys(String pattern);
|
||||
Set<String> keys(String pattern);
|
||||
|
||||
/**
|
||||
* get all hash of the key
|
||||
* get all hash of the key.
|
||||
*/
|
||||
Map<byte[], byte[]> hgetAll(final byte[] key);
|
||||
|
||||
@@ -101,25 +101,26 @@ public interface KeyValueStoreLink {
|
||||
*
|
||||
* @return Multi bulk reply, specifically a list of elements in the specified range.
|
||||
*/
|
||||
List<String> Lrange(final String key, final long start, final long end);
|
||||
List<String> lrange(final String key, final long start, final long end);
|
||||
|
||||
/**
|
||||
* Rpush.
|
||||
* @return Integer reply, specifically, the number of elements inside the list after the push
|
||||
* operation.
|
||||
* operation.
|
||||
*/
|
||||
Long Rpush(final String key, final String... strings);
|
||||
Long rpush(final String key, final String... strings);
|
||||
|
||||
Long Rpush(final byte[] key, final byte[]... strings);
|
||||
Long rpush(final byte[] key, final byte[]... strings);
|
||||
|
||||
/**
|
||||
*
|
||||
* Publish.
|
||||
* @param channel To which channel the message will be published
|
||||
* @param message What to publish
|
||||
* @return the number of clients that received the message
|
||||
*/
|
||||
Long Publish(final String channel, final String message);
|
||||
Long publish(final String channel, final String message);
|
||||
|
||||
Long Publish(byte[] channel, byte[] message);
|
||||
Long publish(byte[] channel, byte[] message);
|
||||
|
||||
Object GetImpl();
|
||||
Object getImpl();
|
||||
}
|
||||
|
||||
@@ -5,28 +5,31 @@ import java.util.Set;
|
||||
import org.ray.spi.model.AddressInfo;
|
||||
|
||||
/**
|
||||
* Proxy client for state store, for instance redis
|
||||
* Proxy client for state store, for instance redis.
|
||||
*/
|
||||
public interface StateStoreProxy {
|
||||
|
||||
/**
|
||||
* setStore.
|
||||
* @param rayKvStore the underlying kv store used to store states
|
||||
*/
|
||||
void setStore(KeyValueStoreLink rayKvStore);
|
||||
|
||||
|
||||
/**
|
||||
* initialize the store
|
||||
* initialize the store.
|
||||
*/
|
||||
void initializeGlobalState() throws Exception;
|
||||
|
||||
/**
|
||||
* keys.
|
||||
* @param pattern filter which keys you are interested in.
|
||||
*/
|
||||
Set<String> keys(final String pattern);
|
||||
|
||||
/**
|
||||
* getAddressInfo.
|
||||
* @return list of address information
|
||||
*/
|
||||
List<AddressInfo> getAddressInfo(final String node_ip_address, int num_retries);
|
||||
List<AddressInfo> getAddressInfo(final String nodeIpAddress, int numRetries);
|
||||
}
|
||||
|
||||
@@ -2,43 +2,91 @@ package org.ray.spi.impl;
|
||||
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.Table;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class Arg extends Table {
|
||||
public static Arg getRootAsArg(ByteBuffer _bb) { return getRootAsArg(_bb, new Arg()); }
|
||||
public static Arg getRootAsArg(ByteBuffer _bb, Arg obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
|
||||
public Arg __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
public static Arg getRootAsArg(ByteBuffer _bb) {
|
||||
return getRootAsArg(_bb, new Arg());
|
||||
}
|
||||
|
||||
public String objectIds(int j) { int o = __offset(4); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int objectIdsLength() { int o = __offset(4); return o != 0 ? __vector_len(o) : 0; }
|
||||
public String data() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer dataAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
|
||||
public static Arg getRootAsArg(ByteBuffer _bb, Arg obj) {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
|
||||
}
|
||||
|
||||
public Arg __assign(int _i, ByteBuffer _bb) {
|
||||
__init(_i, _bb);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void __init(int _i, ByteBuffer _bb) {
|
||||
bb_pos = _i;
|
||||
bb = _bb;
|
||||
}
|
||||
|
||||
public static int createArg(FlatBufferBuilder builder,
|
||||
int object_idsOffset,
|
||||
int dataOffset) {
|
||||
int object_idsOffset,
|
||||
int dataOffset) {
|
||||
builder.startObject(2);
|
||||
Arg.addData(builder, dataOffset);
|
||||
Arg.addObjectIds(builder, object_idsOffset);
|
||||
return Arg.endArg(builder);
|
||||
}
|
||||
|
||||
public static void startArg(FlatBufferBuilder builder) { builder.startObject(2); }
|
||||
public static void addObjectIds(FlatBufferBuilder builder, int objectIdsOffset) { builder.addOffset(0, objectIdsOffset, 0); }
|
||||
public static int createObjectIdsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startObjectIdsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(1, dataOffset, 0); }
|
||||
public static void addData(FlatBufferBuilder builder, int dataOffset) {
|
||||
builder.addOffset(1, dataOffset, 0);
|
||||
}
|
||||
|
||||
public static void addObjectIds(FlatBufferBuilder builder, int objectIdsOffset) {
|
||||
builder.addOffset(0, objectIdsOffset, 0);
|
||||
}
|
||||
|
||||
public static int endArg(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
|
||||
//this is manually added to avoid encoding/decoding cost as our object id is a byte array instead of a string
|
||||
public static void startArg(FlatBufferBuilder builder) {
|
||||
builder.startObject(2);
|
||||
}
|
||||
|
||||
public static int createObjectIdsVector(FlatBufferBuilder builder, int[] data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (int i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
public static void startObjectIdsVector(FlatBufferBuilder builder, int numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
public String objectIds(int j) {
|
||||
int o = __offset(4);
|
||||
return o != 0 ? __string(__vector(o) + j * 4) : null;
|
||||
}
|
||||
|
||||
public int objectIdsLength() {
|
||||
int o = __offset(4);
|
||||
return o != 0 ? __vector_len(o) : 0;
|
||||
}
|
||||
|
||||
public String data() {
|
||||
int o = __offset(6);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer dataAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(6, 1);
|
||||
}
|
||||
|
||||
//this is manually added to avoid encoding/decoding cost as our object id is a byte array
|
||||
// instead of a string
|
||||
public ByteBuffer objectIdAsByteBuffer(int j) {
|
||||
int o = __offset(4);
|
||||
if (o == 0) {
|
||||
|
||||
+145
-146
@@ -13,145 +13,74 @@ import org.ray.spi.model.TaskSpec;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* JNI-based local scheduler link provider
|
||||
* JNI-based local scheduler link provider.
|
||||
*/
|
||||
public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
|
||||
public DefaultLocalSchedulerClient(String schedulerSockName, UniqueID clientId, UniqueID actorId,
|
||||
boolean isWorker, long numGpus) {
|
||||
_client = _init(schedulerSockName, clientId.getBytes(), actorId.getBytes(), isWorker,
|
||||
numGpus);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void submitTask(TaskSpec task) {
|
||||
ByteBuffer info = TaskSpec2Info(task);
|
||||
byte[] a = null;
|
||||
if(!task.actorId.isNil()) {
|
||||
a = task.cursorId.getBytes();
|
||||
}
|
||||
_submitTask(_client, a, info, info.position(), info.remaining());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskSpec getTaskTodo() {
|
||||
byte[] bytes = _getTaskTodo(_client);
|
||||
assert (null != bytes);
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
return TaskInfo2Spec(bb);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
_destroy(_client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUnblocked() {
|
||||
_notify_unblocked(_client);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconstructObject(UniqueID objectId) {
|
||||
_reconstruct_object(_client, objectId.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) {
|
||||
_put_object(_client, taskId.getBytes(), objectId.getBytes());
|
||||
}
|
||||
|
||||
private long _client = 0;
|
||||
|
||||
private static ThreadLocal<ByteBuffer> _taskBuffer = ThreadLocal.withInitial(() -> {
|
||||
ByteBuffer bb = ByteBuffer
|
||||
.allocateDirect(RayRuntime.getParams().max_submit_task_buffer_size_bytes);
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return bb;
|
||||
});
|
||||
private long client = 0;
|
||||
|
||||
public static ByteBuffer TaskSpec2Info(TaskSpec task) {
|
||||
ByteBuffer bb = _taskBuffer.get();
|
||||
bb.clear();
|
||||
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(bb);
|
||||
|
||||
int driver_idOffset = fbb.createString(task.driverId.ToByteBuffer());
|
||||
int task_idOffset = fbb.createString(task.taskId.ToByteBuffer());
|
||||
int parent_task_idOffset = fbb.createString(task.parentTaskId.ToByteBuffer());
|
||||
int parent_counter = task.parentCounter;
|
||||
int actorCreate_idOffset = fbb.createString(task.createActorId.ToByteBuffer());
|
||||
int actorCreateDummy_idOffset = fbb.createString(UniqueID.nil.ToByteBuffer());
|
||||
int actor_idOffset = fbb.createString(task.actorId.ToByteBuffer());
|
||||
int actor_handle_idOffset = fbb.createString(task.actorHandleId.ToByteBuffer());
|
||||
int actor_counter = task.actorCounter;
|
||||
int function_idOffset = fbb.createString(task.functionId.ToByteBuffer());
|
||||
|
||||
// serialize args
|
||||
int[] argsOffsets = new int[task.args.length];
|
||||
for (int i = 0; i < argsOffsets.length; i++) {
|
||||
|
||||
int object_idOffset = 0;
|
||||
int dataOffset = 0;
|
||||
if (task.args[i].ids != null) {
|
||||
int id_count = task.args[i].ids.size();
|
||||
int[] idOffsets = new int[id_count];
|
||||
for (int k = 0; k < id_count; k++) {
|
||||
idOffsets[k] = fbb.createString(task.args[i].ids.get(k).ToByteBuffer());
|
||||
}
|
||||
object_idOffset = fbb.createVectorOfTables(idOffsets);
|
||||
}
|
||||
if (task.args[i].data != null) {
|
||||
dataOffset = fbb.createString(ByteBuffer.wrap(task.args[i].data));
|
||||
}
|
||||
|
||||
argsOffsets[i] = Arg.createArg(fbb, object_idOffset, dataOffset);
|
||||
}
|
||||
int argsOffset = fbb.createVectorOfTables(argsOffsets);
|
||||
|
||||
// serialize returns
|
||||
int return_count = task.returnIds.length;
|
||||
int[] returnsOffsets = new int[return_count];
|
||||
for (int k = 0; k < return_count; k++) {
|
||||
returnsOffsets[k] = fbb.createString(task.returnIds[k].ToByteBuffer());
|
||||
}
|
||||
int returnsOffset = fbb.createVectorOfTables(returnsOffsets);
|
||||
|
||||
// serialize required resources
|
||||
// The required_resources vector indicates the quantities of the different
|
||||
// resources required by this task. The index in this vector corresponds to
|
||||
// the resource type defined in the ResourceIndex enum. For example,
|
||||
|
||||
int[] required_resourcesOffsets = new int[1];
|
||||
for (int i = 0; i < required_resourcesOffsets.length; i++) {
|
||||
int keyOffset = 0;
|
||||
keyOffset = fbb.createString(ByteBuffer.wrap("CPU".getBytes()));
|
||||
required_resourcesOffsets[i] = ResourcePair.createResourcePair(fbb,keyOffset,0.0);
|
||||
}
|
||||
int requiredResourcesOffset = fbb.createVectorOfTables(required_resourcesOffsets);
|
||||
|
||||
int root = TaskInfo.createTaskInfo(
|
||||
fbb, driver_idOffset, task_idOffset,
|
||||
parent_task_idOffset, parent_counter,
|
||||
actorCreate_idOffset, actorCreateDummy_idOffset,
|
||||
actor_idOffset, actor_handle_idOffset, actor_counter,
|
||||
false, function_idOffset,
|
||||
argsOffset, returnsOffset, requiredResourcesOffset);
|
||||
|
||||
fbb.finish(root);
|
||||
ByteBuffer buffer = fbb.dataBuffer();
|
||||
|
||||
if (buffer.remaining() > RayRuntime.getParams().max_submit_task_buffer_size_bytes) {
|
||||
RayLog.core.error(
|
||||
"Allocated buffer is not enough to transfer the task specification: " + RayRuntime
|
||||
.getParams().max_submit_task_buffer_size_bytes + " vs " + buffer.remaining());
|
||||
assert (false);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
public DefaultLocalSchedulerClient(String schedulerSockName, UniqueID clientId, UniqueID actorId,
|
||||
boolean isWorker, long numGpus) {
|
||||
client = _init(schedulerSockName, clientId.getBytes(), actorId.getBytes(), isWorker,
|
||||
numGpus);
|
||||
}
|
||||
|
||||
public static TaskSpec TaskInfo2Spec(ByteBuffer bb) {
|
||||
private static native long _init(String localSchedulerSocket, byte[] workerId, byte[] actorId,
|
||||
boolean isWorker, long numGpus);
|
||||
|
||||
private static native byte[] _computePutId(long client, byte[] taskId, int putIndex);
|
||||
|
||||
private static native void _task_done(long client);
|
||||
|
||||
@Override
|
||||
public void submitTask(TaskSpec task) {
|
||||
ByteBuffer info = taskSpec2Info(task);
|
||||
byte[] a = null;
|
||||
if (!task.actorId.isNil()) {
|
||||
a = task.cursorId.getBytes();
|
||||
}
|
||||
_submitTask(client, a, info, info.position(), info.remaining());
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskSpec getTaskTodo() {
|
||||
byte[] bytes = _getTaskTodo(client);
|
||||
assert (null != bytes);
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
return taskInfo2Spec(bb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markTaskPutDependency(UniqueID taskId, UniqueID objectId) {
|
||||
_put_object(client, taskId.getBytes(), objectId.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconstructObject(UniqueID objectId) {
|
||||
_reconstruct_object(client, objectId.getBytes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUnblocked() {
|
||||
_notify_unblocked(client);
|
||||
}
|
||||
|
||||
private static native void _notify_unblocked(long client);
|
||||
|
||||
private static native void _reconstruct_object(long client, byte[] objectId);
|
||||
|
||||
private static native void _put_object(long client, byte[] taskId, byte[] objectId);
|
||||
|
||||
// return TaskInfo (in FlatBuffer)
|
||||
private static native byte[] _getTaskTodo(long client);
|
||||
|
||||
public static TaskSpec taskInfo2Spec(ByteBuffer bb) {
|
||||
bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
TaskInfo info = TaskInfo.getRootAsTaskInfo(bb);
|
||||
|
||||
@@ -171,10 +100,10 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
FunctionArg darg = new FunctionArg();
|
||||
Arg sarg = info.args(i);
|
||||
|
||||
int id_count = sarg.objectIdsLength();
|
||||
if (id_count > 0) {
|
||||
int idCount = sarg.objectIdsLength();
|
||||
if (idCount > 0) {
|
||||
darg.ids = new ArrayList<>();
|
||||
for (int j = 0; j < id_count; j++) {
|
||||
for (int j = 0; j < idCount; j++) {
|
||||
ByteBuffer lbb = sarg.objectIdAsByteBuffer(j);
|
||||
assert (lbb != null && lbb.remaining() > 0);
|
||||
darg.ids.add(new UniqueID(lbb));
|
||||
@@ -203,24 +132,94 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
return spec;
|
||||
}
|
||||
|
||||
native private static long _init(String localSchedulerSocket, byte[] workerId, byte[] actorId,
|
||||
boolean isWorker, long numGpus);
|
||||
public static ByteBuffer taskSpec2Info(TaskSpec task) {
|
||||
ByteBuffer bb = _taskBuffer.get();
|
||||
bb.clear();
|
||||
|
||||
FlatBufferBuilder fbb = new FlatBufferBuilder(bb);
|
||||
|
||||
final int driverIdOffset = fbb.createString(task.driverId.toByteBuffer());
|
||||
final int taskIdOffset = fbb.createString(task.taskId.toByteBuffer());
|
||||
final int parentTaskIdOffset = fbb.createString(task.parentTaskId.toByteBuffer());
|
||||
final int parentCounter = task.parentCounter;
|
||||
final int actorCreateIdOffset = fbb.createString(task.createActorId.toByteBuffer());
|
||||
final int actorCreateDummyIdOffset = fbb.createString(UniqueID.nil.toByteBuffer());
|
||||
final int actorIdOffset = fbb.createString(task.actorId.toByteBuffer());
|
||||
final int actorHandleIdOffset = fbb.createString(task.actorHandleId.toByteBuffer());
|
||||
final int actorCounter = task.actorCounter;
|
||||
final int functionIdOffset = fbb.createString(task.functionId.toByteBuffer());
|
||||
|
||||
// serialize args
|
||||
int[] argsOffsets = new int[task.args.length];
|
||||
for (int i = 0; i < argsOffsets.length; i++) {
|
||||
|
||||
int objectIdOffset = 0;
|
||||
int dataOffset = 0;
|
||||
if (task.args[i].ids != null) {
|
||||
int idCount = task.args[i].ids.size();
|
||||
int[] idOffsets = new int[idCount];
|
||||
for (int k = 0; k < idCount; k++) {
|
||||
idOffsets[k] = fbb.createString(task.args[i].ids.get(k).toByteBuffer());
|
||||
}
|
||||
objectIdOffset = fbb.createVectorOfTables(idOffsets);
|
||||
}
|
||||
if (task.args[i].data != null) {
|
||||
dataOffset = fbb.createString(ByteBuffer.wrap(task.args[i].data));
|
||||
}
|
||||
|
||||
argsOffsets[i] = Arg.createArg(fbb, objectIdOffset, dataOffset);
|
||||
}
|
||||
int argsOffset = fbb.createVectorOfTables(argsOffsets);
|
||||
|
||||
// serialize returns
|
||||
int returnCount = task.returnIds.length;
|
||||
int[] returnsOffsets = new int[returnCount];
|
||||
for (int k = 0; k < returnCount; k++) {
|
||||
returnsOffsets[k] = fbb.createString(task.returnIds[k].toByteBuffer());
|
||||
}
|
||||
int returnsOffset = fbb.createVectorOfTables(returnsOffsets);
|
||||
|
||||
// serialize required resources
|
||||
// The required_resources vector indicates the quantities of the different
|
||||
// resources required by this task. The index in this vector corresponds to
|
||||
// the resource type defined in the ResourceIndex enum. For example,
|
||||
|
||||
int[]requiredResourcesOffsets = new int[1];
|
||||
for (int i = 0; i < requiredResourcesOffsets.length; i++) {
|
||||
int keyOffset = 0;
|
||||
keyOffset = fbb.createString(ByteBuffer.wrap("CPU".getBytes()));
|
||||
requiredResourcesOffsets[i] = ResourcePair.createResourcePair(fbb, keyOffset, 0.0);
|
||||
}
|
||||
int requiredResourcesOffset = fbb.createVectorOfTables(requiredResourcesOffsets);
|
||||
|
||||
int root = TaskInfo.createTaskInfo(
|
||||
fbb, driverIdOffset, taskIdOffset,
|
||||
parentTaskIdOffset, parentCounter,
|
||||
actorCreateIdOffset, actorCreateDummyIdOffset,
|
||||
actorIdOffset, actorHandleIdOffset, actorCounter,
|
||||
false, functionIdOffset,
|
||||
argsOffset, returnsOffset, requiredResourcesOffset);
|
||||
|
||||
fbb.finish(root);
|
||||
ByteBuffer buffer = fbb.dataBuffer();
|
||||
|
||||
if (buffer.remaining() > RayRuntime.getParams().max_submit_task_buffer_size_bytes) {
|
||||
RayLog.core.error(
|
||||
"Allocated buffer is not enough to transfer the task specification: " + RayRuntime
|
||||
.getParams().max_submit_task_buffer_size_bytes + " vs " + buffer.remaining());
|
||||
assert (false);
|
||||
}
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
// task -> TaskInfo (with FlatBuffer)
|
||||
native private static void _submitTask(long client, byte[] cursorId, /*Direct*/ByteBuffer task, int pos, int sz);
|
||||
private static native void _submitTask(long client, byte[] cursorId, /*Direct*/ByteBuffer task,
|
||||
int pos, int sz);
|
||||
|
||||
// return TaskInfo (in FlatBuffer)
|
||||
native private static byte[] _getTaskTodo(long client);
|
||||
public void destroy() {
|
||||
_destroy(client);
|
||||
}
|
||||
|
||||
native private static byte[] _computePutId(long client, byte[] taskId, int putIndex);
|
||||
|
||||
native private static void _destroy(long client);
|
||||
|
||||
native private static void _task_done(long client);
|
||||
|
||||
native private static void _reconstruct_object(long client, byte[] objectId);
|
||||
|
||||
native private static void _notify_unblocked(long client);
|
||||
|
||||
native private static void _put_object(long client, byte[] taskId, byte[] objectId);
|
||||
private static native void _destroy(long client);
|
||||
}
|
||||
|
||||
+13
-13
@@ -17,10 +17,15 @@ import org.ray.util.SystemUtil;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* native implementation of remote function manager
|
||||
* native implementation of remote function manager.
|
||||
*/
|
||||
public class NativeRemoteFunctionManager implements RemoteFunctionManager {
|
||||
|
||||
private ConcurrentHashMap<UniqueID, LoadedFunctions> loadedApps = new ConcurrentHashMap<>();
|
||||
private MessageDigest md;
|
||||
private String appDir = System.getProperty("user.dir") + "/apps";
|
||||
private KeyValueStoreLink kvStore;
|
||||
|
||||
public NativeRemoteFunctionManager(KeyValueStoreLink kvStore) throws NoSuchAlgorithmException {
|
||||
this.kvStore = kvStore;
|
||||
md = MessageDigest.getInstance("SHA-1");
|
||||
@@ -42,36 +47,36 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
|
||||
// instead of cache
|
||||
//if (!Ray.exist(resourceId)) {
|
||||
//Ray.put(resourceId, resourceZip);
|
||||
kvStore.Set(resourceId.getBytes(), resourceZip, null);
|
||||
kvStore.set(resourceId.getBytes(), resourceZip, null);
|
||||
//}
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getResource(UniqueID resourceId) {
|
||||
return kvStore.Get(resourceId.getBytes(), null);
|
||||
return kvStore.get(resourceId.getBytes(), null);
|
||||
//return (byte[])Ray.get(resourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterResource(UniqueID resourceId) {
|
||||
kvStore.Delete(resourceId.getBytes(), null);
|
||||
kvStore.delete(resourceId.getBytes(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerApp(UniqueID driverId, UniqueID resourceId) {
|
||||
//Ray.put(driverId, resourceId);
|
||||
kvStore.Set("App2ResMap", resourceId.toString(), driverId.toString());
|
||||
kvStore.set("App2ResMap", resourceId.toString(), driverId.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueID getAppResourceId(UniqueID driverId) {
|
||||
return new UniqueID(kvStore.Get("App2ResMap", driverId.toString()));
|
||||
return new UniqueID(kvStore.get("App2ResMap", driverId.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterApp(UniqueID driverId) {
|
||||
kvStore.Delete("App2ResMap", driverId.toString());
|
||||
kvStore.delete("App2ResMap", driverId.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,7 +93,7 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
|
||||
RayLog.core.info("initLoadedApps" + driverId.toString());
|
||||
LoadedFunctions rf = loadedApps.get(driverId);
|
||||
if (rf == null) {
|
||||
UniqueID resId = new UniqueID(kvStore.Get("App2ResMap", driverId.toString()));
|
||||
UniqueID resId = new UniqueID(kvStore.get("App2ResMap", driverId.toString()));
|
||||
//UniqueID resId = Ray.get(driverId);
|
||||
|
||||
byte[] res = getResource(resId);
|
||||
@@ -127,9 +132,4 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
|
||||
RayLog.rapp.error("unload function for " + driverId + " failed, ex = " + e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private ConcurrentHashMap<UniqueID, LoadedFunctions> loadedApps = new ConcurrentHashMap<>();
|
||||
private MessageDigest md;
|
||||
private String appDir = System.getProperty("user.dir") + "/apps";
|
||||
private KeyValueStoreLink kvStore;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,7 @@ package org.ray.spi.impl;
|
||||
*/
|
||||
public class PlasmaObjectExistsException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private static final long serialVersionUID = 9128880292504270291L;
|
||||
|
||||
public PlasmaObjectExistsException() {
|
||||
@@ -16,7 +14,7 @@ public class PlasmaObjectExistsException extends Exception {
|
||||
}
|
||||
|
||||
public PlasmaObjectExistsException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,6 @@ package org.ray.spi.impl;
|
||||
*/
|
||||
public class PlasmaOutOfMemoryException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -2786069077559520659L;
|
||||
|
||||
public PlasmaOutOfMemoryException() {
|
||||
@@ -16,7 +13,7 @@ public class PlasmaOutOfMemoryException extends Exception {
|
||||
}
|
||||
|
||||
public PlasmaOutOfMemoryException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
public RedisClient(String addr) {
|
||||
SetAddr(addr);
|
||||
setAddr(addr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void SetAddr(String addr) {
|
||||
public synchronized void setAddr(String addr) {
|
||||
if (StringUtils.isEmpty(redisAddress)) {
|
||||
redisAddress = addr;
|
||||
String[] ipPort = addr.split(":");
|
||||
@@ -34,14 +34,14 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void CheckConnected() throws Exception {
|
||||
public void checkConnected() throws Exception {
|
||||
if (jedisPool == null) {
|
||||
throw new Exception("the GlobalState API can't be used before ray init.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Set(final String key, final String value, final String field) {
|
||||
public Long set(final String key, final String value, final String field) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (field == null) {
|
||||
jedis.set(key, value);
|
||||
@@ -54,7 +54,7 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Set(byte[] key, byte[] value, byte[] field) {
|
||||
public Long set(byte[] key, byte[] value, byte[] field) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (field == null) {
|
||||
jedis.set(key, value);
|
||||
@@ -67,7 +67,36 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Get(final String key, final String field) {
|
||||
public String hmset(String key, Map<String, String> hash) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmset(key, hash);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String hmset(byte[] key, Map<byte[], byte[]> hash) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmset(key, hash);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> hmget(String key, String... fields) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmget(key, fields);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> hmget(byte[] key, byte[]... fields) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmget(key, fields);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String get(final String key, final String field) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (field == null) {
|
||||
return jedis.get(key);
|
||||
@@ -79,7 +108,7 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] Get(byte[] key, byte[] field) {
|
||||
public byte[] get(byte[] key, byte[] field) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (field == null) {
|
||||
return jedis.get(key);
|
||||
@@ -91,7 +120,7 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Delete(final String key, final String field) {
|
||||
public Long delete(final String key, final String field) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (field == null) {
|
||||
return jedis.del(key);
|
||||
@@ -103,7 +132,7 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Delete(byte[] key, byte[] field) {
|
||||
public Long delete(byte[] key, byte[] field) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
if (field == null) {
|
||||
return jedis.del(key);
|
||||
@@ -115,43 +144,14 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Hmset(String key, Map<String, String> hash) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmset(key, hash);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String Hmset(byte[] key, Map<byte[], byte[]> hash) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmset(key, hash);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> Hmget(String key, String... fields) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmget(key, fields);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<byte[]> Hmget(byte[] key, byte[]... fields) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.hmget(key, fields);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<byte[]> Keys(byte[] pattern) {
|
||||
public Set<byte[]> keys(byte[] pattern) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.keys(pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> Keys(String pattern) {
|
||||
public Set<String> keys(String pattern) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.keys(pattern);
|
||||
}
|
||||
@@ -165,42 +165,42 @@ public class RedisClient implements KeyValueStoreLink {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> Lrange(String key, long start, long end) {
|
||||
public List<String> lrange(String key, long start, long end) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.lrange(key, start, end);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Rpush(String key, String... strings) {
|
||||
public Long rpush(String key, String... strings) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.rpush(key, strings);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Rpush(byte[] key, byte[]... strings) {
|
||||
public Long rpush(byte[] key, byte[]... strings) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.rpush(key, strings);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Publish(String channel, String message) {
|
||||
public Long publish(String channel, String message) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.publish(channel, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long Publish(byte[] channel, byte[] message) {
|
||||
public Long publish(byte[] channel, byte[] message) {
|
||||
try (Jedis jedis = jedisPool.getResource()) {
|
||||
return jedis.publish(channel, message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object GetImpl() {
|
||||
public Object getImpl() {
|
||||
return jedisPool;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,37 +2,70 @@ package org.ray.spi.impl;
|
||||
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.Table;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class ResourcePair extends Table {
|
||||
public static ResourcePair getRootAsResourcePair(ByteBuffer _bb) { return getRootAsResourcePair(_bb, new ResourcePair()); }
|
||||
public static ResourcePair getRootAsResourcePair(ByteBuffer _bb, ResourcePair obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
|
||||
public ResourcePair __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
public static ResourcePair getRootAsResourcePair(ByteBuffer _bb) {
|
||||
return getRootAsResourcePair(_bb, new ResourcePair());
|
||||
}
|
||||
|
||||
public String key() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer keyAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public double value() { int o = __offset(6); return o != 0 ? bb.getDouble(o + bb_pos) : 0.0; }
|
||||
public static ResourcePair getRootAsResourcePair(ByteBuffer _bb, ResourcePair obj) {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
|
||||
}
|
||||
|
||||
public ResourcePair __assign(int _i, ByteBuffer _bb) {
|
||||
__init(_i, _bb);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void __init(int _i, ByteBuffer _bb) {
|
||||
bb_pos = _i;
|
||||
bb = _bb;
|
||||
}
|
||||
|
||||
public static int createResourcePair(FlatBufferBuilder builder,
|
||||
int keyOffset,
|
||||
double value) {
|
||||
int keyOffset,
|
||||
double value) {
|
||||
builder.startObject(2);
|
||||
ResourcePair.addValue(builder, value);
|
||||
ResourcePair.addKey(builder, keyOffset);
|
||||
return ResourcePair.endResourcePair(builder);
|
||||
}
|
||||
|
||||
public static void startResourcePair(FlatBufferBuilder builder) { builder.startObject(2); }
|
||||
public static void addKey(FlatBufferBuilder builder, int keyOffset) { builder.addOffset(0, keyOffset, 0); }
|
||||
public static void addValue(FlatBufferBuilder builder, double value) { builder.addDouble(1, value, 0.0); }
|
||||
public static void addValue(FlatBufferBuilder builder, double value) {
|
||||
builder.addDouble(1, value, 0.0);
|
||||
}
|
||||
|
||||
public static void addKey(FlatBufferBuilder builder, int keyOffset) {
|
||||
builder.addOffset(0, keyOffset, 0);
|
||||
}
|
||||
|
||||
public static int endResourcePair(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
|
||||
public static void startResourcePair(FlatBufferBuilder builder) {
|
||||
builder.startObject(2);
|
||||
}
|
||||
|
||||
public String key() {
|
||||
int o = __offset(4);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer keyAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(4, 1);
|
||||
}
|
||||
|
||||
public double value() {
|
||||
int o = __offset(6);
|
||||
return o != 0 ? bb.getDouble(o + bb_pos) : 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.ray.spi.model.AddressInfo;
|
||||
import org.ray.util.logger.RayLog;
|
||||
|
||||
/**
|
||||
* A class used to interface with the Ray control state
|
||||
* A class used to interface with the Ray control state.
|
||||
*/
|
||||
public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
|
||||
@@ -28,17 +28,13 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
this.rayKvStore = rayKvStore;
|
||||
}
|
||||
|
||||
public void checkConnected() throws Exception {
|
||||
rayKvStore.CheckConnected();
|
||||
}
|
||||
|
||||
public synchronized void initializeGlobalState() throws Exception {
|
||||
|
||||
String es;
|
||||
|
||||
checkConnected();
|
||||
|
||||
String s = rayKvStore.Get("NumRedisShards", null);
|
||||
String s = rayKvStore.get("NumRedisShards", null);
|
||||
if (s == null) {
|
||||
throw new Exception("NumRedisShards not found in redis.");
|
||||
}
|
||||
@@ -47,7 +43,7 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
es = String.format("Expected at least one Redis shard, found %d", numRedisShards);
|
||||
throw new Exception(es);
|
||||
}
|
||||
List<String> ipAddressPorts = rayKvStore.Lrange("RedisShards", 0, -1);
|
||||
List<String> ipAddressPorts = rayKvStore.lrange("RedisShards", 0, -1);
|
||||
if (ipAddressPorts.size() != numRedisShards) {
|
||||
es = String.format("Expected %d Redis shard addresses, found %d.", numRedisShards,
|
||||
ipAddressPorts.size());
|
||||
@@ -61,32 +57,45 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
|
||||
}
|
||||
|
||||
public void checkConnected() throws Exception {
|
||||
rayKvStore.checkConnected();
|
||||
}
|
||||
|
||||
public synchronized Set<String> keys(final String pattern) {
|
||||
Set<String> allKeys = new HashSet<>();
|
||||
Set<String> tmpKey;
|
||||
for (KeyValueStoreLink a_shardStoreList : shardStoreList) {
|
||||
tmpKey = a_shardStoreList.Keys(pattern);
|
||||
for (KeyValueStoreLink ashardStoreList : shardStoreList) {
|
||||
tmpKey = ashardStoreList.keys(pattern);
|
||||
allKeys.addAll(tmpKey);
|
||||
}
|
||||
|
||||
return allKeys;
|
||||
|
||||
}
|
||||
|
||||
private byte[] CharsetEncode(String str, String Charset) throws UnsupportedEncodingException {
|
||||
if (str != null) {
|
||||
return str.getBytes(Charset);
|
||||
public List<AddressInfo> getAddressInfo(final String nodeIpAddress, int numRetries) {
|
||||
int count = 0;
|
||||
while (count < numRetries) {
|
||||
try {
|
||||
return getAddressInfoHelper(nodeIpAddress);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
RayLog.core.error("error at StateStoreProxyImpl getAddressInfo", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private String CharsetDecode(byte[] bs, String Charset) throws UnsupportedEncodingException {
|
||||
return new String(bs, Charset);
|
||||
throw new RuntimeException("cannot get address info from state store");
|
||||
}
|
||||
|
||||
/*
|
||||
* get address info of one node from primary redis
|
||||
* @param: node ip address, usually local ip address
|
||||
* @return: a list of SchedulerInfo which contains storeName, managerName, managerPort and schedulerName
|
||||
* @return: a list of SchedulerInfo which contains storeName, managerName, managerPort and
|
||||
* schedulerName
|
||||
* @note:Redis data key is "CL:*", redis data value is a hash.
|
||||
* The hash contains the following:
|
||||
* "deleted" : 0/1
|
||||
@@ -103,7 +112,7 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
}
|
||||
List<AddressInfo> schedulerInfo = new ArrayList<>();
|
||||
|
||||
Set<byte[]> cks = rayKvStore.Keys("CL:*".getBytes());
|
||||
Set<byte[]> cks = rayKvStore.keys("CL:*".getBytes());
|
||||
byte[] key;
|
||||
List<Map<byte[], byte[]>> plasmaManager = new ArrayList<>();
|
||||
List<Map<byte[], byte[]>> localScheduler = new ArrayList<>();
|
||||
@@ -111,7 +120,7 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
key = ck;
|
||||
Map<byte[], byte[]> info = rayKvStore.hgetAll(key);
|
||||
|
||||
String deleted = CharsetDecode(info.get("deleted".getBytes()), "US-ASCII");
|
||||
String deleted = charsetDecode(info.get("deleted".getBytes()), "US-ASCII");
|
||||
if (deleted != null) {
|
||||
if (Boolean.getBoolean(deleted)) {
|
||||
continue;
|
||||
@@ -126,9 +135,9 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
throw new Exception("no client_type in any client");
|
||||
}
|
||||
|
||||
if (CharsetDecode(info.get("nodeIpAddress".getBytes()), "US-ASCII")
|
||||
if (charsetDecode(info.get("nodeIpAddress".getBytes()), "US-ASCII")
|
||||
.equals(nodeIpAddress)) {
|
||||
String clientType = CharsetDecode(info.get("client_type".getBytes()), "US-ASCII");
|
||||
String clientType = charsetDecode(info.get("client_type".getBytes()), "US-ASCII");
|
||||
if (clientType.equals("plasmaManager")) {
|
||||
plasmaManager.add(info);
|
||||
} else if (clientType.equals("localScheduler")) {
|
||||
@@ -145,30 +154,30 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
|
||||
for (int i = 0; i < plasmaManager.size(); i++) {
|
||||
AddressInfo si = new AddressInfo();
|
||||
si.storeName = CharsetDecode(plasmaManager.get(i).get("store_socket_name".getBytes()),
|
||||
si.storeName = charsetDecode(plasmaManager.get(i).get("store_socket_name".getBytes()),
|
||||
"US-ASCII");
|
||||
si.managerName = CharsetDecode(plasmaManager.get(i).get("manager_socket_name".getBytes()),
|
||||
si.managerName = charsetDecode(plasmaManager.get(i).get("manager_socket_name".getBytes()),
|
||||
"US-ASCII");
|
||||
|
||||
byte[] rpc = plasmaManager.get(i).get("manager_rpc_name".getBytes());
|
||||
if (rpc != null) {
|
||||
si.managerRpcAddr = CharsetDecode(rpc, "US-ASCII");
|
||||
si.managerRpcAddr = charsetDecode(rpc, "US-ASCII");
|
||||
}
|
||||
|
||||
rpc = plasmaManager.get(i).get("store_rpc_name".getBytes());
|
||||
if (rpc != null) {
|
||||
si.storeRpcAddr = CharsetDecode(rpc, "US-ASCII");
|
||||
si.storeRpcAddr = charsetDecode(rpc, "US-ASCII");
|
||||
}
|
||||
|
||||
String managerAddr = CharsetDecode(plasmaManager.get(i).get("manager_address".getBytes()),
|
||||
String managerAddr = charsetDecode(plasmaManager.get(i).get("manager_address".getBytes()),
|
||||
"US-ASCII");
|
||||
si.managerPort = Integer.parseInt(managerAddr.split(":")[1]);
|
||||
si.schedulerName = CharsetDecode(
|
||||
si.schedulerName = charsetDecode(
|
||||
localScheduler.get(i).get("local_scheduler_socket_name".getBytes()), "US-ASCII");
|
||||
|
||||
rpc = localScheduler.get(i).get("local_scheduler_rpc_name".getBytes());
|
||||
if (rpc != null) {
|
||||
si.schedulerRpcAddr = CharsetDecode(rpc, "US-ASCII");
|
||||
si.schedulerRpcAddr = charsetDecode(rpc, "US-ASCII");
|
||||
}
|
||||
|
||||
schedulerInfo.add(si);
|
||||
@@ -177,21 +186,14 @@ public class StateStoreProxyImpl implements StateStoreProxy {
|
||||
return schedulerInfo;
|
||||
}
|
||||
|
||||
public List<AddressInfo> getAddressInfo(final String node_ip_address, int numRetries) {
|
||||
int count = 0;
|
||||
while (count < numRetries) {
|
||||
try {
|
||||
return getAddressInfoHelper(node_ip_address);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(1000);
|
||||
} catch (InterruptedException ie) {
|
||||
RayLog.core.error("error at StateStoreProxyImpl getAddressInfo", e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
count++;
|
||||
private String charsetDecode(byte[] bs, String charset) throws UnsupportedEncodingException {
|
||||
return new String(bs, charset);
|
||||
}
|
||||
|
||||
private byte[] charsetEncode(String str, String charset) throws UnsupportedEncodingException {
|
||||
if (str != null) {
|
||||
return str.getBytes(charset);
|
||||
}
|
||||
throw new RuntimeException("cannot get address info from state store");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +1,47 @@
|
||||
package org.ray.spi.impl;
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
|
||||
import java.nio.*;
|
||||
import java.lang.*;
|
||||
import java.util.*;
|
||||
import com.google.flatbuffers.*;
|
||||
import com.google.flatbuffers.FlatBufferBuilder;
|
||||
import com.google.flatbuffers.Table;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class TaskInfo extends Table {
|
||||
public static TaskInfo getRootAsTaskInfo(ByteBuffer _bb) { return getRootAsTaskInfo(_bb, new TaskInfo()); }
|
||||
public static TaskInfo getRootAsTaskInfo(ByteBuffer _bb, TaskInfo obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
|
||||
public void __init(int _i, ByteBuffer _bb) { bb_pos = _i; bb = _bb; }
|
||||
public TaskInfo __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
public static TaskInfo getRootAsTaskInfo(ByteBuffer _bb) {
|
||||
return getRootAsTaskInfo(_bb, new TaskInfo());
|
||||
}
|
||||
|
||||
public String driverId() { int o = __offset(4); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer driverIdAsByteBuffer() { return __vector_as_bytebuffer(4, 1); }
|
||||
public String taskId() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer taskIdAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
|
||||
public String parentTaskId() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer parentTaskIdAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
|
||||
public int parentCounter() { int o = __offset(10); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public String actorCreationId() { int o = __offset(12); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer actorCreationIdAsByteBuffer() { return __vector_as_bytebuffer(12, 1); }
|
||||
public String actorCreationDummyObjectId() { int o = __offset(14); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer actorCreationDummyObjectIdAsByteBuffer() { return __vector_as_bytebuffer(14, 1); }
|
||||
public String actorId() { int o = __offset(16); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer actorIdAsByteBuffer() { return __vector_as_bytebuffer(16, 1); }
|
||||
public String actorHandleId() { int o = __offset(18); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer actorHandleIdAsByteBuffer() { return __vector_as_bytebuffer(18, 1); }
|
||||
public int actorCounter() { int o = __offset(20); return o != 0 ? bb.getInt(o + bb_pos) : 0; }
|
||||
public boolean isActorCheckpointMethod() { int o = __offset(22); return o != 0 ? 0!=bb.get(o + bb_pos) : false; }
|
||||
public String functionId() { int o = __offset(24); return o != 0 ? __string(o + bb_pos) : null; }
|
||||
public ByteBuffer functionIdAsByteBuffer() { return __vector_as_bytebuffer(24, 1); }
|
||||
public Arg args(int j) { return args(new Arg(), j); }
|
||||
public Arg args(Arg obj, int j) { int o = __offset(26); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int argsLength() { int o = __offset(26); return o != 0 ? __vector_len(o) : 0; }
|
||||
public String returns(int j) { int o = __offset(28); return o != 0 ? __string(__vector(o) + j * 4) : null; }
|
||||
public int returnsLength() { int o = __offset(28); return o != 0 ? __vector_len(o) : 0; }
|
||||
public ResourcePair requiredResources(int j) { return requiredResources(new ResourcePair(), j); }
|
||||
public ResourcePair requiredResources(ResourcePair obj, int j) { int o = __offset(30); return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null; }
|
||||
public int requiredResourcesLength() { int o = __offset(30); return o != 0 ? __vector_len(o) : 0; }
|
||||
public static TaskInfo getRootAsTaskInfo(ByteBuffer _bb, TaskInfo obj) {
|
||||
_bb.order(ByteOrder.LITTLE_ENDIAN);
|
||||
return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb));
|
||||
}
|
||||
|
||||
public TaskInfo __assign(int _i, ByteBuffer _bb) {
|
||||
__init(_i, _bb);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void __init(int _i, ByteBuffer _bb) {
|
||||
bb_pos = _i;
|
||||
bb = _bb;
|
||||
}
|
||||
|
||||
public static int createTaskInfo(FlatBufferBuilder builder,
|
||||
int driver_idOffset,
|
||||
int task_idOffset,
|
||||
int parent_task_idOffset,
|
||||
int parent_counter,
|
||||
int actor_creation_idOffset,
|
||||
int actor_creation_dummy_object_idOffset,
|
||||
int actor_idOffset,
|
||||
int actor_handle_idOffset,
|
||||
int actor_counter,
|
||||
boolean is_actor_checkpoint_method,
|
||||
int function_idOffset,
|
||||
int argsOffset,
|
||||
int returnsOffset,
|
||||
int required_resourcesOffset) {
|
||||
int driver_idOffset,
|
||||
int task_idOffset,
|
||||
int parent_task_idOffset,
|
||||
int parent_counter,
|
||||
int actor_creation_idOffset,
|
||||
int actor_creation_dummy_object_idOffset,
|
||||
int actor_idOffset,
|
||||
int actor_handle_idOffset,
|
||||
int actor_counter,
|
||||
boolean is_actor_checkpoint_method,
|
||||
int function_idOffset,
|
||||
int argsOffset,
|
||||
int returnsOffset,
|
||||
int required_resourcesOffset) {
|
||||
builder.startObject(14);
|
||||
TaskInfo.addRequiredResources(builder, required_resourcesOffset);
|
||||
TaskInfo.addReturns(builder, returnsOffset);
|
||||
@@ -74,33 +60,236 @@ public final class TaskInfo extends Table {
|
||||
return TaskInfo.endTaskInfo(builder);
|
||||
}
|
||||
|
||||
public static void startTaskInfo(FlatBufferBuilder builder) { builder.startObject(14); }
|
||||
public static void addDriverId(FlatBufferBuilder builder, int driverIdOffset) { builder.addOffset(0, driverIdOffset, 0); }
|
||||
public static void addTaskId(FlatBufferBuilder builder, int taskIdOffset) { builder.addOffset(1, taskIdOffset, 0); }
|
||||
public static void addParentTaskId(FlatBufferBuilder builder, int parentTaskIdOffset) { builder.addOffset(2, parentTaskIdOffset, 0); }
|
||||
public static void addParentCounter(FlatBufferBuilder builder, int parentCounter) { builder.addInt(3, parentCounter, 0); }
|
||||
public static void addActorCreationId(FlatBufferBuilder builder, int actorCreationIdOffset) { builder.addOffset(4, actorCreationIdOffset, 0); }
|
||||
public static void addActorCreationDummyObjectId(FlatBufferBuilder builder, int actorCreationDummyObjectIdOffset) { builder.addOffset(5, actorCreationDummyObjectIdOffset, 0); }
|
||||
public static void addActorId(FlatBufferBuilder builder, int actorIdOffset) { builder.addOffset(6, actorIdOffset, 0); }
|
||||
public static void addActorHandleId(FlatBufferBuilder builder, int actorHandleIdOffset) { builder.addOffset(7, actorHandleIdOffset, 0); }
|
||||
public static void addActorCounter(FlatBufferBuilder builder, int actorCounter) { builder.addInt(8, actorCounter, 0); }
|
||||
public static void addIsActorCheckpointMethod(FlatBufferBuilder builder, boolean isActorCheckpointMethod) { builder.addBoolean(9, isActorCheckpointMethod, false); }
|
||||
public static void addFunctionId(FlatBufferBuilder builder, int functionIdOffset) { builder.addOffset(10, functionIdOffset, 0); }
|
||||
public static void addArgs(FlatBufferBuilder builder, int argsOffset) { builder.addOffset(11, argsOffset, 0); }
|
||||
public static int createArgsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startArgsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addReturns(FlatBufferBuilder builder, int returnsOffset) { builder.addOffset(12, returnsOffset, 0); }
|
||||
public static int createReturnsVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startReturnsVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addRequiredResources(FlatBufferBuilder builder, int requiredResourcesOffset) { builder.addOffset(13, requiredResourcesOffset, 0); }
|
||||
public static int createRequiredResourcesVector(FlatBufferBuilder builder, int[] data) { builder.startVector(4, data.length, 4); for (int i = data.length - 1; i >= 0; i--) builder.addOffset(data[i]); return builder.endVector(); }
|
||||
public static void startRequiredResourcesVector(FlatBufferBuilder builder, int numElems) { builder.startVector(4, numElems, 4); }
|
||||
public static void addRequiredResources(FlatBufferBuilder builder, int requiredResourcesOffset) {
|
||||
builder.addOffset(13, requiredResourcesOffset, 0);
|
||||
}
|
||||
|
||||
public static void addReturns(FlatBufferBuilder builder, int returnsOffset) {
|
||||
builder.addOffset(12, returnsOffset, 0);
|
||||
}
|
||||
|
||||
public static void addArgs(FlatBufferBuilder builder, int argsOffset) {
|
||||
builder.addOffset(11, argsOffset, 0);
|
||||
}
|
||||
|
||||
public static void addFunctionId(FlatBufferBuilder builder, int functionIdOffset) {
|
||||
builder.addOffset(10, functionIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addActorCounter(FlatBufferBuilder builder, int actorCounter) {
|
||||
builder.addInt(8, actorCounter, 0);
|
||||
}
|
||||
|
||||
public static void addActorHandleId(FlatBufferBuilder builder, int actorHandleIdOffset) {
|
||||
builder.addOffset(7, actorHandleIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addActorId(FlatBufferBuilder builder, int actorIdOffset) {
|
||||
builder.addOffset(6, actorIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addActorCreationDummyObjectId(FlatBufferBuilder builder, int
|
||||
actorCreationDummyObjectIdOffset) {
|
||||
builder.addOffset(5, actorCreationDummyObjectIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addActorCreationId(FlatBufferBuilder builder, int actorCreationIdOffset) {
|
||||
builder.addOffset(4, actorCreationIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addParentCounter(FlatBufferBuilder builder, int parentCounter) {
|
||||
builder.addInt(3, parentCounter, 0);
|
||||
}
|
||||
|
||||
public static void addParentTaskId(FlatBufferBuilder builder, int parentTaskIdOffset) {
|
||||
builder.addOffset(2, parentTaskIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addTaskId(FlatBufferBuilder builder, int taskIdOffset) {
|
||||
builder.addOffset(1, taskIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addDriverId(FlatBufferBuilder builder, int driverIdOffset) {
|
||||
builder.addOffset(0, driverIdOffset, 0);
|
||||
}
|
||||
|
||||
public static void addIsActorCheckpointMethod(FlatBufferBuilder builder, boolean
|
||||
isActorCheckpointMethod) {
|
||||
builder.addBoolean(9, isActorCheckpointMethod, false);
|
||||
}
|
||||
|
||||
public static int endTaskInfo(FlatBufferBuilder builder) {
|
||||
int o = builder.endObject();
|
||||
return o;
|
||||
}
|
||||
|
||||
//this is manually added to avoid encoding/decoding cost as our object id is a byte array instead of a string
|
||||
public static void startTaskInfo(FlatBufferBuilder builder) {
|
||||
builder.startObject(14);
|
||||
}
|
||||
|
||||
public static int createArgsVector(FlatBufferBuilder builder, int[] data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (int i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
public static void startArgsVector(FlatBufferBuilder builder, int numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
public static int createReturnsVector(FlatBufferBuilder builder, int[] data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (int i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
public static void startReturnsVector(FlatBufferBuilder builder, int numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
public static int createRequiredResourcesVector(FlatBufferBuilder builder, int[] data) {
|
||||
builder.startVector(4, data.length, 4);
|
||||
for (int i = data.length - 1; i >= 0; i--) {
|
||||
builder.addOffset(data[i]);
|
||||
}
|
||||
return builder.endVector();
|
||||
}
|
||||
|
||||
public static void startRequiredResourcesVector(FlatBufferBuilder builder, int numElems) {
|
||||
builder.startVector(4, numElems, 4);
|
||||
}
|
||||
|
||||
public String driverId() {
|
||||
int o = __offset(4);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer driverIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(4, 1);
|
||||
}
|
||||
|
||||
public String taskId() {
|
||||
int o = __offset(6);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer taskIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(6, 1);
|
||||
}
|
||||
|
||||
public String parentTaskId() {
|
||||
int o = __offset(8);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer parentTaskIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(8, 1);
|
||||
}
|
||||
|
||||
public int parentCounter() {
|
||||
int o = __offset(10);
|
||||
return o != 0 ? bb.getInt(o + bb_pos) : 0;
|
||||
}
|
||||
|
||||
public String actorCreationId() {
|
||||
int o = __offset(12);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer actorCreationIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(12, 1);
|
||||
}
|
||||
|
||||
public String actorCreationDummyObjectId() {
|
||||
int o = __offset(14);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer actorCreationDummyObjectIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(14, 1);
|
||||
}
|
||||
|
||||
public String actorId() {
|
||||
int o = __offset(16);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer actorIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(16, 1);
|
||||
}
|
||||
|
||||
public String actorHandleId() {
|
||||
int o = __offset(18);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer actorHandleIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(18, 1);
|
||||
}
|
||||
|
||||
public int actorCounter() {
|
||||
int o = __offset(20);
|
||||
return o != 0 ? bb.getInt(o + bb_pos) : 0;
|
||||
}
|
||||
|
||||
public boolean isActorCheckpointMethod() {
|
||||
int o = __offset(22);
|
||||
return o != 0 ? 0 != bb.get(o + bb_pos) : false;
|
||||
}
|
||||
|
||||
public String functionId() {
|
||||
int o = __offset(24);
|
||||
return o != 0 ? __string(o + bb_pos) : null;
|
||||
}
|
||||
|
||||
public ByteBuffer functionIdAsByteBuffer() {
|
||||
return __vector_as_bytebuffer(24, 1);
|
||||
}
|
||||
|
||||
public Arg args(int j) {
|
||||
return args(new Arg(), j);
|
||||
}
|
||||
|
||||
public Arg args(Arg obj, int j) {
|
||||
int o = __offset(26);
|
||||
return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null;
|
||||
}
|
||||
|
||||
public int argsLength() {
|
||||
int o = __offset(26);
|
||||
return o != 0 ? __vector_len(o) : 0;
|
||||
}
|
||||
|
||||
public String returns(int j) {
|
||||
int o = __offset(28);
|
||||
return o != 0 ? __string(__vector(o) + j * 4) : null;
|
||||
}
|
||||
|
||||
public int returnsLength() {
|
||||
int o = __offset(28);
|
||||
return o != 0 ? __vector_len(o) : 0;
|
||||
}
|
||||
|
||||
public ResourcePair requiredResources(int j) {
|
||||
return requiredResources(new ResourcePair(), j);
|
||||
}
|
||||
|
||||
public ResourcePair requiredResources(ResourcePair obj, int j) {
|
||||
int o = __offset(30);
|
||||
return o != 0 ? obj.__assign(__indirect(__vector(o) + j * 4), bb) : null;
|
||||
}
|
||||
|
||||
public int requiredResourcesLength() {
|
||||
int o = __offset(30);
|
||||
return o != 0 ? __vector_len(o) : 0;
|
||||
}
|
||||
|
||||
//this is manually added to avoid encoding/decoding cost as our object
|
||||
//id is a byte array instead of a string
|
||||
public ByteBuffer returnsAsByteBuffer(int j) {
|
||||
int o = __offset(28);
|
||||
if (o == 0) {
|
||||
|
||||
Reference in New Issue
Block a user