[ID Refactor] Rename DriverID to JobID (#5004)

* WIP

WIP

WIP

Rename Driver -> Job

Fix complition

Fix

Rename in Java

In py

WIP

Fix

WIP

Fix

Fix test

Fix

Fix C++ linting

Fix

* Update java/runtime/src/main/java/org/ray/runtime/config/RayConfig.java

Co-Authored-By: Stephanie Wang <swang@cs.berkeley.edu>

* Update src/ray/core_worker/core_worker.cc

Co-Authored-By: Stephanie Wang <swang@cs.berkeley.edu>

* Address comments

* Fix

* Fix CI

* Fix cpp linting

* Fix py lint

* FIx

* Address comments and fix

* Address comments

* Address

* Fix import_threading
This commit is contained in:
Qing Wang
2019-06-28 00:44:51 +08:00
committed by GitHub
parent d9768c1cd2
commit 62e4b591e3
79 changed files with 961 additions and 974 deletions
@@ -9,12 +9,9 @@ import org.ray.api.id.UniqueId;
public interface RuntimeContext {
/**
* Get the current Driver ID.
*
* If called in a driver, this returns the driver ID. If called in a worker, this returns the ID
* of the associated driver.
* Get the current Job ID.
*/
UniqueId getCurrentDriverId();
UniqueId getCurrentJobId();
/**
* Get the current actor ID.
@@ -74,10 +74,10 @@ public abstract class AbstractRayRuntime implements RayRuntime {
public AbstractRayRuntime(RayConfig rayConfig) {
this.rayConfig = rayConfig;
functionManager = new FunctionManager(rayConfig.driverResourcePath);
functionManager = new FunctionManager(rayConfig.jobResourcePath);
worker = new Worker(this);
workerContext = new WorkerContext(rayConfig.workerMode,
rayConfig.driverId, rayConfig.runMode);
rayConfig.jobId, rayConfig.runMode);
runtimeContext = new RuntimeContextImpl(this);
}
@@ -346,7 +346,7 @@ public abstract class AbstractRayRuntime implements RayRuntime {
boolean isActorCreationTask, BaseTaskOptions taskOptions) {
Preconditions.checkArgument((func == null) != (pyFunctionDescriptor == null));
TaskId taskId = rayletClient.generateTaskId(workerContext.getCurrentDriverId(),
TaskId taskId = rayletClient.generateTaskId(workerContext.getCurrentJobId(),
workerContext.getCurrentTaskId(), workerContext.nextTaskIndex());
int numReturns = actor.getId().isNil() ? 1 : 2;
ObjectId[] returnIds = IdUtil.genReturnIds(taskId, numReturns);
@@ -377,7 +377,7 @@ public abstract class AbstractRayRuntime implements RayRuntime {
FunctionDescriptor functionDescriptor;
if (func != null) {
language = TaskLanguage.JAVA;
functionDescriptor = functionManager.getFunction(workerContext.getCurrentDriverId(), func)
functionDescriptor = functionManager.getFunction(workerContext.getCurrentJobId(), func)
.getFunctionDescriptor();
} else {
language = TaskLanguage.PYTHON;
@@ -385,7 +385,7 @@ public abstract class AbstractRayRuntime implements RayRuntime {
}
return new TaskSpec(
workerContext.getCurrentDriverId(),
workerContext.getCurrentJobId(),
taskId,
workerContext.getCurrentTaskId(),
-1,
@@ -101,7 +101,7 @@ public final class RayNativeRuntime extends AbstractRayRuntime {
rayConfig.rayletSocketName,
workerContext.getCurrentWorkerId(),
rayConfig.workerMode == WorkerMode.WORKER,
workerContext.getCurrentDriverId()
workerContext.getCurrentJobId()
);
// register
@@ -17,8 +17,8 @@ public class RuntimeContextImpl implements RuntimeContext {
}
@Override
public UniqueId getCurrentDriverId() {
return runtime.getWorkerContext().getCurrentDriverId();
public UniqueId getCurrentJobId() {
return runtime.getWorkerContext().getCurrentJobId();
}
@Override
@@ -86,7 +86,7 @@ public class Worker {
try {
// Get method
RayFunction rayFunction = runtime.getFunctionManager()
.getFunction(spec.driverId, spec.getJavaFunctionDescriptor());
.getFunction(spec.jobId, spec.getJavaFunctionDescriptor());
// Set context
runtime.getWorkerContext().setCurrentTask(spec, rayFunction.classLoader);
Thread.currentThread().setContextClassLoader(rayFunction.classLoader);
@@ -29,7 +29,7 @@ public class WorkerContext {
private ThreadLocal<TaskSpec> currentTask;
private UniqueId currentDriverId;
private UniqueId currentJobId;
private ClassLoader currentClassLoader;
@@ -43,7 +43,7 @@ public class WorkerContext {
*/
private RunMode runMode;
public WorkerContext(WorkerMode workerMode, UniqueId driverId, RunMode runMode) {
public WorkerContext(WorkerMode workerMode, UniqueId jobId, RunMode runMode) {
mainThreadId = Thread.currentThread().getId();
taskIndex = ThreadLocal.withInitial(() -> 0);
putIndex = ThreadLocal.withInitial(() -> 0);
@@ -52,13 +52,15 @@ public class WorkerContext {
currentTask = ThreadLocal.withInitial(() -> null);
currentClassLoader = null;
if (workerMode == WorkerMode.DRIVER) {
workerId = driverId;
// TODO(qwang): Assign the driver id to worker id
// once we treat driver id as a special worker id.
workerId = jobId;
currentTaskId.set(TaskId.randomId());
currentDriverId = driverId;
currentJobId = jobId;
} else {
workerId = UniqueId.randomId();
this.currentTaskId.set(TaskId.NIL);
this.currentDriverId = UniqueId.NIL;
this.currentJobId = UniqueId.NIL;
}
}
@@ -84,7 +86,7 @@ public class WorkerContext {
Preconditions.checkNotNull(task);
this.currentTaskId.set(task.taskId);
this.currentDriverId = task.driverId;
this.currentJobId = task.jobId;
taskIndex.set(0);
putIndex.set(0);
this.currentTask.set(task);
@@ -115,15 +117,14 @@ public class WorkerContext {
}
/**
* @return If this worker is a driver, this method returns the driver ID; Otherwise, it returns
* the driver ID of the current running task.
* The ID of the current job.
*/
public UniqueId getCurrentDriverId() {
return currentDriverId;
public UniqueId getCurrentJobId() {
return currentJobId;
}
/**
* @return The class loader which is associated with the current driver.
* @return The class loader which is associated with the current job.
*/
public ClassLoader getCurrentClassLoader() {
return currentClassLoader;
@@ -32,7 +32,7 @@ public class RayConfig {
public final WorkerMode workerMode;
public final RunMode runMode;
public final Map<String, Double> resources;
public final UniqueId driverId;
public final UniqueId jobId;
public final String logDir;
public final boolean redirectOutput;
public final List<String> libraryPath;
@@ -53,7 +53,7 @@ public class RayConfig {
public final String rayletSocketName;
public final List<String> rayletConfigParameters;
public final String driverResourcePath;
public final String jobResourcePath;
public final String pythonWorkerCommand;
/**
@@ -105,12 +105,12 @@ public class RayConfig {
resources.put("CPU", numCpu * 1.0);
}
}
// Driver id.
String driverId = config.getString("ray.driver.id");
if (!driverId.isEmpty()) {
this.driverId = UniqueId.fromHexString(driverId);
// Job id.
String jobId = config.getString("ray.job.id");
if (!jobId.isEmpty()) {
this.jobId = UniqueId.fromHexString(jobId);
} else {
this.driverId = UniqueId.randomId();
this.jobId = UniqueId.randomId();
}
// Log dir.
logDir = removeTrailingSlash(config.getString("ray.log-dir"));
@@ -160,11 +160,11 @@ public class RayConfig {
rayletConfigParameters.add(parameter);
}
// Driver resource path.
if (config.hasPath("ray.driver.resource-path")) {
driverResourcePath = config.getString("ray.driver.resource-path");
// Job resource path.
if (config.hasPath("ray.job.resource-path")) {
jobResourcePath = config.getString("ray.job.resource-path");
} else {
driverResourcePath = null;
jobResourcePath = null;
}
// Number of threads that execute tasks.
@@ -205,7 +205,7 @@ public class RayConfig {
+ ", workerMode=" + workerMode
+ ", runMode=" + runMode
+ ", resources=" + resources
+ ", driverId=" + driverId
+ ", jobId=" + jobId
+ ", logDir='" + logDir + '\''
+ ", redirectOutput=" + redirectOutput
+ ", libraryPath=" + libraryPath
@@ -220,7 +220,7 @@ public class RayConfig {
+ ", objectStoreSize=" + objectStoreSize
+ ", rayletSocketName='" + rayletSocketName + '\''
+ ", rayletConfigParameters=" + rayletConfigParameters
+ ", driverResourcePath='" + driverResourcePath + '\''
+ ", jobResourcePath='" + jobResourcePath + '\''
+ ", pythonWorkerCommand='" + pythonWorkerCommand + '\''
+ '}';
}
@@ -30,7 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Manages functions by driver id.
* Manages functions by job id.
*/
public class FunctionManager {
@@ -46,33 +46,33 @@ public class FunctionManager {
RAY_FUNC_CACHE = ThreadLocal.withInitial(WeakHashMap::new);
/**
* Mapping from the driver id to the functions that belong to this driver.
* Mapping from the job id to the functions that belong to this job.
*/
private Map<UniqueId, DriverFunctionTable> driverFunctionTables = new HashMap<>();
private Map<UniqueId, JobFunctionTable> jobFunctionTables = new HashMap<>();
/**
* The resource path which we can load the driver's jar resources.
* The resource path which we can load the job's jar resources.
*/
private String driverResourcePath;
private String jobResourcePath;
/**
* Construct a FunctionManager with the specified driver resource path.
* Construct a FunctionManager with the specified job resource path.
*
* @param driverResourcePath The specified driver resource that can store the driver's
* @param jobResourcePath The specified job resource that can store the job's
* resources.
*/
public FunctionManager(String driverResourcePath) {
this.driverResourcePath = driverResourcePath;
public FunctionManager(String jobResourcePath) {
this.jobResourcePath = jobResourcePath;
}
/**
* Get the RayFunction from a RayFunc instance (a lambda).
*
* @param driverId current driver id.
* @param jobId current job id.
* @param func The lambda.
* @return A RayFunction object.
*/
public RayFunction getFunction(UniqueId driverId, RayFunc func) {
public RayFunction getFunction(UniqueId jobId, RayFunc func) {
JavaFunctionDescriptor functionDescriptor = RAY_FUNC_CACHE.get().get(func.getClass());
if (functionDescriptor == null) {
SerializedLambda serializedLambda = LambdaUtils.getSerializedLambda(func);
@@ -82,24 +82,24 @@ public class FunctionManager {
functionDescriptor = new JavaFunctionDescriptor(className, methodName, typeDescriptor);
RAY_FUNC_CACHE.get().put(func.getClass(), functionDescriptor);
}
return getFunction(driverId, functionDescriptor);
return getFunction(jobId, functionDescriptor);
}
/**
* Get the RayFunction from a function descriptor.
*
* @param driverId Current driver id.
* @param jobId Current job id.
* @param functionDescriptor The function descriptor.
* @return A RayFunction object.
*/
public RayFunction getFunction(UniqueId driverId, JavaFunctionDescriptor functionDescriptor) {
DriverFunctionTable driverFunctionTable = driverFunctionTables.get(driverId);
if (driverFunctionTable == null) {
public RayFunction getFunction(UniqueId jobId, JavaFunctionDescriptor functionDescriptor) {
JobFunctionTable jobFunctionTable = jobFunctionTables.get(jobId);
if (jobFunctionTable == null) {
ClassLoader classLoader;
if (Strings.isNullOrEmpty(driverResourcePath)) {
if (Strings.isNullOrEmpty(jobResourcePath)) {
classLoader = getClass().getClassLoader();
} else {
File resourceDir = new File(driverResourcePath + "/" + driverId.toString() + "/");
File resourceDir = new File(jobResourcePath + "/" + jobId.toString() + "/");
Collection<File> files = FileUtils.listFiles(resourceDir,
new RegexFileFilter(".*\\.jar"), DirectoryFileFilter.DIRECTORY);
files.add(resourceDir);
@@ -111,23 +111,23 @@ public class FunctionManager {
}
}).collect(Collectors.toList());
classLoader = new URLClassLoader(urlList.toArray(new URL[urlList.size()]));
LOGGER.debug("Resource loaded for driver {} from path {}.", driverId,
LOGGER.debug("Resource loaded for job {} from path {}.", jobId,
resourceDir.getAbsolutePath());
}
driverFunctionTable = new DriverFunctionTable(classLoader);
driverFunctionTables.put(driverId, driverFunctionTable);
jobFunctionTable = new JobFunctionTable(classLoader);
jobFunctionTables.put(jobId, jobFunctionTable);
}
return driverFunctionTable.getFunction(functionDescriptor);
return jobFunctionTable.getFunction(functionDescriptor);
}
/**
* Manages all functions that belong to one driver.
* Manages all functions that belong to one job.
*/
static class DriverFunctionTable {
static class JobFunctionTable {
/**
* The driver's corresponding class loader.
* The job's corresponding class loader.
*/
ClassLoader classLoader;
/**
@@ -135,7 +135,7 @@ public class FunctionManager {
*/
Map<String, Map<Pair<String, String>, RayFunction>> functions;
DriverFunctionTable(ClassLoader classLoader) {
JobFunctionTable(ClassLoader classLoader) {
this.classLoader = classLoader;
this.functions = new HashMap<>();
}
@@ -164,7 +164,7 @@ public class MockRayletClient implements RayletClient {
}
@Override
public TaskId generateTaskId(UniqueId driverId, TaskId parentTaskId, int taskIndex) {
public TaskId generateTaskId(UniqueId jobId, TaskId parentTaskId, int taskIndex) {
return TaskId.randomId();
}
@@ -21,7 +21,7 @@ public interface RayletClient {
void notifyUnblocked(TaskId currentTaskId);
TaskId generateTaskId(UniqueId driverId, TaskId parentTaskId, int taskIndex);
TaskId generateTaskId(UniqueId jobId, TaskId parentTaskId, int taskIndex);
<T> WaitResult<T> wait(List<RayObject<T>> waitFor, int numReturns, int
timeoutMs, TaskId currentTaskId);
@@ -44,10 +44,11 @@ public class RayletClientImpl implements RayletClient {
*/
private long client = 0;
// TODO(qwang): JobId parameter can be removed once we embed jobId in driverId.
public RayletClientImpl(String schedulerSockName, UniqueId clientId,
boolean isWorker, UniqueId driverId) {
boolean isWorker, UniqueId jobId) {
client = nativeInit(schedulerSockName, clientId.getBytes(),
isWorker, driverId.getBytes());
isWorker, jobId.getBytes());
}
@Override
@@ -83,7 +84,7 @@ public class RayletClientImpl implements RayletClient {
public void submitTask(TaskSpec spec) {
LOGGER.debug("Submitting task: {}", spec);
Preconditions.checkState(!spec.parentTaskId.isNil());
Preconditions.checkState(!spec.driverId.isNil());
Preconditions.checkState(!spec.jobId.isNil());
ByteBuffer info = convertTaskSpecToFlatbuffer(spec);
byte[] cursorId = null;
@@ -114,8 +115,8 @@ public class RayletClientImpl implements RayletClient {
}
@Override
public TaskId generateTaskId(UniqueId driverId, TaskId parentTaskId, int taskIndex) {
byte[] bytes = nativeGenerateTaskId(driverId.getBytes(), parentTaskId.getBytes(), taskIndex);
public TaskId generateTaskId(UniqueId jobId, TaskId parentTaskId, int taskIndex) {
byte[] bytes = nativeGenerateTaskId(jobId.getBytes(), parentTaskId.getBytes(), taskIndex);
return new TaskId(bytes);
}
@@ -141,11 +142,10 @@ public class RayletClientImpl implements RayletClient {
nativeNotifyActorResumedFromCheckpoint(client, actorId.getBytes(), checkpointId.getBytes());
}
private static TaskSpec parseTaskSpecFromFlatbuffer(ByteBuffer bb) {
bb.order(ByteOrder.LITTLE_ENDIAN);
TaskInfo info = TaskInfo.getRootAsTaskInfo(bb);
UniqueId driverId = UniqueId.fromByteBuffer(info.driverIdAsByteBuffer());
UniqueId jobId = UniqueId.fromByteBuffer(info.jobIdAsByteBuffer());
TaskId taskId = TaskId.fromByteBuffer(info.taskIdAsByteBuffer());
TaskId parentTaskId = TaskId.fromByteBuffer(info.parentTaskIdAsByteBuffer());
int parentCounter = info.parentCounter();
@@ -197,7 +197,7 @@ public class RayletClientImpl implements RayletClient {
dynamicWorkerOptions.add(info.dynamicWorkerOptions(i));
}
return new TaskSpec(driverId, taskId, parentTaskId, parentCounter, actorCreationId,
return new TaskSpec(jobId, taskId, parentTaskId, parentCounter, actorCreationId,
maxActorReconstructions, actorId, actorHandleId, actorCounter, newActorHandles,
args, numReturns, resources, TaskLanguage.JAVA, functionDescriptor, dynamicWorkerOptions);
}
@@ -207,7 +207,7 @@ public class RayletClientImpl implements RayletClient {
bb.clear();
FlatBufferBuilder fbb = new FlatBufferBuilder(bb);
final int driverIdOffset = fbb.createString(task.driverId.toByteBuffer());
final int jobIdOffset = fbb.createString(task.jobId.toByteBuffer());
final int taskIdOffset = fbb.createString(task.taskId.toByteBuffer());
final int parentTaskIdOffset = fbb.createString(task.parentTaskId.toByteBuffer());
final int parentCounter = task.parentCounter;
@@ -290,7 +290,7 @@ public class RayletClientImpl implements RayletClient {
int root = TaskInfo.createTaskInfo(
fbb,
driverIdOffset,
jobIdOffset,
taskIdOffset,
parentTaskIdOffset,
parentCounter,
@@ -363,7 +363,7 @@ public class RayletClientImpl implements RayletClient {
private static native boolean[] nativeWaitObject(long conn, byte[][] objectIds,
int numReturns, int timeout, boolean waitLocal, byte[] currentTaskId) throws RayException;
private static native byte[] nativeGenerateTaskId(byte[] driverId, byte[] parentTaskId,
private static native byte[] nativeGenerateTaskId(byte[] jobId, byte[] parentTaskId,
int taskIndex);
private static native void nativeFreePlasmaObjects(long conn, byte[][] objectIds,
@@ -18,8 +18,8 @@ import org.ray.runtime.util.IdUtil;
*/
public class TaskSpec {
// ID of the driver that created this task.
public final UniqueId driverId;
// ID of the job that created this task.
public final UniqueId jobId;
// Task ID of the task.
public final TaskId taskId;
@@ -81,7 +81,7 @@ public class TaskSpec {
}
public TaskSpec(
UniqueId driverId,
UniqueId jobId,
TaskId taskId,
TaskId parentTaskId,
int parentCounter,
@@ -97,7 +97,7 @@ public class TaskSpec {
TaskLanguage language,
FunctionDescriptor functionDescriptor,
List<String> dynamicWorkerOptions) {
this.driverId = driverId;
this.jobId = jobId;
this.taskId = taskId;
this.parentTaskId = parentTaskId;
this.parentCounter = parentCounter;
@@ -147,7 +147,7 @@ public class TaskSpec {
@Override
public String toString() {
return "TaskSpec{" +
"driverId=" + driverId +
"jobId=" + jobId +
", taskId=" + taskId +
", parentTaskId=" + parentTaskId +
", parentCounter=" + parentCounter +
@@ -20,14 +20,14 @@ ray {
// Available resources on this node, for example "CPU:4,GPU:0".
resources: ""
// Configuration items about driver.
driver {
// If worker.mode is DRIVER, specify the driver id.
// Configuration items about job.
job {
// If worker.mode is DRIVER, specify the job id.
// If not provided, a random id will be used.
id: ""
// If this config is set, worker will use different paths to loadresources when
// executing tasks from different drivers. E.g. if it's set to '/tm/driver_resources',
// the path for driver 123 will be '/tmp/driver_resources/123'.
// If this config is set, worker will use different paths to load resources when
// executing tasks from different jobs. E.g. if it's set to '/tm/job_resources',
// the path for job 123 will be '/tmp/job_resources/123'.
resource-path: ""
}
@@ -13,7 +13,7 @@ import org.ray.api.annotation.RayRemote;
import org.ray.api.function.RayFunc0;
import org.ray.api.function.RayFunc1;
import org.ray.api.id.UniqueId;
import org.ray.runtime.functionmanager.FunctionManager.DriverFunctionTable;
import org.ray.runtime.functionmanager.FunctionManager.JobFunctionTable;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -106,7 +106,7 @@ public class FunctionManagerTest {
@Test
public void testLoadFunctionTableForClass() {
DriverFunctionTable functionTable = new DriverFunctionTable(getClass().getClassLoader());
JobFunctionTable functionTable = new JobFunctionTable(getClass().getClassLoader());
Map<Pair<String, String>, RayFunction> res = functionTable
.loadFunctionsForClass(Bar.class.getName());
// The result should 2 entries, one for the constructor, the other for bar.
@@ -119,13 +119,13 @@ public class FunctionManagerTest {
@Test
public void testGetFunctionFromLocalResource() throws Exception {
UniqueId driverId = UniqueId.randomId();
UniqueId jobId = UniqueId.randomId();
final String resourcePath = FileUtils.getTempDirectoryPath() + "/ray_test_resources";
final String driverResourcePath = resourcePath + "/" + driverId.toString();
File driverResourceDir = new File(driverResourcePath);
FileUtils.deleteQuietly(driverResourceDir);
driverResourceDir.mkdirs();
driverResourceDir.deleteOnExit();
final String jobResourcePath = resourcePath + "/" + jobId.toString();
File jobResourceDir = new File(jobResourcePath);
FileUtils.deleteQuietly(jobResourceDir);
jobResourceDir.mkdirs();
jobResourceDir.deleteOnExit();
String demoJavaFile = "";
demoJavaFile += "public class DemoApp {\n";
@@ -134,13 +134,13 @@ public class FunctionManagerTest {
demoJavaFile += " }\n";
demoJavaFile += "}";
// Write the demo java file to the driver resource path.
String javaFilePath = driverResourcePath + "/DemoApp.java";
// Write the demo java file to the job resource path.
String javaFilePath = jobResourcePath + "/DemoApp.java";
Files.write(Paths.get(javaFilePath), demoJavaFile.getBytes());
// Compile the java file.
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
int result = compiler.run(null, null, null, "-d", driverResourcePath, javaFilePath);
int result = compiler.run(null, null, null, "-d", jobResourcePath, javaFilePath);
if (result != 0) {
throw new RuntimeException("Couldn't compile Demo.java.");
}
@@ -149,7 +149,7 @@ public class FunctionManagerTest {
JavaFunctionDescriptor descriptor = new JavaFunctionDescriptor(
"DemoApp", "hello", "()Ljava/lang/String;");
final FunctionManager functionManager = new FunctionManager(resourcePath);
RayFunction func = functionManager.getFunction(driverId, descriptor);
RayFunction func = functionManager.getFunction(jobId, descriptor);
Assert.assertEquals(func.getFunctionDescriptor(), descriptor);
}
@@ -10,13 +10,13 @@ public class RayConfigTest {
@Test
public void testCreateRayConfig() {
try {
System.setProperty("ray.driver.resource-path", "path/to/ray/driver/resource/path");
System.setProperty("ray.job.resource-path", "path/to/ray/job/resource/path");
RayConfig rayConfig = RayConfig.create();
Assert.assertEquals(WorkerMode.DRIVER, rayConfig.workerMode);
Assert.assertEquals("path/to/ray/driver/resource/path", rayConfig.driverResourcePath);
Assert.assertEquals("path/to/ray/job/resource/path", rayConfig.jobResourcePath);
} finally {
// Unset system properties.
System.clearProperty("ray.driver.resource-path");
System.clearProperty("ray.job.resource-path");
}
}
@@ -11,28 +11,28 @@ import org.testng.annotations.Test;
public class RuntimeContextTest extends BaseTest {
private static UniqueId DRIVER_ID =
private static UniqueId JOB_ID =
UniqueId.fromHexString("0011223344556677889900112233445566778899");
private static String RAYLET_SOCKET_NAME = "/tmp/ray/test/raylet_socket";
private static String OBJECT_STORE_SOCKET_NAME = "/tmp/ray/test/object_store_socket";
@BeforeClass
public void setUp() {
System.setProperty("ray.driver.id", DRIVER_ID.toString());
System.setProperty("ray.job.id", JOB_ID.toString());
System.setProperty("ray.raylet.socket-name", RAYLET_SOCKET_NAME);
System.setProperty("ray.object-store.socket-name", OBJECT_STORE_SOCKET_NAME);
}
@AfterClass
public void tearDown() {
System.clearProperty("ray.driver.id");
System.clearProperty("ray.job.id");
System.clearProperty("ray.raylet.socket-name");
System.clearProperty("ray.object-store.socket-name");
}
@Test
public void testRuntimeContextInDriver() {
Assert.assertEquals(DRIVER_ID, Ray.getRuntimeContext().getCurrentDriverId());
Assert.assertEquals(JOB_ID, Ray.getRuntimeContext().getCurrentJobId());
Assert.assertEquals(RAYLET_SOCKET_NAME, Ray.getRuntimeContext().getRayletSocketName());
Assert.assertEquals(OBJECT_STORE_SOCKET_NAME,
Ray.getRuntimeContext().getObjectStoreSocketName());
@@ -42,7 +42,7 @@ public class RuntimeContextTest extends BaseTest {
public static class RuntimeContextTester {
public String testRuntimeContext(UniqueId actorId) {
Assert.assertEquals(DRIVER_ID, Ray.getRuntimeContext().getCurrentDriverId());
Assert.assertEquals(JOB_ID, Ray.getRuntimeContext().getCurrentJobId());
Assert.assertEquals(actorId, Ray.getRuntimeContext().getCurrentActorId());
Assert.assertEquals(RAYLET_SOCKET_NAME, Ray.getRuntimeContext().getRayletSocketName());
Assert.assertEquals(OBJECT_STORE_SOCKET_NAME,