本文整理汇总了Java中com.datatorrent.api.LocalMode.getController方法的典型用法代码示例。如果您正苦于以下问题:Java LocalMode.getController方法的具体用法?Java LocalMode.getController怎么用?Java LocalMode.getController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datatorrent.api.LocalMode
的用法示例。
在下文中一共展示了LocalMode.getController方法的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());
}
}
示例2: StreamingWordExtractTest
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void StreamingWordExtractTest() throws Exception
{
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
setConfig(conf);
StreamingWordExtract app = new StreamingWordExtract();
lma.prepareDAG(app, conf);
LocalMode.Controller lc = lma.getController();
((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
return getNumOfEventsInStore() == 36;
}
});
lc.run(10000);
Assert.assertEquals(app.getWordCount(), getNumOfEventsInStore());
Assert.assertEquals(app.getEntriesMapped(), getNumOfEventsInStore());
}
示例3: testApplication
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws IOException, Exception
{
try {
FileContext.getLocalFSFileContext().delete(new Path(new File(testMeta.dir).getAbsolutePath()), true);
List<EventRecord> data = Lists.newArrayList();
data.add(new EventRecord(1, "cust1", 12321L, true, 12.22f, 12.23));
data.add(new EventRecord(2, "cust2", 12322L, true, 22.22f, 22.23));
data.add(new EventRecord(3, "cust3", 12323L, true, 32.22f, 32.23));
writeParquetFile(PARQUET_SCHEMA, new File(testMeta.dir, "data.parquet"), data);
parquetFilePOJOReader.setDirectory(testMeta.dir);
parquetFilePOJOReader.setParquetSchema(PARQUET_SCHEMA);
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
ParquetReaderApplication parquetReaderApplication = new ParquetReaderApplication();
parquetReaderApplication.setParquetFilePOJOReader(parquetFilePOJOReader);
lma.prepareDAG(parquetReaderApplication, conf);
LocalMode.Controller lc = lma.getController();
lc.run(10000);// runs for 10 seconds and quits
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
示例4: testApplication
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws Exception
{
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.set("dt.operator.Unique.prop.tableName", "Test_Lookup_Cache");
conf.set("dt.operator.Unique.prop.store.dbUrl", "jdbc:hsqldb:mem:test;sql.syntax_mys=true");
conf.set("dt.operator.Unique.prop.store.dbDriver", "org.hsqldb.jdbcDriver");
lma.prepareDAG(new Application(), conf);
lma.cloneDAG();
LocalMode.Controller lc = lma.getController();
lc.setHeartbeatMonitoringEnabled(false);
lc.runAsync();
long now = System.currentTimeMillis();
while (System.currentTimeMillis() - now < 15000) {
Thread.sleep(1000);
}
lc.shutdown();
}
示例5: 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();
}
示例6: testApplication
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws Exception
{
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
lma.prepareDAG(new JdbcIOApp(), conf);
LocalMode.Controller lc = lma.getController();
lc.runAsync();
// wait for records to be added to table
Thread.sleep(3000);
lc.shutdown();
Assert.assertEquals("Events in store", 10, getNumOfEventsInStore());
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
示例7: 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());
}
}
示例8: 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;
}
示例9: 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;
}
示例10: 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());
}
}
示例11: testSomeMethod
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testSomeMethod() throws Exception
{
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.addResource("dt-site-pi.xml");
lma.prepareDAG(new Application(), conf);
LocalMode.Controller lc = lma.getController();
lc.run(10000);
}
示例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.xml"));
lma.prepareDAG(new Application(), conf);
LocalMode.Controller lc = lma.getController();
lc.run(10000); // runs for 10 seconds and quits
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
示例13: testApplication
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws Exception
{
LocalMode lma = LocalMode.newInstance();
new UniqueValueCountBenchmarkApplication().populateDAG(lma.getDAG(), new Configuration(false));
LocalMode.Controller lc = lma.getController();
lc.run(10000);
}
示例14: testApplication
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testApplication() throws Exception
{
try {
LocalMode lma = LocalMode.newInstance();
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties.xml"));
lma.prepareDAG(new Application(), conf);
LocalMode.Controller lc = lma.getController();
lc.runAsync();
// wait for output files to roll
Thread.sleep(5000);
String[] extensions = {"dat.0", "tmp"};
Collection<File> list = FileUtils.listFiles(new File(FILE_NAME), extensions, false);
for (File file : list) {
for (String line : FileUtils.readLines(file)) {
Assert.assertEquals("Delimiter in record", true,
(line.equals("1234|0|SimpleCsvFormatterExample|10000.0|||APEX|false|false||")));
}
}
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
示例15: testMapOperator
import com.datatorrent.api.LocalMode; //导入方法依赖的package包/类
@Test
public void testMapOperator() throws Exception
{
LocalMode lma = LocalMode.newInstance();
DAG dag = lma.getDAG();
NumberGenerator numGen = dag.addOperator("numGen", new NumberGenerator());
FunctionOperator.MapFunctionOperator<Integer, Integer> mapper
= dag.addOperator("mapper", new FunctionOperator.MapFunctionOperator<Integer, Integer>(new Square()));
ResultCollector collector = dag.addOperator("collector", new ResultCollector());
dag.addStream("raw numbers", numGen.output, mapper.input);
dag.addStream("mapped results", mapper.output, collector.input);
// Create local cluster
LocalMode.Controller lc = lma.getController();
lc.setHeartbeatMonitoringEnabled(false);
((StramLocalCluster)lc).setExitCondition(new Callable<Boolean>()
{
@Override
public Boolean call() throws Exception
{
return TupleCount == NumTuples;
}
});
lc.run(5000);
Assert.assertEquals(sum, 285);
}