mirror of
https://github.com/wassname/ray.git
synced 2026-06-30 20:00:22 +08:00
[Java] Make both RayActor and RayPyActor inheriting from BaseActor (#7462)
This commit is contained in:
+9
-9
@@ -6,7 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.BaseActor;
|
||||
|
||||
/**
|
||||
* Physical execution graph.
|
||||
@@ -18,19 +18,19 @@ import org.ray.api.RayActor;
|
||||
public class ExecutionGraph implements Serializable {
|
||||
private long buildTime;
|
||||
private List<ExecutionNode> executionNodeList;
|
||||
private List<RayActor> sourceWorkers = new ArrayList<>();
|
||||
private List<RayActor> sinkWorkers = new ArrayList<>();
|
||||
private List<BaseActor> sourceWorkers = new ArrayList<>();
|
||||
private List<BaseActor> sinkWorkers = new ArrayList<>();
|
||||
|
||||
public ExecutionGraph(List<ExecutionNode> executionNodes) {
|
||||
this.executionNodeList = executionNodes;
|
||||
for (ExecutionNode executionNode : executionNodeList) {
|
||||
if (executionNode.getNodeType() == ExecutionNode.NodeType.SOURCE) {
|
||||
List<RayActor> actors = executionNode.getExecutionTasks().stream()
|
||||
List<BaseActor> actors = executionNode.getExecutionTasks().stream()
|
||||
.map(ExecutionTask::getWorker).collect(Collectors.toList());
|
||||
sourceWorkers.addAll(actors);
|
||||
}
|
||||
if (executionNode.getNodeType() == ExecutionNode.NodeType.SINK) {
|
||||
List<RayActor> actors = executionNode.getExecutionTasks().stream()
|
||||
List<BaseActor> actors = executionNode.getExecutionTasks().stream()
|
||||
.map(ExecutionTask::getWorker).collect(Collectors.toList());
|
||||
sinkWorkers.addAll(actors);
|
||||
}
|
||||
@@ -38,11 +38,11 @@ public class ExecutionGraph implements Serializable {
|
||||
buildTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public List<RayActor> getSourceWorkers() {
|
||||
public List<BaseActor> getSourceWorkers() {
|
||||
return sourceWorkers;
|
||||
}
|
||||
|
||||
public List<RayActor> getSinkWorkers() {
|
||||
public List<BaseActor> getSinkWorkers() {
|
||||
return sinkWorkers;
|
||||
}
|
||||
|
||||
@@ -81,10 +81,10 @@ public class ExecutionGraph implements Serializable {
|
||||
throw new RuntimeException("Task " + taskId + " does not exist!");
|
||||
}
|
||||
|
||||
public Map<Integer, RayActor> getTaskId2WorkerByNodeId(int nodeId) {
|
||||
public Map<Integer, BaseActor> getTaskId2WorkerByNodeId(int nodeId) {
|
||||
for (ExecutionNode executionNode : executionNodeList) {
|
||||
if (executionNode.getNodeId() == nodeId) {
|
||||
Map<Integer, RayActor> taskId2Worker = new HashMap<>();
|
||||
Map<Integer, BaseActor> taskId2Worker = new HashMap<>();
|
||||
for (ExecutionTask executionTask : executionNode.getExecutionTasks()) {
|
||||
taskId2Worker.put(executionTask.getTaskId(), executionTask.getWorker());
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
package org.ray.streaming.runtime.core.graph;
|
||||
|
||||
import java.io.Serializable;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.BaseActor;
|
||||
|
||||
/**
|
||||
* ExecutionTask is minimal execution unit.
|
||||
@@ -11,9 +11,9 @@ import org.ray.api.RayActor;
|
||||
public class ExecutionTask implements Serializable {
|
||||
private int taskId;
|
||||
private int taskIndex;
|
||||
private RayActor worker;
|
||||
private BaseActor worker;
|
||||
|
||||
public ExecutionTask(int taskId, int taskIndex, RayActor worker) {
|
||||
public ExecutionTask(int taskId, int taskIndex, BaseActor worker) {
|
||||
this.taskId = taskId;
|
||||
this.taskIndex = taskIndex;
|
||||
this.worker = worker;
|
||||
@@ -35,11 +35,11 @@ public class ExecutionTask implements Serializable {
|
||||
this.taskIndex = taskIndex;
|
||||
}
|
||||
|
||||
public RayActor getWorker() {
|
||||
public BaseActor getWorker() {
|
||||
return worker;
|
||||
}
|
||||
|
||||
public void setWorker(RayActor worker) {
|
||||
public void setWorker(BaseActor worker) {
|
||||
this.worker = worker;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package org.ray.streaming.runtime.schedule;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.ray.api.BaseActor;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.RayObject;
|
||||
@@ -57,7 +58,7 @@ public class JobSchedulerImpl implements JobScheduler {
|
||||
List<ExecutionTask> executionTasks = executionNode.getExecutionTasks();
|
||||
for (ExecutionTask executionTask : executionTasks) {
|
||||
int taskId = executionTask.getTaskId();
|
||||
RayActor worker = executionTask.getWorker();
|
||||
BaseActor worker = executionTask.getWorker();
|
||||
switch (executionNode.getLanguage()) {
|
||||
case JAVA:
|
||||
RayActor<JobWorker> jobWorker = (RayActor<JobWorker>) worker;
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.ray.api.BaseActor;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.streaming.jobgraph.JobEdge;
|
||||
import org.ray.streaming.jobgraph.JobGraph;
|
||||
import org.ray.streaming.jobgraph.JobVertex;
|
||||
@@ -58,7 +58,7 @@ public class TaskAssignerImpl implements TaskAssigner {
|
||||
return new ExecutionGraph(executionNodes);
|
||||
}
|
||||
|
||||
private RayActor createWorker(JobVertex jobVertex) {
|
||||
private BaseActor createWorker(JobVertex jobVertex) {
|
||||
switch (jobVertex.getLanguage()) {
|
||||
case PYTHON:
|
||||
return Ray.createPyActor(
|
||||
|
||||
+3
-3
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.ray.api.BaseActor;
|
||||
import org.ray.api.Ray;
|
||||
import org.ray.api.RayActor;
|
||||
import org.ray.api.id.ActorId;
|
||||
import org.ray.streaming.api.collector.Collector;
|
||||
import org.ray.streaming.api.context.RuntimeContext;
|
||||
@@ -65,7 +65,7 @@ public abstract class StreamTask implements Runnable {
|
||||
List<Collector> collectors = new ArrayList<>();
|
||||
for (ExecutionEdge edge : outputEdges) {
|
||||
Map<String, ActorId> outputActorIds = new HashMap<>();
|
||||
Map<Integer, RayActor> taskId2Worker = executionGraph
|
||||
Map<Integer, BaseActor> taskId2Worker = executionGraph
|
||||
.getTaskId2WorkerByNodeId(edge.getTargetNodeId());
|
||||
taskId2Worker.forEach((targetTaskId, targetActor) -> {
|
||||
String queueName = ChannelID.genIdStr(taskId, targetTaskId, executionGraph.getBuildTime());
|
||||
@@ -91,7 +91,7 @@ public abstract class StreamTask implements Runnable {
|
||||
List<ExecutionEdge> inputEdges = executionNode.getInputsEdges();
|
||||
Map<String, ActorId> inputActorIds = new HashMap<>();
|
||||
for (ExecutionEdge edge : inputEdges) {
|
||||
Map<Integer, RayActor> taskId2Worker = executionGraph
|
||||
Map<Integer, BaseActor> taskId2Worker = executionGraph
|
||||
.getTaskId2WorkerByNodeId(edge.getSrcNodeId());
|
||||
taskId2Worker.forEach((srcTaskId, srcActor) -> {
|
||||
String queueName = ChannelID.genIdStr(srcTaskId, taskId, executionGraph.getBuildTime());
|
||||
|
||||
Reference in New Issue
Block a user