mirror of
https://github.com/wassname/ray.git
synced 2026-07-13 17:45:08 +08:00
Support multiple core workers in one process (#7623)
This commit is contained in:
+3
-10
@@ -1,6 +1,5 @@
|
||||
package org.ray.streaming.runtime.transfer;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.ray.runtime.RayNativeRuntime;
|
||||
import org.ray.runtime.functionmanager.FunctionDescriptor;
|
||||
import org.ray.runtime.functionmanager.JavaFunctionDescriptor;
|
||||
@@ -24,16 +23,12 @@ public class TransferHandler {
|
||||
private long writerClientNative;
|
||||
private long readerClientNative;
|
||||
|
||||
public TransferHandler(long coreWorkerNative,
|
||||
JavaFunctionDescriptor writerAsyncFunc,
|
||||
public TransferHandler(JavaFunctionDescriptor writerAsyncFunc,
|
||||
JavaFunctionDescriptor writerSyncFunc,
|
||||
JavaFunctionDescriptor readerAsyncFunc,
|
||||
JavaFunctionDescriptor readerSyncFunc) {
|
||||
Preconditions.checkArgument(coreWorkerNative != 0);
|
||||
writerClientNative = createWriterClientNative(
|
||||
coreWorkerNative, writerAsyncFunc, writerSyncFunc);
|
||||
readerClientNative = createReaderClientNative(
|
||||
coreWorkerNative, readerAsyncFunc, readerSyncFunc);
|
||||
writerClientNative = createWriterClientNative(writerAsyncFunc, writerSyncFunc);
|
||||
readerClientNative = createReaderClientNative(readerAsyncFunc, readerSyncFunc);
|
||||
}
|
||||
|
||||
public void onWriterMessage(byte[] buffer) {
|
||||
@@ -53,12 +48,10 @@ public class TransferHandler {
|
||||
}
|
||||
|
||||
private native long createWriterClientNative(
|
||||
long coreWorkerNative,
|
||||
FunctionDescriptor asyncFunc,
|
||||
FunctionDescriptor syncFunc);
|
||||
|
||||
private native long createReaderClientNative(
|
||||
long coreWorkerNative,
|
||||
FunctionDescriptor asyncFunc,
|
||||
FunctionDescriptor syncFunc);
|
||||
|
||||
|
||||
-13
@@ -2,9 +2,6 @@ package org.ray.streaming.runtime.worker;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.runtime.RayMultiWorkerNativeRuntime;
|
||||
import org.ray.runtime.functionmanager.JavaFunctionDescriptor;
|
||||
import org.ray.streaming.runtime.core.graph.ExecutionGraph;
|
||||
import org.ray.streaming.runtime.core.graph.ExecutionNode;
|
||||
@@ -62,7 +59,6 @@ public class JobWorker implements Serializable {
|
||||
Config.CHANNEL_TYPE, Config.DEFAULT_CHANNEL_TYPE);
|
||||
if (channelType.equals(Config.NATIVE_CHANNEL)) {
|
||||
transferHandler = new TransferHandler(
|
||||
getNativeCoreWorker(),
|
||||
new JavaFunctionDescriptor(JobWorker.class.getName(), "onWriterMessage", "([B)V"),
|
||||
new JavaFunctionDescriptor(JobWorker.class.getName(), "onWriterMessageSync", "([B)[B"),
|
||||
new JavaFunctionDescriptor(JobWorker.class.getName(), "onReaderMessage", "([B)V"),
|
||||
@@ -148,13 +144,4 @@ public class JobWorker implements Serializable {
|
||||
public byte[] onWriterMessageSync(byte[] buffer) {
|
||||
return transferHandler.onWriterMessageSync(buffer);
|
||||
}
|
||||
|
||||
private static long getNativeCoreWorker() {
|
||||
long pointer = 0;
|
||||
if (Ray.internal() instanceof RayMultiWorkerNativeRuntime) {
|
||||
pointer = ((RayMultiWorkerNativeRuntime) Ray.internal())
|
||||
.getCurrentRuntime().getNativeCoreWorkerPointer();
|
||||
}
|
||||
return pointer;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -10,7 +10,6 @@ import java.util.Random;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.id.ActorId;
|
||||
import org.ray.runtime.RayMultiWorkerNativeRuntime;
|
||||
import org.ray.runtime.actor.NativeRayActor;
|
||||
import org.ray.runtime.functionmanager.JavaFunctionDescriptor;
|
||||
import org.ray.streaming.runtime.transfer.ChannelID;
|
||||
@@ -29,8 +28,7 @@ public class Worker {
|
||||
protected TransferHandler transferHandler = null;
|
||||
|
||||
public Worker() {
|
||||
transferHandler = new TransferHandler(((RayMultiWorkerNativeRuntime) Ray.internal())
|
||||
.getCurrentRuntime().getNativeCoreWorkerPointer(),
|
||||
transferHandler = new TransferHandler(
|
||||
new JavaFunctionDescriptor(Worker.class.getName(),
|
||||
"onWriterMessage", "([B)V"),
|
||||
new JavaFunctionDescriptor(Worker.class.getName(),
|
||||
|
||||
Reference in New Issue
Block a user