Java Code Examples for com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta#setLocality()

The following examples show how to use com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta#setLocality() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OiOEndWindowTest.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Test
public void validateOiOImplementation() throws Exception
{
  LogicalPlan lp = new LogicalPlan();
  String workingDir = new File("target/validateOiOImplementation").getAbsolutePath();
  lp.setAttribute(Context.OperatorContext.STORAGE_AGENT, new AsyncFSStorageAgent(workingDir, null));
  TestInputOperator io = lp.addOperator("Input Operator", new TestInputOperator());
  FirstGenericOperator go = lp.addOperator("First Generic Operator", new FirstGenericOperator());
  SecondGenericOperator out = lp.addOperator("Second Generic Operator", new SecondGenericOperator());

  /*
   * This tests make sure that even if the application_window_count is different the endWindow() is called for
   * end_stream
   */
  lp.getOperatorMeta("Second Generic Operator").getAttributes().put(Context.OperatorContext.APPLICATION_WINDOW_COUNT, 2);
  StreamMeta stream = lp.addStream("Stream", io.output, go.input);
  StreamMeta stream1 = lp.addStream("Stream1", go.output, out.input);

  stream1.setLocality(Locality.THREAD_LOCAL);
  lp.validate();
  StramLocalCluster slc = new StramLocalCluster(lp);
  slc.run();
  Assert.assertEquals("End Window Count", FirstGenericOperator.endwindowCount, SecondGenericOperator.endwindowCount);
}
 
Example 2
Source File: LogicalPlanTest.java    From attic-apex-core with Apache License 2.0 6 votes vote down vote up
@Test
public void testLocalityValidation()
{
  TestGeneratorInputOperator input1 = dag.addOperator("input1", TestGeneratorInputOperator.class);
  GenericTestOperator o1 = dag.addOperator("o1", GenericTestOperator.class);
  StreamMeta s1 = dag.addStream("input1.outport", input1.outport, o1.inport1).setLocality(Locality.THREAD_LOCAL);
  dag.validate();

  TestGeneratorInputOperator input2 = dag.addOperator("input2", TestGeneratorInputOperator.class);
  dag.addStream("input2.outport", input2.outport, o1.inport2);

  try {
    dag.validate();
    Assert.fail("Exception expected for " + o1);
  } catch (ValidationException ve) {
    Assert.assertThat("", ve.getMessage(), RegexMatcher.matches("Locality THREAD_LOCAL invalid for operator .* with multiple input streams .*"));
  }

  s1.setLocality(null);
  dag.validate();
}
 
Example 3
Source File: LogicalPlanConfiguration.java    From Bats with Apache License 2.0 5 votes vote down vote up
private void setStreamConfiguration(LogicalPlan dag, List<AppConf> appConfs, String appAlias)
{
  for (StreamMeta sm : dag.getAllStreams()) {
    List<StreamConf> smConfs = getMatchingChildConf(appConfs, sm.getName(), StramElement.STREAM);
    for (StreamConf smConf : smConfs) {
      DAG.Locality locality = smConf.getLocality();
      if (locality != null) {
        sm.setLocality(locality);
        break;
      }
    }
  }
}
 
Example 4
Source File: LogicalPlanConfiguration.java    From attic-apex-core with Apache License 2.0 5 votes vote down vote up
private void setStreamConfiguration(LogicalPlan dag, List<AppConf> appConfs, String appAlias)
{
  for (StreamMeta sm : dag.getAllStreams()) {
    List<StreamConf> smConfs = getMatchingChildConf(appConfs, sm.getName(), StramElement.STREAM);
    for (StreamConf smConf : smConfs) {
      DAG.Locality locality = smConf.getLocality();
      if (locality != null) {
        sm.setLocality(locality);
        break;
      }
    }
  }
}