use of com.datatorrent.stram.engine.TestGeneratorInputOperator in project apex-core by apache.
the class StreamPersistanceTests method testPersistStreamOperatorIsAddedPerSink.
@Test
public void testPersistStreamOperatorIsAddedPerSink() {
TestGeneratorInputOperator input1 = dag.addOperator("input1", TestGeneratorInputOperator.class);
GenericTestOperator x1 = dag.addOperator("x1", new GenericTestOperator());
GenericTestOperator x2 = dag.addOperator("x2", new GenericTestOperator());
GenericTestOperator x3 = dag.addOperator("x3", new GenericTestOperator());
TestReceiverOperator persister = new TestReceiverOperator();
TestReceiverOperator persister1 = new TestReceiverOperator();
TestReceiverOperator persister2 = new TestReceiverOperator();
StreamMeta stream = dag.addStream("Stream1", input1.outport, x1.inport1, x2.inport1, x3.inport1);
stream.persistUsing("Stream1_persister", persister, persister.inport);
stream.persistUsing("Stream1_x1_persister", persister1, persister1.inport, x1.inport1);
stream.persistUsing("Stream1_x2_persister", persister2, persister2.inport, x2.inport1);
// Check 3 persist operators are added to dag
OperatorMeta persistOperatorMeta = dag.getOperatorMeta("Stream1_persister");
assertEquals("Persist operator not added to dag ", persister, persistOperatorMeta.getOperator());
persistOperatorMeta = dag.getOperatorMeta("Stream1_x1_persister");
assertEquals("Persist operator not added to dag ", persister1, persistOperatorMeta.getOperator());
persistOperatorMeta = dag.getOperatorMeta("Stream1_x2_persister");
assertEquals("Persist operator not added to dag ", persister2, persistOperatorMeta.getOperator());
dag.validate();
}
use of com.datatorrent.stram.engine.TestGeneratorInputOperator in project apex-core by apache.
the class StreamPersistanceTests method testPersistStreamOperatorIsRemovedWhenSinkIsRemoved.
@Test
public void testPersistStreamOperatorIsRemovedWhenSinkIsRemoved() {
// Remove sink and check if corresponding persist operator is removed
TestGeneratorInputOperator input1 = dag.addOperator("input1", TestGeneratorInputOperator.class);
GenericTestOperator x1 = dag.addOperator("x1", new GenericTestOperator());
GenericTestOperator x2 = dag.addOperator("x2", new GenericTestOperator());
GenericTestOperator x3 = dag.addOperator("x3", new GenericTestOperator());
TestReceiverOperator persister = new TestReceiverOperator();
TestReceiverOperator persister1 = new TestReceiverOperator();
TestReceiverOperator persister2 = new TestReceiverOperator();
StreamMeta stream = dag.addStream("Stream1", input1.outport, x1.inport1, x2.inport1, x3.inport1);
stream.persistUsing("Stream1_persister", persister, persister.inport);
stream.persistUsing("Stream1_x1_persister", persister1, persister1.inport, x1.inport1);
stream.persistUsing("Stream1_x2_persister", persister2, persister2.inport, x2.inport1);
// Check 3 persist operators are added to dag
OperatorMeta persistOperatorMeta = dag.getOperatorMeta("Stream1_persister");
assertEquals("Persist operator not added to dag ", persister, persistOperatorMeta.getOperator());
persistOperatorMeta = dag.getOperatorMeta("Stream1_x1_persister");
assertEquals("Persist operator not added to dag ", persister1, persistOperatorMeta.getOperator());
persistOperatorMeta = dag.getOperatorMeta("Stream1_x2_persister");
assertEquals("Persist operator not added to dag ", persister2, persistOperatorMeta.getOperator());
dag.removeOperator(x1);
// Check persister for x1 is removed
persistOperatorMeta = dag.getOperatorMeta("Stream1_x1_persister");
assertEquals("Persist operator should be removed from dag after sink is removed", null, persistOperatorMeta);
// Check other persisters are unchanged
persistOperatorMeta = dag.getOperatorMeta("Stream1_persister");
assertEquals("Persist operator not added to dag ", persister, persistOperatorMeta.getOperator());
persistOperatorMeta = dag.getOperatorMeta("Stream1_x2_persister");
assertEquals("Persist operator not added to dag ", persister2, persistOperatorMeta.getOperator());
}
use of com.datatorrent.stram.engine.TestGeneratorInputOperator in project apex-core by apache.
the class DelayOperatorTest method testValidationWithMultipleStreamLoops.
@Test
public void testValidationWithMultipleStreamLoops() {
LogicalPlan dag = StramTestSupport.createDAG(testMeta);
TestGeneratorInputOperator source = dag.addOperator("A", TestGeneratorInputOperator.class);
GenericTestOperator op1 = dag.addOperator("Op1", GenericTestOperator.class);
GenericTestOperator op2 = dag.addOperator("Op2", GenericTestOperator.class);
DefaultDelayOperator delay = dag.addOperator("Delay", DefaultDelayOperator.class);
dag.addStream("Source", source.outport, op1.inport1);
dag.addStream("Stream1", op1.outport1, op2.inport1);
dag.addStream("Stream2", op1.outport2, op2.inport2);
dag.addStream("Op to Delay", op2.outport1, delay.input);
dag.addStream("Delay to Op", delay.output, op1.inport2);
dag.validate();
}
use of com.datatorrent.stram.engine.TestGeneratorInputOperator in project apex-core by apache.
the class DelayOperatorTest method testValidDelay.
@Test
public void testValidDelay() {
LogicalPlan dag = new LogicalPlan();
TestGeneratorInputOperator opA = dag.addOperator("A", TestGeneratorInputOperator.class);
GenericTestOperator opB = dag.addOperator("B", GenericTestOperator.class);
GenericTestOperator opC = dag.addOperator("C", GenericTestOperator.class);
GenericTestOperator opD = dag.addOperator("D", GenericTestOperator.class);
DefaultDelayOperator opDelay = dag.addOperator("opDelay", DefaultDelayOperator.class);
dag.addStream("AtoB", opA.outport, opB.inport1);
dag.addStream("BtoC", opB.outport1, opC.inport1);
dag.addStream("CtoD", opC.outport1, opD.inport1);
dag.addStream("CtoDelay", opC.outport2, opDelay.input);
dag.addStream("DelayToB", opDelay.output, opB.inport2);
dag.validate();
}
use of com.datatorrent.stram.engine.TestGeneratorInputOperator in project apex-core by apache.
the class DelayOperatorTest method testFibonacciRecovery2.
@Test(timeout = 60000)
public void testFibonacciRecovery2() throws Exception {
LogicalPlan dag = StramTestSupport.createDAG(testMeta);
TestGeneratorInputOperator dummyInput = dag.addOperator("DUMMY", TestGeneratorInputOperator.class);
FibonacciOperator fib = dag.addOperator("FIB", FibonacciOperator.class);
FailableDelayOperator opDelay = dag.addOperator("opDelay", FailableDelayOperator.class);
opDelay.failableOperator = new FailableOperator(opDelay, 5, true);
dag.addStream("dummy_to_operator", dummyInput.outport, fib.dummyInputPort);
dag.addStream("operator_to_delay", fib.output, opDelay.input);
dag.addStream("delay_to_operator", opDelay.output, fib.input);
dag.getAttributes().put(LogicalPlan.CHECKPOINT_WINDOW_COUNT, 2);
dag.getAttributes().put(LogicalPlan.STREAMING_WINDOW_SIZE_MILLIS, 300);
dag.getAttributes().put(LogicalPlan.HEARTBEAT_INTERVAL_MILLIS, 50);
final StramLocalCluster localCluster = new StramLocalCluster(dag);
localCluster.setPerContainerBufferServer(true);
localCluster.run(new ExitCondition(30, FailableOperator.isFailureSimulated));
assertFalse(ExitCondition.message, ExitCondition.failed);
assertTrue(FibonacciOperator.results.size() >= 30);
assertFibonacci();
}
Aggregations