Java Code Examples for com.datatorrent.api.LocalMode#cloneDAG()
The following examples show how to use
com.datatorrent.api.LocalMode#cloneDAG() .
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: StatefulUniqueCountTest.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
@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(); }
Example 2
Source File: StatefulApplicationTest.java From attic-apex-malhar with Apache License 2.0 | 6 votes |
@Test public void testApplication() throws Exception { LocalMode lma = LocalMode.newInstance(); Configuration conf = new Configuration(false); conf.set("dt.operator.StatefulUniqueCounter.prop.tableName", "Test_Lookup_Cache"); conf.set("dt.operator.StatefulUniqueCounter.prop.store.dbUrl", "jdbc:hsqldb:mem:test;sql.syntax_mys=true"); conf.set("dt.operator.StatefulUniqueCounter.prop.store.dbDriver", "org.hsqldb.jdbcDriver"); lma.prepareDAG(new StatefulApplication(), 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(); }
Example 3
Source File: ApplicationFixedTest.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Test public void testApplication() throws IOException, Exception { LocalMode lma = LocalMode.newInstance(); new ApplicationFixed().populateDAG(lma.getDAG(), new Configuration(false)); DAG dag = lma.cloneDAG(); FixedTuplesInputOperator wordGenerator = (FixedTuplesInputOperator)dag .getOperatorMeta("WordGenerator").getOperator(); Assert.assertEquals("Queue Capacity", ApplicationFixed.QUEUE_CAPACITY, (int)dag.getMeta(wordGenerator) .getMeta(wordGenerator.output).getValue(PortContext.QUEUE_CAPACITY)); LocalMode.Controller lc = lma.getController(); lc.run(60000); }
Example 4
Source File: TwitterDumpApplicationTest.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Test public void testPopulateDAG() throws Exception { Configuration configuration = new Configuration(false); LocalMode lm = LocalMode.newInstance(); DAG prepareDAG = lm.prepareDAG(new TwitterDumpApplication(), configuration); DAG clonedDAG = lm.cloneDAG(); assertEquals("Serialization", prepareDAG, clonedDAG); }
Example 5
Source File: Application1Test.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Test @Ignore public void testSomeMethod() throws Exception { Configuration conf = new Configuration(false); LocalMode lma = LocalMode.newInstance(); Application1 application = new Application1(); application.populateDAG(lma.getDAG(), conf); lma.cloneDAG(); lma.getController().run(60000); }
Example 6
Source File: FileSplitterBaseTest.java From attic-apex-malhar with Apache License 2.0 | 5 votes |
@Test public void testSplitterInApp() throws Exception { LocalMode lma = LocalMode.newInstance(); SplitterApp app = new SplitterApp(); Configuration appConf = new Configuration(); appConf.set("dt.operator.Splitter.prop.blocksThreshold", "4"); lma.prepareDAG(app, appConf); lma.cloneDAG(); // check serialization LocalMode.Controller lc = lma.getController(); lc.runAsync(); app.receiver.latch.await(); Assert.assertEquals("no. of metadata", 12, app.receiver.count); lc.shutdown(); }
Example 7
Source File: SalesDemoTest.java From examples with Apache License 2.0 | 4 votes |
@Ignore @Test public void applicationTest() throws Exception { String gatewayConnectAddress = "localhost:9090"; URI uri = URI.create("ws://" + gatewayConnectAddress + "/pubsub"); SalesDemo salesDemo = new SalesDemo(); salesDemo.inputGenerator = new MockGenerator(); Configuration conf = new Configuration(false); conf.addResource("META-INF/properties.xml"); conf.set("dt.attr.GATEWAY_CONNECT_ADDRESS", gatewayConnectAddress); conf.set("dt.application.SalesDemo.operator.DimensionsComputation.attr.PARTITIONER", "com.datatorrent.common.partitioner.StatelessPartitioner:1"); conf.set("dt.application.SalesDemo.operator.Store.fileStore.basePathPrefix", testMeta.getDir()); LocalMode lma = LocalMode.newInstance(); lma.prepareDAG(salesDemo, conf); lma.cloneDAG(); LocalMode.Controller lc = lma.getController(); lc.setHeartbeatMonitoringEnabled(false); lc.runAsync(); String query = SchemaUtils.jarResourceFileToString("salesquery.json"); PubSubWebSocketAppDataQuery pubSubInput = new PubSubWebSocketAppDataQuery(); CollectorTestSink<Object> sink = new CollectorTestSink<Object>(); TestUtils.setSink(pubSubInput.outputPort, sink); pubSubInput.setTopic("SalesQueryResultDemo.1"); pubSubInput.setUri(uri); pubSubInput.setup(null); pubSubInput.activate(null); PubSubWebSocketOutputOperator<String> pubSubOutput = new PubSubWebSocketOutputOperator<String>(); pubSubOutput.setTopic("SalesQueryDemo"); pubSubOutput.setUri(uri); pubSubOutput.setup(null); pubSubOutput.beginWindow(0); pubSubInput.beginWindow(0); Thread.sleep(5000); pubSubOutput.input.put(query); Thread.sleep(5000); pubSubInput.outputPort.flush(Integer.MAX_VALUE); Assert.assertEquals(1, sink.collectedTuples.size()); String resultJSON = sink.collectedTuples.get(0).toString(); JSONObject result = new JSONObject(resultJSON); JSONArray array = result.getJSONArray("data"); JSONObject val = array.getJSONObject(0); Assert.assertEquals(1, array.length()); Assert.assertEquals("3.0", val.get("discount:SUM")); Assert.assertEquals("2.0", val.get("tax:SUM")); Assert.assertEquals("1.0", val.get("sales:SUM")); pubSubInput.deactivate(); pubSubOutput.teardown(); pubSubInput.teardown(); }
Example 8
Source File: AdsDimensionsDemoTest.java From examples with Apache License 2.0 | 4 votes |
@Test public void applicationTest() throws Exception { String gatewayConnectAddress = "localhost:9090"; URI uri = URI.create("ws://" + gatewayConnectAddress + "/pubsub"); AdsDimensionsDemo adsDemo = new AdsDimensionsDemo(); adsDemo.inputOperator = new MockGenerator(); Configuration conf = new Configuration(false); conf.addResource("META-INF/properties.xml"); conf.set("dt.attr.GATEWAY_CONNECT_ADDRESS", gatewayConnectAddress); conf.set("dt.application.AdsDimensionsDemoGeneric.operator.InputGenerator.attr.PARTITIONER", "com.datatorrent.common.partitioner.StatelessPartitioner:1"); conf.set("dt.application.AdsDimensionsDemoGeneric.operator.Store.fileStore.basePathPrefix", testMeta.getDir()); LocalMode lma = LocalMode.newInstance(); lma.prepareDAG(adsDemo, conf); lma.cloneDAG(); LocalMode.Controller lc = lma.getController(); lc.setHeartbeatMonitoringEnabled(false); lc.runAsync(); String query = SchemaUtils.jarResourceFileToString("adsquery.json"); PubSubWebSocketAppDataQuery pubSubInput = new PubSubWebSocketAppDataQuery(); CollectorTestSink<Object> sink = new CollectorTestSink<Object>(); TestUtils.setSink(pubSubInput.outputPort, sink); pubSubInput.setTopic("AdsQueryGenericResultDemo.1"); pubSubInput.setUri(uri); pubSubInput.setup(null); pubSubInput.activate(null); PubSubWebSocketOutputOperator<String> pubSubOutput = new PubSubWebSocketOutputOperator<String>(); pubSubOutput.setTopic("AdsQueryGenericDemo"); pubSubOutput.setUri(uri); pubSubOutput.setup(null); pubSubOutput.beginWindow(0); pubSubInput.beginWindow(0); Thread.sleep(5000); pubSubOutput.input.put(query); Thread.sleep(5000); pubSubInput.outputPort.flush(Integer.MAX_VALUE); Assert.assertEquals(1, sink.collectedTuples.size()); String resultJSON = sink.collectedTuples.get(0).toString(); JSONObject result = new JSONObject(resultJSON); JSONArray array = result.getJSONArray("data"); JSONObject val = array.getJSONObject(0); Assert.assertEquals(1, array.length()); Assert.assertEquals("3.00", val.get("revenue:SUM")); Assert.assertEquals("5.00", val.get("cost:SUM")); Assert.assertEquals("10", val.get("clicks:SUM")); Assert.assertEquals("5", val.get("impressions:SUM")); pubSubInput.deactivate(); pubSubOutput.teardown(); pubSubInput.teardown(); }