mirror of
https://github.com/wassname/ray.git
synced 2026-07-04 03:36:23 +08:00
[Streaming] Streaming scheduler - part1-1: job graph (#6712)
This commit is contained in:
+3
-3
@@ -30,8 +30,8 @@ public class WordCountTest extends BaseUnitTest implements Serializable {
|
||||
@Test
|
||||
public void testWordCount() {
|
||||
StreamingContext streamingContext = StreamingContext.buildContext();
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
config.put(Config.STREAMING_BATCH_MAX_COUNT, 1);
|
||||
Map<String, String> config = new HashMap<>();
|
||||
config.put(Config.STREAMING_BATCH_MAX_COUNT, "1");
|
||||
config.put(Config.CHANNEL_TYPE, Config.MEMORY_CHANNEL);
|
||||
streamingContext.withConfig(config);
|
||||
List<String> text = new ArrayList<>();
|
||||
@@ -50,7 +50,7 @@ public class WordCountTest extends BaseUnitTest implements Serializable {
|
||||
.sink((SinkFunction<WordAndCount>)
|
||||
result -> wordCount.put(result.word, result.count));
|
||||
|
||||
streamingContext.execute();
|
||||
streamingContext.execute("testWordCount");
|
||||
|
||||
// Sleep until the count for every word is computed.
|
||||
while (wordCount.size() < 3) {
|
||||
|
||||
+9
-9
@@ -19,8 +19,8 @@ import org.ray.streaming.runtime.core.graph.ExecutionGraph;
|
||||
import org.ray.streaming.runtime.core.graph.ExecutionNode;
|
||||
import org.ray.streaming.runtime.core.graph.ExecutionNode.NodeType;
|
||||
import org.ray.streaming.runtime.worker.JobWorker;
|
||||
import org.ray.streaming.plan.Plan;
|
||||
import org.ray.streaming.plan.PlanBuilder;
|
||||
import org.ray.streaming.jobgraph.JobGraph;
|
||||
import org.ray.streaming.jobgraph.JobGraphBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
@@ -32,15 +32,15 @@ public class TaskAssignerImplTest extends BaseUnitTest {
|
||||
|
||||
@Test
|
||||
public void testTaskAssignImpl() {
|
||||
Plan plan = buildDataSyncPlan();
|
||||
JobGraph jobGraph = buildDataSyncPlan();
|
||||
|
||||
List<RayActor<JobWorker>> workers = new ArrayList<>();
|
||||
for(int i = 0; i < plan.getPlanVertexList().size(); i++) {
|
||||
for(int i = 0; i < jobGraph.getJobVertexList().size(); i++) {
|
||||
workers.add(new LocalModeRayActor(ActorId.fromRandom(), ObjectId.fromRandom()));
|
||||
}
|
||||
|
||||
TaskAssigner taskAssigner = new TaskAssignerImpl();
|
||||
ExecutionGraph executionGraph = taskAssigner.assign(plan, workers);
|
||||
ExecutionGraph executionGraph = taskAssigner.assign(jobGraph, workers);
|
||||
|
||||
List<ExecutionNode> executionNodeList = executionGraph.getExecutionNodeList();
|
||||
|
||||
@@ -63,14 +63,14 @@ public class TaskAssignerImplTest extends BaseUnitTest {
|
||||
Assert.assertEquals(sinkNode.getOutputEdges().size(), 0);
|
||||
}
|
||||
|
||||
public Plan buildDataSyncPlan() {
|
||||
public JobGraph buildDataSyncPlan() {
|
||||
StreamingContext streamingContext = StreamingContext.buildContext();
|
||||
DataStream<String> dataStream = DataStreamSource.buildSource(streamingContext,
|
||||
Lists.newArrayList("a", "b", "c"));
|
||||
DataStreamSink streamSink = dataStream.sink(x -> LOGGER.info(x));
|
||||
PlanBuilder planBuilder = new PlanBuilder(Lists.newArrayList(streamSink));
|
||||
JobGraphBuilder jobGraphBuilder = new JobGraphBuilder(Lists.newArrayList(streamSink));
|
||||
|
||||
Plan plan = planBuilder.buildPlan();
|
||||
return plan;
|
||||
JobGraph jobGraph = jobGraphBuilder.build();
|
||||
return jobGraph;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -151,8 +151,8 @@ public class StreamingQueueTest extends BaseUnitTest implements Serializable {
|
||||
|
||||
Map<String, Integer> wordCount = new ConcurrentHashMap<>();
|
||||
StreamingContext streamingContext = StreamingContext.buildContext();
|
||||
Map<String, Object> config = new HashMap<>();
|
||||
config.put(Config.STREAMING_BATCH_MAX_COUNT, 1);
|
||||
Map<String, String> config = new HashMap<>();
|
||||
config.put(Config.STREAMING_BATCH_MAX_COUNT, "1");
|
||||
config.put(Config.CHANNEL_TYPE, Config.NATIVE_CHANNEL);
|
||||
config.put(Config.CHANNEL_SIZE, "100000");
|
||||
streamingContext.withConfig(config);
|
||||
@@ -177,7 +177,7 @@ public class StreamingQueueTest extends BaseUnitTest implements Serializable {
|
||||
serializeResultToFile(resultFile, wordCount);
|
||||
});
|
||||
|
||||
streamingContext.execute();
|
||||
streamingContext.execute("testWordCount");
|
||||
|
||||
Map<String, Integer> checkWordCount =
|
||||
(Map<String, Integer>) deserializeResultFromFile(resultFile);
|
||||
|
||||
Reference in New Issue
Block a user