Search in sources :

Example 11 with RandomEventGenerator

use of org.apache.apex.malhar.lib.testbench.RandomEventGenerator in project apex-malhar by apache.

the class Application method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
    PiCalculateOperator calc = dag.addOperator("picalc", new PiCalculateOperator());
    ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
    dag.addStream("rand_calc", rand.integer_data, calc.input).setLocality(locality);
    dag.addStream("rand_console", calc.output, console.input).setLocality(locality);
}
Also used : ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) RandomEventGenerator(org.apache.apex.malhar.lib.testbench.RandomEventGenerator)

Example 12 with RandomEventGenerator

use of org.apache.apex.malhar.lib.testbench.RandomEventGenerator in project apex-malhar by apache.

the class ApplicationWithScript method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    int maxValue = 30000;
    RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
    rand.setMinvalue(0);
    rand.setMaxvalue(maxValue);
    RoundRobinHashMap<String, Object> rrhm = dag.addOperator("rrhm", new RoundRobinHashMap<String, Object>());
    rrhm.setKeys(new String[] { "x", "y" });
    JavaScriptOperator calc = dag.addOperator("picalc", new JavaScriptOperator());
    calc.setPassThru(false);
    calc.put("i", 0);
    calc.put("count", 0);
    calc.addSetupScript("function pi() { if (x*x+y*y <= " + maxValue * maxValue + ") { i++; } count++; return i / count * 4; }");
    calc.setInvoke("pi");
    dag.addStream("rand_rrhm", rand.integer_data, rrhm.data);
    dag.addStream("rrhm_calc", rrhm.map, calc.inBindings);
    ConsoleOutputOperator console = dag.addOperator("console", new ConsoleOutputOperator());
    dag.addStream("rand_console", calc.result, console.input);
}
Also used : ConsoleOutputOperator(org.apache.apex.malhar.lib.io.ConsoleOutputOperator) RandomEventGenerator(org.apache.apex.malhar.lib.testbench.RandomEventGenerator) JavaScriptOperator(org.apache.apex.malhar.lib.script.JavaScriptOperator)

Example 13 with RandomEventGenerator

use of org.apache.apex.malhar.lib.testbench.RandomEventGenerator in project apex-malhar by apache.

the class AerospikeOutputBenchmarkApplication method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    RandomEventGenerator rand = dag.addOperator("rand", new RandomEventGenerator());
    rand.setMaxvalue(3000);
    rand.setTuplesBlast(250);
    AerospikeOutputOperator aero = dag.addOperator("aero", new AerospikeOutputOperator());
    AerospikeTransactionalStore store = new AerospikeTransactionalStore();
    store.setNode(NODE);
    store.setPort(PORT);
    store.setNamespace(NAMESPACE);
    aero.setStore(store);
    dag.addStream("rand_aero", rand.integer_data, aero.input).setLocality(locality);
}
Also used : AerospikeTransactionalStore(org.apache.apex.malhar.contrib.aerospike.AerospikeTransactionalStore) RandomEventGenerator(org.apache.apex.malhar.lib.testbench.RandomEventGenerator)

Example 14 with RandomEventGenerator

use of org.apache.apex.malhar.lib.testbench.RandomEventGenerator in project apex-malhar by apache.

the class HiveMapInsertBenchmarkingApp method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    HiveStore store = new HiveStore();
    store.setDatabaseUrl(conf.get("dt.application.HiveMapInsertBenchmarkingApp.operator.HiveOperator.store.dbUrl"));
    store.setConnectionProperties(conf.get("dt.application.HiveMapInsertBenchmarkingApp.operator.HiveOperator.store.connectionProperties"));
    store.setFilepath(conf.get("dt.application.HiveMapInsertBenchmarkingApp.operator.HiveOperator.store.filepath"));
    try {
        hiveInitializeMapDatabase(store, conf.get("dt.application.HiveMapInsertBenchmarkingApp.operator.HiveOperator.tablename"), ":");
    } catch (SQLException ex) {
        LOG.debug(ex.getMessage());
    }
    dag.setAttribute(DAG.STREAMING_WINDOW_SIZE_MILLIS, 1000);
    RandomEventGenerator eventGenerator = dag.addOperator("EventGenerator", RandomEventGenerator.class);
    RandomMapOutput mapGenerator = dag.addOperator("MapGenerator", RandomMapOutput.class);
    dag.setAttribute(eventGenerator, PortContext.QUEUE_CAPACITY, 10000);
    dag.setAttribute(mapGenerator, PortContext.QUEUE_CAPACITY, 10000);
    HiveOperator hiveInsert = dag.addOperator("HiveOperator", new HiveOperator());
    hiveInsert.setStore(store);
    FSRollingMapTestImpl rollingMapFsWriter = dag.addOperator("RollingFsMapWriter", new FSRollingMapTestImpl());
    rollingMapFsWriter.setFilePath(store.filepath);
    ArrayList<String> hivePartitionColumns = new ArrayList<String>();
    hivePartitionColumns.add("dt");
    hiveInsert.setHivePartitionColumns(hivePartitionColumns);
    dag.addStream("EventGenerator2Map", eventGenerator.integer_data, mapGenerator.input);
    dag.addStream("MapGenerator2HdfsOutput", mapGenerator.map_data, rollingMapFsWriter.input);
    dag.addStream("FsWriter2Hive", rollingMapFsWriter.outputPort, hiveInsert.input);
}
Also used : RandomMapOutput(org.apache.apex.benchmark.RandomMapOutput) SQLException(java.sql.SQLException) HiveOperator(org.apache.apex.malhar.hive.HiveOperator) ArrayList(java.util.ArrayList) HiveStore(org.apache.apex.malhar.hive.HiveStore) RandomEventGenerator(org.apache.apex.malhar.lib.testbench.RandomEventGenerator)

Aggregations

RandomEventGenerator (org.apache.apex.malhar.lib.testbench.RandomEventGenerator)14 ConsoleOutputOperator (org.apache.apex.malhar.lib.io.ConsoleOutputOperator)6 RandomMapOutput (org.apache.apex.benchmark.RandomMapOutput)2 Counter (org.apache.apex.malhar.lib.stream.Counter)2 Operator (com.datatorrent.api.Operator)1 StatsListener (com.datatorrent.api.StatsListener)1 DefaultDelayOperator (com.datatorrent.common.util.DefaultDelayOperator)1 URI (java.net.URI)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Random (java.util.Random)1 AerospikeTransactionalStore (org.apache.apex.malhar.contrib.aerospike.AerospikeTransactionalStore)1 CassandraTransactionalStore (org.apache.apex.malhar.contrib.cassandra.CassandraTransactionalStore)1 NiFiSinglePortOutputOperator (org.apache.apex.malhar.contrib.nifi.NiFiSinglePortOutputOperator)1 RubyOperator (org.apache.apex.malhar.contrib.ruby.RubyOperator)1 HiveOperator (org.apache.apex.malhar.hive.HiveOperator)1 HiveStore (org.apache.apex.malhar.hive.HiveStore)1 UniqueCounter (org.apache.apex.malhar.lib.algo.UniqueCounter)1 AppDataSnapshotServerMap (org.apache.apex.malhar.lib.appdata.snapshot.AppDataSnapshotServerMap)1