mirror of
https://github.com/wassname/ray.git
synced 2026-07-10 20:53:24 +08:00
[java] Improve UniqueID code. (#2723)
This commit is contained in:
committed by
Robert Nishihara
parent
4f4bea086a
commit
26d3c0655c
@@ -47,7 +47,7 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
private KeyValueStoreLink kvStore = null;
|
||||
private RunManager manager = null;
|
||||
private Object actor = null;
|
||||
private UniqueID actorId = UniqueID.nil;
|
||||
private UniqueID actorId = UniqueID.NIL;
|
||||
|
||||
protected RayNativeRuntime() {
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
LocalSchedulerLink slink = new DefaultLocalSchedulerClient(
|
||||
params.local_scheduler_name,
|
||||
WorkerContext.currentWorkerId(),
|
||||
UniqueID.nil,
|
||||
UniqueID.NIL,
|
||||
isWorker,
|
||||
WorkerContext.currentTask().taskId,
|
||||
0,
|
||||
@@ -133,7 +133,7 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
LocalSchedulerLink slink = new DefaultLocalSchedulerClient(
|
||||
params.raylet_socket_name,
|
||||
WorkerContext.currentWorkerId(),
|
||||
UniqueID.nil,
|
||||
UniqueID.NIL,
|
||||
isWorker,
|
||||
WorkerContext.currentTask().taskId,
|
||||
0,
|
||||
|
||||
@@ -369,7 +369,7 @@ public class RunManager {
|
||||
for (int j = 0; j < localNumWorkers[i]; j++) {
|
||||
startWorker(localStores.storeName, localStores.managerName, localStores.schedulerName,
|
||||
"/worker" + i + "." + j, params.redis_address,
|
||||
params.node_ip_address, UniqueID.nil, "", params.redirect, params.cleanup);
|
||||
params.node_ip_address, UniqueID.NIL, "", params.redirect, params.cleanup);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -570,7 +570,7 @@ public class RunManager {
|
||||
|
||||
String workerCmd = null;
|
||||
workerCmd = buildWorkerCommand(true, info.storeName, info.managerName, name,
|
||||
UniqueID.nil, "", ip, redisAddress);
|
||||
UniqueID.NIL, "", ip, redisAddress);
|
||||
cmd += " -w \"" + workerCmd + "\"";
|
||||
|
||||
if (redisAddress.length() > 0) {
|
||||
@@ -614,7 +614,7 @@ public class RunManager {
|
||||
|
||||
//Create the worker command that the raylet will use to start workers.
|
||||
String workerCommand = buildWorkerCommandRaylet(info.storeName, rayletSocketName,
|
||||
UniqueID.nil, "", ip, redisAddress);
|
||||
UniqueID.NIL, "", ip, redisAddress);
|
||||
|
||||
int sep = redisAddress.indexOf(':');
|
||||
assert (sep != -1);
|
||||
@@ -656,7 +656,7 @@ public class RunManager {
|
||||
+ ";ray.java.start.raylet_socket_name=" + rayletSocketName
|
||||
+ ";ray.java.start.worker_mode=WORKER;ray.java.start.use_raylet=true";
|
||||
workerConfigs += ";ray.java.start.deploy=" + params.deploy;
|
||||
if (!actorId.equals(UniqueID.nil)) {
|
||||
if (!actorId.equals(UniqueID.NIL)) {
|
||||
workerConfigs += ";ray.java.start.actor_id=" + actorId;
|
||||
}
|
||||
if (!actorClass.equals("")) {
|
||||
@@ -688,7 +688,7 @@ public class RunManager {
|
||||
+ ";ray.java.start.worker_mode=WORKER"
|
||||
+ ";ray.java.start.local_scheduler_name=" + localSchedulerName;
|
||||
workerConfigs += ";ray.java.start.deploy=" + params.deploy;
|
||||
if (!actorId.equals(UniqueID.nil)) {
|
||||
if (!actorId.equals(UniqueID.NIL)) {
|
||||
workerConfigs += ";ray.java.start.actor_id=" + actorId;
|
||||
}
|
||||
if (!actorClass.equals("")) {
|
||||
|
||||
@@ -135,15 +135,15 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
TaskInfo info = TaskInfo.getRootAsTaskInfo(bb);
|
||||
|
||||
TaskSpec spec = new TaskSpec();
|
||||
spec.driverId = new UniqueID(info.driverIdAsByteBuffer());
|
||||
spec.taskId = new UniqueID(info.taskIdAsByteBuffer());
|
||||
spec.parentTaskId = new UniqueID(info.parentTaskIdAsByteBuffer());
|
||||
spec.driverId = UniqueID.fromByteBuffer(info.driverIdAsByteBuffer());
|
||||
spec.taskId = UniqueID.fromByteBuffer(info.taskIdAsByteBuffer());
|
||||
spec.parentTaskId = UniqueID.fromByteBuffer(info.parentTaskIdAsByteBuffer());
|
||||
spec.parentCounter = info.parentCounter();
|
||||
spec.actorId = new UniqueID(info.actorIdAsByteBuffer());
|
||||
spec.actorId = UniqueID.fromByteBuffer(info.actorIdAsByteBuffer());
|
||||
spec.actorCounter = info.actorCounter();
|
||||
spec.createActorId = new UniqueID(info.actorCreationIdAsByteBuffer());
|
||||
spec.createActorId = UniqueID.fromByteBuffer(info.actorCreationIdAsByteBuffer());
|
||||
|
||||
spec.functionId = new UniqueID(info.functionIdAsByteBuffer());
|
||||
spec.functionId = UniqueID.fromByteBuffer(info.functionIdAsByteBuffer());
|
||||
|
||||
List<FunctionArg> args = new ArrayList<>();
|
||||
for (int i = 0; i < info.argsLength(); i++) {
|
||||
@@ -156,7 +156,7 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
for (int j = 0; j < idCount; j++) {
|
||||
ByteBuffer lbb = sarg.objectIdAsByteBuffer(j);
|
||||
assert (lbb != null && lbb.remaining() > 0);
|
||||
darg.ids.add(new UniqueID(lbb));
|
||||
darg.ids.add(UniqueID.fromByteBuffer(lbb));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
for (int i = 0; i < info.returnsLength(); i++) {
|
||||
ByteBuffer lbb = info.returnsAsByteBuffer(i);
|
||||
assert (lbb != null && lbb.remaining() > 0);
|
||||
rids.add(new UniqueID(lbb));
|
||||
rids.add(UniqueID.fromByteBuffer(lbb));
|
||||
}
|
||||
spec.returnIds = rids.toArray(new UniqueID[0]);
|
||||
|
||||
@@ -193,7 +193,7 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
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 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;
|
||||
|
||||
@@ -64,7 +64,7 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
|
||||
|
||||
@Override
|
||||
public UniqueID getAppResourceId(UniqueID driverId) {
|
||||
return new UniqueID(kvStore.get("App2ResMap", driverId.toString()));
|
||||
return UniqueID.fromHexString(kvStore.get("App2ResMap", driverId.toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -92,7 +92,7 @@ public class NativeRemoteFunctionManager implements RemoteFunctionManager {
|
||||
|
||||
ClassLoader cl = loadedApps.get(driverId);
|
||||
if (cl == null) {
|
||||
UniqueID resId = new UniqueID(kvStore.get("App2ResMap", driverId.toString()));
|
||||
UniqueID resId = UniqueID.fromHexString(kvStore.get("App2ResMap", driverId.toString()));
|
||||
byte[] res = getResource(resId);
|
||||
if (res == null) {
|
||||
throw new RuntimeException("get resource null, the resId " + resId.toString());
|
||||
|
||||
Reference in New Issue
Block a user