use of edu.iu.dsc.tws.task.impl.ComputeGraphBuilder in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerTest method createGraph.
private ComputeGraph createGraph(int parallel, String graphName) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
builder.addSource("source", testSource, parallel);
ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
sinkConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
builder.setMode(OperationMode.BATCH);
ComputeGraph graph = builder.build();
graph.setGraphName(graphName);
return graph;
}
use of edu.iu.dsc.tws.task.impl.ComputeGraphBuilder in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerTest method createGraphWithDifferentParallelismInput.
private ComputeGraph createGraphWithDifferentParallelismInput(int parallel, String graphName, String... inputKey) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource(inputKey[0]);
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink(inputKey[0]);
ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
builder.addSource("source", testSource, parallel);
ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
sinkConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
builder.setMode(OperationMode.BATCH);
ComputeGraph graph = builder.build();
graph.setGraphName(graphName);
return graph;
}
use of edu.iu.dsc.tws.task.impl.ComputeGraphBuilder in project twister2 by DSC-SPIDAL.
the class BatchTaskSchedulerTest method createGraphWithComputeTaskAndConstraints.
private ComputeGraph createGraphWithComputeTaskAndConstraints(int parallel, String graphName) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
TaskSchedulerClassTest.TestCompute testCompute = new TaskSchedulerClassTest.TestCompute();
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
builder.addSource("source", testSource, parallel);
ComputeConnection computeConnection = builder.addCompute("compute", testCompute, parallel);
ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
computeConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
sinkConnection.direct("compute").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
builder.setMode(OperationMode.BATCH);
builder.addGraphConstraints(Context.TWISTER2_MAX_TASK_INSTANCES_PER_WORKER, "8");
ComputeGraph graph = builder.build();
graph.setGraphName(graphName);
return graph;
}
use of edu.iu.dsc.tws.task.impl.ComputeGraphBuilder in project twister2 by DSC-SPIDAL.
the class RoundRobinBatchTaskSchedulerTest method createGraph.
private ComputeGraph createGraph(int parallel) {
TaskSchedulerClassTest.TestSource testSource = new TaskSchedulerClassTest.TestSource();
TaskSchedulerClassTest.TestSink testSink = new TaskSchedulerClassTest.TestSink();
ComputeGraphBuilder builder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
builder.addSource("source", testSource, parallel);
ComputeConnection sinkConnection = builder.addCompute("sink", testSink, parallel);
sinkConnection.direct("source").viaEdge(Context.TWISTER2_DIRECT_EDGE).withDataType(MessageTypes.OBJECT);
builder.setMode(OperationMode.BATCH);
ComputeGraph graph = builder.build();
return graph;
}
use of edu.iu.dsc.tws.task.impl.ComputeGraphBuilder in project twister2 by DSC-SPIDAL.
the class StormBenchmark method execute.
@Override
public void execute() {
Integer parallelSources = this.config.getIntegerValue("parallel-sources", 256);
ComputeGraphBuilder computeGraphBuilder = ComputeGraphBuilder.newBuilder(Config.newBuilder().build());
Generator generator = new Generator();
DataSink dataSink = new DataSink();
computeGraphBuilder.addSource("generator", generator, parallelSources);
if ("reduce".equals(config.get(PARAM_OPERATION))) {
computeGraphBuilder.addCompute("sink", dataSink).reduce("generator").viaEdge("edge").withOperation(Op.SUM, MessageTypes.DOUBLE_ARRAY);
} else {
computeGraphBuilder.addCompute("sink", dataSink).gather("generator").viaEdge("edge");
}
computeGraphBuilder.setMode(OperationMode.STREAMING);
ComputeGraph build = computeGraphBuilder.build();
this.taskExecutor.execute(build, taskExecutor.plan(build));
}
Aggregations