use of com.datatorrent.stram.engine.TestOutputOperator in project apex-core by apache.
the class LogicalPlanTest method testOutputPortAnnotation.
@Test
public void testOutputPortAnnotation() {
TestAnnotationsOperator ta1 = dag.addOperator("testAnnotationsOperator", new TestAnnotationsOperator());
try {
dag.validate();
Assert.fail("should raise: port connection required");
} catch (ValidationException e) {
Assert.assertEquals("", "Output port connection required: testAnnotationsOperator.outport2", e.getMessage());
}
TestOutputOperator o2 = dag.addOperator("sink", new TestOutputOperator());
dag.addStream("s1", ta1.outport2, o2.inport);
dag.validate();
TestAnnotationsOperator2 ta2 = dag.addOperator("multiOutputPorts1", new TestAnnotationsOperator2());
dag.validate();
TestOutputOperator o3 = dag.addOperator("o3", new TestOutputOperator());
dag.addStream("s2", ta2.outport1, o3.inport);
dag.addOperator("multiOutputPorts3", new TestAnnotationsOperator3());
dag.validate();
}
use of com.datatorrent.stram.engine.TestOutputOperator in project apex-core by apache.
the class OutputUnifiedTest method testManyToOnePartition.
@Test
public void testManyToOnePartition() throws Exception {
TestInputOperator i1 = new TestInputOperator();
dag.addOperator("i1", i1);
GenericTestOperator op1 = new GenericTestOperator();
dag.addOperator("op1", op1);
dag.setOperatorAttribute(op1, OperatorContext.PARTITIONER, new StatelessPartitioner<GenericTestOperator>(3));
TestOutputOperator op2 = new TestOutputOperator();
dag.addOperator("op2", op2);
dag.addStream("s1", i1.output, op1.inport1);
dag.addStream("s2", op1.outport1, op2.inport);
StreamingContainerManager scm = new StreamingContainerManager(dag);
PhysicalPlan physicalPlan = scm.getPhysicalPlan();
List<PTContainer> containers = physicalPlan.getContainers();
Assert.assertEquals("Number of containers", 5, containers.size());
assignContainers(scm, containers);
testOutputAttribute(dag, i1, scm, physicalPlan, false);
testOutputAttribute(dag, op1, scm, physicalPlan, true);
}
use of com.datatorrent.stram.engine.TestOutputOperator in project apex-core by apache.
the class OutputUnifiedTest method testMxNPartition.
@Test
public void testMxNPartition() throws Exception {
TestInputOperator i1 = new TestInputOperator();
dag.addOperator("i1", i1);
GenericTestOperator op1 = new GenericTestOperator();
dag.addOperator("op1", op1);
dag.setOperatorAttribute(op1, OperatorContext.PARTITIONER, new StatelessPartitioner<GenericTestOperator>(3));
TestOutputOperator op2 = new TestOutputOperator();
dag.addOperator("op2", op2);
dag.setOperatorAttribute(op2, OperatorContext.PARTITIONER, new StatelessPartitioner<GenericTestOperator>(2));
dag.addStream("s1", i1.output, op1.inport1);
dag.addStream("s2", op1.outport1, op2.inport);
StreamingContainerManager scm = new StreamingContainerManager(dag);
PhysicalPlan physicalPlan = scm.getPhysicalPlan();
List<PTContainer> containers = physicalPlan.getContainers();
Assert.assertEquals("Number of containers", 6, containers.size());
assignContainers(scm, containers);
testOutputAttribute(dag, i1, scm, physicalPlan, false);
testOutputAttribute(dag, op1, scm, physicalPlan, true);
}
use of com.datatorrent.stram.engine.TestOutputOperator in project apex-core by apache.
the class OutputUnifiedTest method testParallelPartition.
@Test
public void testParallelPartition() throws Exception {
TestInputOperator i1 = new TestInputOperator();
dag.addOperator("i1", i1);
dag.setOperatorAttribute(i1, OperatorContext.PARTITIONER, new StatelessPartitioner<GenericTestOperator>(2));
GenericTestOperator op1 = new GenericTestOperator();
dag.addOperator("op1", op1);
dag.setInputPortAttribute(op1.inport1, PortContext.PARTITION_PARALLEL, true);
TestOutputOperator op2 = new TestOutputOperator();
dag.addOperator("op2", op2);
dag.addStream("s1", i1.output, op1.inport1);
dag.addStream("s2", op1.outport1, op2.inport);
StreamingContainerManager scm = new StreamingContainerManager(dag);
PhysicalPlan physicalPlan = scm.getPhysicalPlan();
List<PTContainer> containers = physicalPlan.getContainers();
Assert.assertEquals("Number of containers", 5, containers.size());
assignContainers(scm, containers);
testOutputAttribute(dag, i1, scm, physicalPlan, false);
testOutputAttribute(dag, op1, scm, physicalPlan, true);
}
use of com.datatorrent.stram.engine.TestOutputOperator in project apex-core by apache.
the class StramLocalClusterTest method testLocalClusterInitShutdown.
/**
* Verify test configuration launches and stops after input terminates.
* Test validates expected output end to end.
*
* @throws Exception
*/
@Test
public void testLocalClusterInitShutdown() throws Exception {
TestGeneratorInputOperator genNode = dag.addOperator("genNode", TestGeneratorInputOperator.class);
genNode.setMaxTuples(2);
GenericTestOperator node1 = dag.addOperator("node1", GenericTestOperator.class);
node1.setEmitFormat("%s >> node1");
File outFile = new File("./target/" + StramLocalClusterTest.class.getName() + "-testLocalClusterInitShutdown.out");
outFile.delete();
TestOutputOperator outNode = dag.addOperator("outNode", TestOutputOperator.class);
outNode.pathSpec = outFile.toURI().toString();
dag.addStream("fromGenNode", genNode.outport, node1.inport1);
dag.addStream("fromNode1", node1.outport1, outNode.inport);
dag.getAttributes().put(LogicalPlan.CONTAINERS_MAX_COUNT, 2);
StramLocalCluster localCluster = new StramLocalCluster(dag);
localCluster.setHeartbeatMonitoringEnabled(false);
localCluster.run();
Assert.assertTrue(outFile + " exists", outFile.exists());
LineNumberReader lnr = new LineNumberReader(new FileReader(outFile));
String line;
while ((line = lnr.readLine()) != null) {
Assert.assertTrue("line match " + line, line.matches("" + lnr.getLineNumber() + " >> node1"));
}
Assert.assertEquals("number lines", 2, lnr.getLineNumber());
lnr.close();
}
Aggregations