当前位置: 首页>>代码示例>>Java>>正文


Java LocalMode.newInstance方法代码示例

本文整理汇总了Java中com.datatorrent.api.LocalMode.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java LocalMode.newInstance方法的具体用法?Java LocalMode.newInstance怎么用?Java LocalMode.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.datatorrent.api.LocalMode的用法示例。


在下文中一共展示了LocalMode.newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testApplication

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws IOException, Exception
{
  try {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties-test.xml"));
    
    lma.prepareDAG(new Application(), conf);
    LocalMode.Controller lc = lma.getController();
    lc.run(5000);

    // get messages from Kafka topic and compare with input
    chkOutput();

    lc.shutdown();

  } catch (ConstraintViolationException e) {
    Assert.fail("constraint violations: " + e.getConstraintViolations());
  }
}
 
开发者ID:DataTorrent,项目名称:app-templates,代码行数:22,代码来源:ApplicationTest.java

示例2: MinimalWordCountTest

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void MinimalWordCountTest() throws Exception
{
  LocalMode lma = LocalMode.newInstance();
  Configuration conf = new Configuration(false);
  conf.set("dt.application.MinimalWordCount.operator.console.silent", "true");
  MinimalWordCount app = new MinimalWordCount();

  lma.prepareDAG(app, conf);

  LocalMode.Controller lc = lma.getController();
  ((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
  {
    @Override
    public Boolean call() throws Exception
    {
      return MinimalWordCount.Collector.isDone();
    }
  });

  lc.run(10000);

  Assert.assertTrue(MinimalWordCount.Collector.result.get("error") == 7);
  Assert.assertTrue(MinimalWordCount.Collector.result.get("word") == 119);
  Assert.assertTrue(MinimalWordCount.Collector.result.get("bye") == 1);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:27,代码来源:MinimalWordCountTest.java

示例3: testCustomParserApp

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testCustomParserApp() throws IOException, Exception
{
  try {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.addResource(new File("src/test/resources/test-FileToJdbcApp.xml").toURI().toURL());

    lma.prepareDAG(new FileToJdbcCustomParser(), conf);
    LocalMode.Controller lc = lma.getController();
    lc.runAsync(); // test will terminate after results are available

    // wait for records to be added to table
    Thread.sleep(5000);

    Assert.assertEquals("Events in store", 10, getNumOfEventsInStore());
    cleanTable();

  } catch (ConstraintViolationException e) {
    Assert.fail("constraint violations: " + e.getConstraintViolations());
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:ApplicationTest.java

示例4: testApplication

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws Exception
{
  Configuration conf = new Configuration(false);
  conf.addResource("dt-site-monitoring.xml");
  Server server = new Server(0);
  Servlet servlet = new SamplePubSubWebSocketServlet();
  ServletHolder sh = new ServletHolder(servlet);
  ServletContextHandler contextHandler = new ServletContextHandler(server, "/", ServletContextHandler.SESSIONS);
  contextHandler.addServlet(sh, "/pubsub");
  contextHandler.addServlet(sh, "/*");
  server.start();
  Connector[] connector = server.getConnectors();
  conf.set("dt.attr.GATEWAY_CONNECT_ADDRESS", "localhost:" + connector[0].getLocalPort());

  MRMonitoringApplication application = new MRMonitoringApplication();
  LocalMode lma = LocalMode.newInstance();
  lma.prepareDAG(application, conf);
  LocalMode.Controller lc = lma.getController();
  lc.run(10000);
  server.stop();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:23,代码来源:MrMonitoringApplicationTest.java

示例5: testSomeMethod

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testSomeMethod() throws Exception
{
  LocalMode lma = LocalMode.newInstance();
  OldFaithfulApplication app = new OldFaithfulApplication();
  app.populateDAG(lma.getDAG(), new Configuration(false));

  try {
    LocalMode.Controller lc = lma.getController();
    lc.setHeartbeatMonitoringEnabled(false);
    lc.run(5000);
  } catch (Exception e) {
    LOG.error("Exception: ", e);
    Assert.fail("Unexpected exception.");
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:17,代码来源:OldFaithfulApplicationTest.java

示例6: testCouchBaseAppOutput

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testCouchBaseAppOutput() throws FileNotFoundException, IOException
{
  Configuration conf = new Configuration();
  InputStream is = new FileInputStream("src/site/conf/dt-site-couchbase.xml");
  conf.addResource(is);

  conf.get("dt.application.CouchBaseAppOutput.operator.couchbaseOutput.store.uriString");
  conf.get("dt.application.CouchBaseAppOutput.operator.couchbaseOutput.store.password");
  conf.get("dt.application.CouchBaseAppOutput.operator.couchbaseOutput.store.bucket");
  conf.get("dt.application.couchbaseAppOutput.operator.couchbaseOutput.store.max_tuples");
  conf.get("dt.application.couchbaseAppOutput.operator.couchbaseOutput.store.queueSize");
  conf.get("dt.application.couchbaseAppOutput.operator.couchbaseOutput.store.blocktime");
  conf.get("dt.application.couchbaseAppOutput.operator.couchbaseOutput.store.timeout");
  LocalMode lm = LocalMode.newInstance();

  try {
    lm.prepareDAG(new CouchBaseAppOutput(), conf);
    LocalMode.Controller lc = lm.getController();
    //lc.setHeartbeatMonitoringEnabled(false);
    lc.run(20000);
  } catch (Exception ex) {
    logger.info(ex.getCause());
  }
  is.close();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:27,代码来源:CouchBaseBenchmarkTest.java

示例7: WindowedWordCountTest

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void WindowedWordCountTest() throws Exception
{
  LocalMode lma = LocalMode.newInstance();
  Configuration conf = new Configuration(false);
  conf.set("dt.application.WindowedWordCount.operator.console.silent", "true");
  lma.prepareDAG(new WindowedWordCount(), conf);
  LocalMode.Controller lc = lma.getController();
  ((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
  {
    @Override
    public Boolean call() throws Exception
    {
      return WindowedWordCount.Collector.isDone();
    }
  });

  lc.run(60000);

  Assert.assertEquals(127, countSum(WindowedWordCount.Collector.getResult()));
  Assert.assertEquals(28, countSumWord(WindowedWordCount.Collector.getResult(), "word2"));
  Assert.assertEquals(7, countSumWord(WindowedWordCount.Collector.getResult(), "error"));
  Assert.assertEquals(21, countSumWord(WindowedWordCount.Collector.getResult(), "word9"));
  Assert.assertEquals(1, countSumWord(WindowedWordCount.Collector.getResult(), "bye"));
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:26,代码来源:WindowedWordCountTest.java

示例8: AutoCompleteTest

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void AutoCompleteTest() throws Exception
{
  LocalMode lma = LocalMode.newInstance();
  Configuration conf = new Configuration(false);
  conf.set("dt.application.AutoComplete.operator.console.silent", "true");
  lma.prepareDAG(new AutoComplete(), conf);
  LocalMode.Controller lc = lma.getController();

  ((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
  {
    @Override
    public Boolean call() throws Exception
    {
      return AutoComplete.Collector.isDone();
    }
  });

  lc.run(200000);

  Assert.assertTrue(AutoComplete.Collector.getResult().containsKey("had"));
  Assert.assertTrue(AutoComplete.Collector.getResult().containsKey("hadoop"));
  Assert.assertEquals(2, AutoComplete.Collector.getResult().get("mapreduce").get(0).getCount());

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:26,代码来源:AutoCompleteTest.java

示例9: testThroughputCounterApp

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testThroughputCounterApp() throws FileNotFoundException, IOException
{
  Logger logger = LoggerFactory.getLogger(ThroughputCounterAppTest.class);
  LocalMode lm = LocalMode.newInstance();
  Configuration conf = new Configuration();
  InputStream is = new FileInputStream("src/site/conf/dt-site-testbench.xml");
  conf.addResource(is);
  conf.get("dt.application.ThroughputCounterApp.operator.hmapOper.keys");
  conf.get("dt.application.ThroughputCounterApp.operator.hmapOper.numKeys");
  try {
    lm.prepareDAG(new ThroughputCounterApp(), conf);
    LocalMode.Controller lc = lm.getController();
    lc.run(20000);
  } catch (Exception ex) {
    logger.info(ex.getMessage());
  }
  is.close();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:20,代码来源:ThroughputCounterAppTest.java

示例10: testApplication

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
public void testApplication(StreamingApplication streamingApplication) throws Exception
{
  try {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.addResource(this.getClass().getResourceAsStream("/JdbcProperties.xml"));
    lma.prepareDAG(streamingApplication, conf);
    LocalMode.Controller lc = lma.getController();
    lc.setHeartbeatMonitoringEnabled(false);
    ((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
    {
      @Override
      public Boolean call() throws Exception
      {
        return TupleCount == 10;
      }
    });
    lc.run(10000);// runs for 10 seconds and quits
    Assert.assertEquals("rows in db", TupleCount, getNumOfRowsinTable(TABLE_POJO_NAME));
  } catch (ConstraintViolationException e) {
    Assert.fail("constraint violations: " + e.getConstraintViolations());
  }

}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:25,代码来源:JdbcInputOperatorApplicationTest.java

示例11: testMissingRecordLength

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testMissingRecordLength() throws Exception
{
  FixedWidthApplication app = new FixedWidthApplication();
  LocalMode lma = LocalMode.newInstance();
  Configuration conf = new Configuration(false);
  conf.set("dt.operator.S3RecordReaderModuleMock.prop.files", inputDir);
  //Should give IllegalArgumentException since recordLength is not set
  //conf.set("dt.operator.HDFSRecordReaderModule.prop.recordLength", "8");
  conf.set("dt.operator.S3RecordReaderModuleMock.prop.blocksThreshold", "1");
  conf.set("dt.operator.S3RecordReaderModuleMock.prop.blockSize", "3");
  conf.set("dt.operator.S3RecordReaderModuleMock.prop.scanIntervalMillis", "10000");

  lma.prepareDAG(app, conf);
  LocalMode.Controller lc = lma.getController();
  lc.setHeartbeatMonitoringEnabled(true);
  lc.runAsync();
  LOG.debug("Waiting for app to finish");
  Thread.sleep(1000 * 1);
  lc.shutdown();
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:22,代码来源:S3RecordReaderMockTest.java

示例12: testApplication

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws IOException, Exception
{
  try {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties-test.xml"));
    conf.set("dt.operator.fileOutput.prop.filePath", outputDir);
    File outputfile = FileUtils.getFile(outputDir, "output.txt_7.0");

    lma.prepareDAG(new Application(), conf);
    LocalMode.Controller lc = lma.getController();
    lc.runAsync();

    // wait for tuples to show up
    while (!outputfile.exists()) {
      System.out.println("Waiting for tuples ....");
      Thread.sleep(1000);
    }


    Assert.assertTrue(
        FileUtils.contentEquals(FileUtils.getFile("src/test/resources/test_event_data_transformed.txt"), outputfile));
    lc.shutdown();

  } catch (ConstraintViolationException e) {
    Assert.fail("constraint violations: " + e.getConstraintViolations());
  }
}
 
开发者ID:DataTorrent,项目名称:app-templates,代码行数:30,代码来源:ApplicationTest.java

示例13: asyncRun

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
private LocalMode.Controller asyncRun(Configuration conf) throws Exception
{

  LocalMode lma = LocalMode.newInstance();
  lma.prepareDAG(new Application(), conf);
  LocalMode.Controller lc = lma.getController();
  lc.runAsync();
  return lc;
}
 
开发者ID:DataTorrent,项目名称:app-templates,代码行数:10,代码来源:ApplicationTest.java

示例14: asyncRun

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
private LocalMode.Controller asyncRun(Configuration conf) throws Exception
{
  LocalMode lma = LocalMode.newInstance();
  lma.prepareDAG(new Application(), conf);
  LocalMode.Controller lc = lma.getController();
  lc.runAsync();
  return lc;
}
 
开发者ID:DataTorrent,项目名称:app-templates,代码行数:9,代码来源:ApplicationTest.java

示例15: testApplication

import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws IOException, Exception
{
  try {
    LocalMode lma = LocalMode.newInstance();
    Configuration conf = new Configuration(false);
    conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties-test.xml"));
    conf.set("dt.operator.fileOutput.prop.filePath", outputDir);
    File outputfile = FileUtils.getFile(outputDir, "output.txt_5.0");

    lma.prepareDAG(new Application(), conf);
    LocalMode.Controller lc = lma.getController();
    lc.runAsync();

    // wait for tuples to show up
    while (!outputfile.exists()) {
      System.out.println("Waiting for tuples ....");
      Thread.sleep(1000);
    }

    lc.shutdown();
    Assert.assertTrue(
        FileUtils.contentEquals(FileUtils.getFile("src/test/resources/test_event_data.txt"), outputfile));

  } catch (ConstraintViolationException e) {
    Assert.fail("constraint violations: " + e.getConstraintViolations());
  }
}
 
开发者ID:DataTorrent,项目名称:app-templates,代码行数:29,代码来源:ApplicationTest.java


注:本文中的com.datatorrent.api.LocalMode.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。