use of com.datatorrent.stram.plan.logical.LogicalPlan in project apex-core by apache.
the class OiOStreamTest method validatePositiveOiOOptionalInput.
@Test
public void validatePositiveOiOOptionalInput() {
LogicalPlan plan = new LogicalPlan();
RecoverableInputOperator inputOp1 = plan.addOperator("InputOperator1", new RecoverableInputOperator());
GenericOperator genOp = plan.addOperator("GenericOperator", new GenericOperator());
plan.addStream("OiO1", inputOp1.output, genOp.ip1).setLocality(Locality.THREAD_LOCAL);
try {
plan.validate();
Assert.assertTrue("OiO validation", true);
} catch (ConstraintViolationException ex) {
Assert.fail("OiO Single Connected InputPort");
}
}
use of com.datatorrent.stram.plan.logical.LogicalPlan in project apex-core by apache.
the class OiOStreamTest method validatePositiveOiOiO.
@Test
public void validatePositiveOiOiO() {
logger.info("Checking the logic for sanity checking of OiO");
LogicalPlan plan = new LogicalPlan();
ThreadIdValidatingInputOperator inputOperator = plan.addOperator("inputOperator", new ThreadIdValidatingInputOperator());
ThreadIdValidatingGenericIntermediateOperator intermediateOperator = plan.addOperator("intermediateOperator", new ThreadIdValidatingGenericIntermediateOperator());
ThreadIdValidatingOutputOperator outputOperator = plan.addOperator("outputOperator", new ThreadIdValidatingOutputOperator());
plan.addStream("OiO1", inputOperator.output, intermediateOperator.input).setLocality(Locality.THREAD_LOCAL);
plan.addStream("OiO2", intermediateOperator.output, outputOperator.input).setLocality(Locality.THREAD_LOCAL);
try {
plan.validate();
Assert.assertTrue("OiOiO validation", true);
} catch (ConstraintViolationException ex) {
Assert.fail("OiOiO validation");
}
}
use of com.datatorrent.stram.plan.logical.LogicalPlan in project apex-core by apache.
the class OiOStreamTest method validateNegativeOiO.
@Test
public void validateNegativeOiO() {
LogicalPlan plan = new LogicalPlan();
RecoverableInputOperator inputOp1 = plan.addOperator("InputOperator1", new RecoverableInputOperator());
RecoverableInputOperator inputOp2 = plan.addOperator("InputOperator2", new RecoverableInputOperator());
GenericOperator genOp = plan.addOperator("GenericOperator", new GenericOperator());
StreamMeta oio1 = plan.addStream("OiO1", inputOp1.output, genOp.ip1).setLocality(Locality.THREAD_LOCAL);
StreamMeta oio2 = plan.addStream("OiO2", inputOp2.output, genOp.ip2).setLocality(Locality.THREAD_LOCAL);
try {
plan.validate();
Assert.fail("OIO Both InputPorts");
} catch (ConstraintViolationException ex) {
Assert.assertTrue("OiO validation passed", true);
} catch (ValidationException ex) {
Assert.assertTrue("OiO validation passed", true);
}
oio1.setLocality(null);
try {
plan.validate();
Assert.fail("OIO First InputPort");
} catch (ConstraintViolationException ex) {
Assert.assertTrue("OiO validation passed", true);
} catch (ValidationException ex) {
Assert.assertTrue("OiO validation passed", true);
}
oio1.setLocality(Locality.THREAD_LOCAL);
oio2.setLocality(null);
try {
plan.validate();
Assert.fail("OIO Second InputPort");
} catch (ConstraintViolationException ex) {
Assert.assertTrue("OiO validation passed", true);
} catch (ValidationException ex) {
Assert.assertTrue("OiO validation passed", true);
}
}
use of com.datatorrent.stram.plan.logical.LogicalPlan in project apex-core by apache.
the class StramTestSupport method createDAG.
public static LogicalPlan createDAG(final TestMeta testMeta, final String suffix) {
if (suffix == null) {
throw new NullPointerException();
}
LogicalPlan dag = new LogicalPlan();
dag.setAttribute(LogicalPlan.APPLICATION_PATH, testMeta.getPath() + suffix);
return dag;
}
use of com.datatorrent.stram.plan.logical.LogicalPlan in project apex-core by apache.
the class OiOStreamTest method validateOiOTwoPortBetweenOperatorsImplementation.
@Test
public void validateOiOTwoPortBetweenOperatorsImplementation() throws Exception {
LogicalPlan lp = new LogicalPlan();
lp.setAttribute(com.datatorrent.api.Context.OperatorContext.STORAGE_AGENT, new MemoryStorageAgent());
ThreadIdValidatingInputOperator inputOperator = lp.addOperator("inputOperator", new ThreadIdValidatingInputOperator());
ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts intermediateOperator = lp.addOperator("intermediateOperator1", new ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts());
ThreadIdValidatingGenericOperatorWithTwoInputPorts outputOperator = lp.addOperator("outputOperator", new ThreadIdValidatingGenericOperatorWithTwoInputPorts());
StreamMeta stream1 = lp.addStream("OiOinput", inputOperator.output, intermediateOperator.input);
StreamMeta stream2 = lp.addStream("OiOintermediateOutput1", intermediateOperator.output, outputOperator.input);
StreamMeta stream3 = lp.addStream("OiOintermediateOutput2", intermediateOperator.output2, outputOperator.input2);
StramLocalCluster slc;
/*
* The first test makes sure that when they are not ThreadLocal they use different threads
*/
ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadList.clear();
ThreadIdValidatingOutputOperator.threadList.clear();
lp.validate();
slc = new StramLocalCluster(lp);
slc.run();
Assert.assertEquals("nonOIO: Number of threads", 1, ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadList.size());
Assert.assertNotEquals("nonOIO: Thread Ids of input operator and intermediate operator", ThreadIdValidatingInputOperator.threadId, ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadId);
Assert.assertNotEquals("nonOIO: Thread Ids of intermediate and output operators", ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadId, ThreadIdValidatingGenericOperatorWithTwoInputPorts.threadId);
Assert.assertNotEquals("nonOIO: Thread Ids of input and output operators", ThreadIdValidatingInputOperator.threadId, ThreadIdValidatingGenericOperatorWithTwoInputPorts.threadId);
/*
* This test makes sure that since all streams between two operators are thread local, they indeed share a thread
*/
ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadList.clear();
ThreadIdValidatingOutputOperator.threadList.clear();
stream2.setLocality(Locality.THREAD_LOCAL);
stream3.setLocality(Locality.THREAD_LOCAL);
lp.validate();
slc = new StramLocalCluster(lp);
slc.run();
Assert.assertEquals("OIO: Number of threads", 1, ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadList.size());
Assert.assertNotEquals("OIO: Thread Ids of input operator and intermediate operator", ThreadIdValidatingInputOperator.threadId, ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadId);
Assert.assertEquals("OIO: Thread Ids of intermediate and output operators", ThreadIdValidatingGenericIntermediateOperatorWithTwoOutputPorts.threadId, ThreadIdValidatingGenericOperatorWithTwoInputPorts.threadId);
Assert.assertNotEquals("OIO: Thread Ids of input and output operators", ThreadIdValidatingInputOperator.threadId, ThreadIdValidatingGenericOperatorWithTwoInputPorts.threadId);
}
Aggregations