Search in sources :

Example 1 with ConnectedSource

use of edu.iu.dsc.tws.task.cdfw.task.ConnectedSource in project twister2 by DSC-SPIDAL.

the class ParallelDataFlowsExample method generateSecondJob.

private static DataFlowGraph generateSecondJob(Config config, int parallelismValue, int workers, DataFlowJobConfig jobConfig) {
    ConnectedSource connectedSource = new ConnectedSource("reduce", "first_out");
    ConnectedSink connectedSink = new ConnectedSink();
    ComputeGraphBuilder graphBuilderX = ComputeGraphBuilder.newBuilder(config);
    graphBuilderX.addSource("source1", connectedSource, parallelismValue);
    ComputeConnection reduceConn = graphBuilderX.addCompute("sink1", connectedSink, 1);
    reduceConn.reduce("source1").viaEdge("reduce").withReductionFunction(new Aggregator()).withDataType(MessageTypes.OBJECT);
    graphBuilderX.setMode(OperationMode.BATCH);
    ComputeGraph batchGraph = graphBuilderX.build();
    DataFlowGraph job = DataFlowGraph.newSubGraphJob("second_graph", batchGraph).setWorkers(workers).addDataFlowJobConfig(jobConfig).setGraphType("non-iterative");
    return job;
}
Also used : ConnectedSink(edu.iu.dsc.tws.task.cdfw.task.ConnectedSink) ConnectedSource(edu.iu.dsc.tws.task.cdfw.task.ConnectedSource) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) ComputeGraphBuilder(edu.iu.dsc.tws.task.impl.ComputeGraphBuilder) ComputeConnection(edu.iu.dsc.tws.task.impl.ComputeConnection) DataFlowGraph(edu.iu.dsc.tws.task.cdfw.DataFlowGraph)

Example 2 with ConnectedSource

use of edu.iu.dsc.tws.task.cdfw.task.ConnectedSource in project twister2 by DSC-SPIDAL.

the class TwoDataFlowsExample method runSecondJob.

private static void runSecondJob(Config config, CDFWEnv cdfwEnv, int parallelism, DataFlowJobConfig jobConfig) {
    ConnectedSource connectedSource = new ConnectedSource("reduce", "first_out");
    ConnectedSink connectedSink = new ConnectedSink();
    ComputeGraphBuilder graphBuilderX = ComputeGraphBuilder.newBuilder(config);
    graphBuilderX.addSource("source2", connectedSource, parallelism);
    ComputeConnection reduceConn = graphBuilderX.addCompute("sink2", connectedSink, 1);
    reduceConn.reduce("source2").viaEdge("reduce").withReductionFunction(new Aggregator()).withDataType(MessageTypes.OBJECT);
    graphBuilderX.setMode(OperationMode.BATCH);
    ComputeGraph batchGraph = graphBuilderX.build();
    DataFlowGraph job = DataFlowGraph.newSubGraphJob("second_graph", batchGraph).setWorkers(4).addDataFlowJobConfig(jobConfig).setGraphType("non-iterative");
    cdfwEnv.executeDataFlowGraph(job);
}
Also used : ConnectedSink(edu.iu.dsc.tws.task.cdfw.task.ConnectedSink) ConnectedSource(edu.iu.dsc.tws.task.cdfw.task.ConnectedSource) ComputeGraph(edu.iu.dsc.tws.api.compute.graph.ComputeGraph) ComputeGraphBuilder(edu.iu.dsc.tws.task.impl.ComputeGraphBuilder) ComputeConnection(edu.iu.dsc.tws.task.impl.ComputeConnection) DataFlowGraph(edu.iu.dsc.tws.task.cdfw.DataFlowGraph)

Aggregations

ComputeGraph (edu.iu.dsc.tws.api.compute.graph.ComputeGraph)2 DataFlowGraph (edu.iu.dsc.tws.task.cdfw.DataFlowGraph)2 ConnectedSink (edu.iu.dsc.tws.task.cdfw.task.ConnectedSink)2 ConnectedSource (edu.iu.dsc.tws.task.cdfw.task.ConnectedSource)2 ComputeConnection (edu.iu.dsc.tws.task.impl.ComputeConnection)2 ComputeGraphBuilder (edu.iu.dsc.tws.task.impl.ComputeGraphBuilder)2