use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.
the class ExactlyOnceFileOutputApp method populateDAG.
@Override
public void populateDAG(DAG dag, Configuration configuration) {
KafkaSinglePortStringInputOperator kafkaInput = dag.addOperator("kafkaInput", new KafkaSinglePortStringInputOperator());
kafkaInput.setWindowDataManager(new FSWindowDataManager());
ExactlyOnceJdbcOutputApp.UniqueCounterFlat count = dag.addOperator("count", new ExactlyOnceJdbcOutputApp.UniqueCounterFlat());
FileWriter fileWriter = dag.addOperator("fileWriter", new FileWriter());
ConsoleOutputOperator cons = dag.addOperator("console", new ConsoleOutputOperator());
dag.addStream("words", kafkaInput.outputPort, count.data);
dag.addStream("counts", count.counts, fileWriter.input, cons.input);
}
use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.
the class YahooFinanceApplication method getConsole.
/**
* Get console for output operator.
* @param name Operator name
* @param dag Application DAG graph.
* @return input port for console output.
*/
public InputPort<Object> getConsole(String name, /*String nodeName,*/
DAG dag, String prefix) {
// hack to output to HTTP based on actual environment
/*
String serverAddr = System.getenv("MALHAR_AJAXSERVER_ADDRESS");
if (serverAddr != null) {
HttpOutputOperator<Object> oper = dag.addOperator(name, new HttpOutputOperator<Object>());
oper.setResourceURL(URI.create("http://" + serverAddr + "/channel/" + nodeName));
return oper.input;
}
*/
ConsoleOutputOperator oper = dag.addOperator(name, ConsoleOutputOperator.class);
oper.setStringFormat(prefix + ": %s");
return oper.input;
}
use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.
the class Application method populateDAG.
@Override
public void populateDAG(DAG dag, Configuration entries) {
/* Generate random key-value pairs */
RandomKeysGenerator randGen = dag.addOperator("randomgen", new RandomKeysGenerator());
/* Initialize with three partition to start with */
// UniqueCount1 uniqCount = dag.addOperator("uniqevalue", new UniqueCount1());
UniqueCounter<Integer> uniqCount = dag.addOperator("uniqevalue", new UniqueCounter<Integer>());
MapToKeyHashValuePairConverter<Integer, Integer> converter = dag.addOperator("converter", new MapToKeyHashValuePairConverter());
uniqCount.setCumulative(false);
dag.setAttribute(uniqCount, Context.OperatorContext.PARTITIONER, new StatelessPartitioner<UniqueCounter<Integer>>(3));
CountVerifier<Integer> verifier = dag.addOperator("verifier", new CountVerifier<Integer>());
StreamDuplicater<KeyHashValPair<Integer, Integer>> dup = dag.addOperator("dup", new StreamDuplicater<KeyHashValPair<Integer, Integer>>());
ConsoleOutputOperator output = dag.addOperator("output", new ConsoleOutputOperator());
ConsoleOutputOperator successOutput = dag.addOperator("successoutput", new ConsoleOutputOperator());
successOutput.setStringFormat("Success %d");
ConsoleOutputOperator failureOutput = dag.addOperator("failureoutput", new ConsoleOutputOperator());
failureOutput.setStringFormat("Failure %d");
// success and failure counters.
Counter successcounter = dag.addOperator("successcounter", new Counter());
Counter failurecounter = dag.addOperator("failurecounter", new Counter());
dag.addStream("datain", randGen.outPort, uniqCount.data);
dag.addStream("dataverification0", randGen.verificationPort, verifier.in1);
dag.addStream("convert", uniqCount.count, converter.input).setLocality(Locality.THREAD_LOCAL);
dag.addStream("split", converter.output, dup.data);
dag.addStream("consoutput", dup.out1, output.input);
dag.addStream("dataverification1", dup.out2, verifier.in2);
dag.addStream("successc", verifier.successPort, successcounter.input);
dag.addStream("failurec", verifier.failurePort, failurecounter.input);
dag.addStream("succconsoutput", successcounter.output, successOutput.input);
dag.addStream("failconsoutput", failurecounter.output, failureOutput.input);
}
use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.
the class XmlParserApplicationTest method testApplication.
@Test
public void testApplication() {
try {
LocalMode lma = LocalMode.newInstance();
DAG dag = lma.getDAG();
XmlDataEmitterOperator input = dag.addOperator("data", new XmlDataEmitterOperator());
XmlParser parser = dag.addOperator("xmlparser", new XmlParser());
ResultCollector rc = dag.addOperator("rc", new ResultCollector());
dag.getMeta(parser).getMeta(parser.out).getAttributes().put(Context.PortContext.TUPLE_CLASS, org.apache.apex.malhar.lib.parser.XmlParserTest.EmployeeBean.class);
ConsoleOutputOperator xmlObjectOp = dag.addOperator("xmlObjectOp", new ConsoleOutputOperator());
xmlObjectOp.setDebug(true);
dag.addStream("input", input.output, parser.in);
dag.addStream("output", parser.parsedOutput, xmlObjectOp.input);
dag.addStream("pojo", parser.out, rc.input);
LocalMode.Controller lc = lma.getController();
lc.setHeartbeatMonitoringEnabled(false);
((StramLocalCluster) lc).setExitCondition(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
return TupleCount == 1;
}
});
// runs for 10 seconds and quits
lc.run(10000);
Assert.assertEquals(1, TupleCount);
Assert.assertEquals("john", obj.getName());
} catch (ConstraintViolationException e) {
Assert.fail("constraint violations: " + e.getConstraintViolations());
}
}
use of org.apache.apex.malhar.lib.io.ConsoleOutputOperator in project apex-malhar by apache.
the class RubyOperatorBenchmarkApplication method populateDAG.
@Override
public void populateDAG(DAG dag, Configuration conf) {
RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
rand.setMaxvalue(3000);
rand.setTuplesBlast(120);
RandomMapOutput randMap = dag.addOperator("randMap", new RandomMapOutput());
randMap.setKey("val");
RubyOperator ruby = dag.addOperator("ruby", new RubyOperator());
String setupScript = "def square(val)\n";
setupScript += " return val*val\nend\n";
ruby.addSetupScript(setupScript);
ruby.setInvoke("square");
ruby.setPassThru(true);
ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
dag.getMeta(console).getMeta(console.input).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
dag.getMeta(ruby).getMeta(ruby.result).getAttributes().put(PortContext.QUEUE_CAPACITY, QUEUE_CAPACITY);
dag.addStream("rand_randMap", rand.integer_data, randMap.input).setLocality(Locality.THREAD_LOCAL);
dag.addStream("randMap_ruby", randMap.map_data, ruby.inBindings).setLocality(locality);
dag.addStream("ruby_console", ruby.result, console.input).setLocality(locality);
}
Aggregations