mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 05:41:19 +08:00
[java] Fix the logic of generating TaskID (#2747)
## What do these changes do? Because the logic of generating `TaskID` in java is different from python's, there are many tests fail when we change the `Ray Core` code. In this change, I rewrote the logic of generating `TaskID` in java which is the same as the python's. In java, we call the native method `_generateTaskId()` to generate a `TaskID` which is also used in python. We change `computePutId()`'s logic too. ## Related issue number [#2608](https://github.com/ray-project/ray/issues/2608)
This commit is contained in:
committed by
Robert Nishihara
parent
f37c260bdb
commit
b4cba9a49f
@@ -243,8 +243,13 @@ public class RayNativeRuntime extends RayRuntime {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T> RayActor<T> create(Class<T> cls) {
|
||||
UniqueID createTaskId = UniqueIdHelper.nextTaskId(-1);
|
||||
UniqueID actorId = UniqueIdHelper.taskComputeReturnId(createTaskId, 0, false);
|
||||
UniqueID createTaskId = localSchedulerProxy.generateTaskId(
|
||||
WorkerContext.currentTask().driverId,
|
||||
WorkerContext.currentTask().taskId,
|
||||
WorkerContext.nextCallIndex()
|
||||
);
|
||||
|
||||
UniqueID actorId = UniqueIdHelper.computeReturnId(createTaskId, 0);
|
||||
RayActor<T> actor = new RayActor<>(actorId);
|
||||
UniqueID cursorId;
|
||||
|
||||
|
||||
+15
-1
@@ -6,8 +6,11 @@ import java.nio.ByteOrder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.UniqueID;
|
||||
import org.ray.core.RayRuntime;
|
||||
import org.ray.core.UniqueIdHelper;
|
||||
import org.ray.spi.LocalSchedulerLink;
|
||||
import org.ray.spi.model.FunctionArg;
|
||||
import org.ray.spi.model.TaskSpec;
|
||||
@@ -42,6 +45,8 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
|
||||
private static native byte[] _computePutId(long client, byte[] taskId, int putIndex);
|
||||
|
||||
private static native byte[] _generateTaskId(byte[] driverId, byte[] parentTaskId, int taskIndex);
|
||||
|
||||
private static native void _task_done(long client);
|
||||
|
||||
private static native boolean[] _waitObject(long conn, byte[][] objectIds,
|
||||
@@ -111,10 +116,19 @@ public class DefaultLocalSchedulerClient implements LocalSchedulerLink {
|
||||
|
||||
@Override
|
||||
public void reconstructObjects(List<UniqueID> objectIds, boolean fetchOnly) {
|
||||
RayLog.core.info("reconstruct objects {}", objectIds);
|
||||
if (RayLog.core.isInfoEnabled()) {
|
||||
RayLog.core.info("Reconstructing objects for task {}, object IDs are {}",
|
||||
UniqueIdHelper.computeTaskId(objectIds.get(0)), objectIds);
|
||||
}
|
||||
_reconstruct_objects(client, getIdBytes(objectIds), fetchOnly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UniqueID generateTaskId(UniqueID driverId, UniqueID parentTaskId, int taskIndex) {
|
||||
byte[] bytes = _generateTaskId(driverId.getBytes(), parentTaskId.getBytes(), taskIndex);
|
||||
return new UniqueID(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyUnblocked() {
|
||||
_notify_unblocked(client);
|
||||
|
||||
Reference in New Issue
Block a user