Search in sources :

Example 1 with JdbcPOJOInputOperator

use of org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator in project apex-malhar by apache.

the class MaxPerKeyExamples method populateDAG.

/**
 * Populate the dag using High-Level API.
 * @param dag
 * @param conf
 */
@Override
public void populateDAG(DAG dag, Configuration conf) {
    JdbcPOJOInputOperator jdbcInput = new JdbcPOJOInputOperator();
    jdbcInput.setFieldInfos(addInputFieldInfos());
    JdbcStore store = new JdbcStore();
    jdbcInput.setStore(store);
    JdbcPOJOInsertOutputOperator jdbcOutput = new JdbcPOJOInsertOutputOperator();
    jdbcOutput.setFieldInfos(addOutputFieldInfos());
    JdbcTransactionalStore outputStore = new JdbcTransactionalStore();
    jdbcOutput.setStore(outputStore);
    // Create stream that reads from a Jdbc Input.
    ApexStream<Object> stream = StreamFactory.fromInput(jdbcInput, jdbcInput.outputPort, name("jdbcInput")).window(new WindowOption.GlobalWindow(), new TriggerOption().accumulatingFiredPanes().withEarlyFiringsAtEvery(1)).map(new Function.MapFunction<Object, InputPojo>() {

        @Override
        public InputPojo f(Object input) {
            return (InputPojo) input;
        }
    }, name("ObjectToInputPojo")).addCompositeStreams(new MaxMeanTemp()).map(new Function.MapFunction<OutputPojo, Object>() {

        @Override
        public Object f(OutputPojo input) {
            return (Object) input;
        }
    }, name("OutputPojoToObject")).endWith(jdbcOutput, jdbcOutput.input, name("jdbcOutput"));
    stream.populateDag(dag);
}
Also used : JdbcPOJOInsertOutputOperator(org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInsertOutputOperator) TriggerOption(org.apache.apex.malhar.lib.window.TriggerOption) WindowOption(org.apache.apex.malhar.lib.window.WindowOption) JdbcPOJOInputOperator(org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator) JdbcTransactionalStore(org.apache.apex.malhar.lib.db.jdbc.JdbcTransactionalStore) JdbcStore(org.apache.apex.malhar.lib.db.jdbc.JdbcStore)

Example 2 with JdbcPOJOInputOperator

use of org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator in project apex-malhar by apache.

the class JdbcHDFSApp method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    JdbcPOJOInputOperator jdbcInputOperator = dag.addOperator("JdbcInput", new JdbcPOJOInputOperator());
    /**
     * The class given below can be updated to the user defined class based on
     * input table schema The addField infos method needs to be updated
     * accordingly This line can be commented and class can be set from the
     * properties file
     */
    // dag.setOutputPortAttribute(jdbcInputOperator.outputPort, Context.PortContext.TUPLE_CLASS, PojoEvent.class);
    jdbcInputOperator.setFieldInfos(addFieldInfos());
    JdbcStore store = new JdbcStore();
    jdbcInputOperator.setStore(store);
    FileLineOutputOperator fileOutput = dag.addOperator("FileOutputOperator", new FileLineOutputOperator());
    dag.addStream("POJO's", jdbcInputOperator.outputPort, fileOutput.input).setLocality(Locality.CONTAINER_LOCAL);
}
Also used : JdbcPOJOInputOperator(org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator) JdbcStore(org.apache.apex.malhar.lib.db.jdbc.JdbcStore)

Example 3 with JdbcPOJOInputOperator

use of org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator in project apex-malhar by apache.

the class JdbcToJdbcApp method populateDAG.

@Override
public void populateDAG(DAG dag, Configuration conf) {
    JdbcPOJOInputOperator jdbcInputOperator = dag.addOperator("JdbcInput", new JdbcPOJOInputOperator());
    JdbcStore store = new JdbcStore();
    jdbcInputOperator.setStore(store);
    jdbcInputOperator.setFieldInfos(addFieldInfos());
    /**
     * The class given below can be updated to the user defined class based on
     * input table schema The addField infos method needs to be updated
     * accordingly This line can be commented and class can be set from the
     * properties file
     */
    // dag.setOutputPortAttribute(jdbcInputOperator.outputPort, Context.PortContext.TUPLE_CLASS, PojoEvent.class);
    JdbcPOJOInsertOutputOperator jdbcOutputOperator = dag.addOperator("JdbcOutput", new JdbcPOJOInsertOutputOperator());
    JdbcTransactionalStore outputStore = new JdbcTransactionalStore();
    jdbcOutputOperator.setStore(outputStore);
    jdbcOutputOperator.setFieldInfos(addJdbcFieldInfos());
    /**
     * The class given below can be updated to the user defined class based on
     * input table schema The addField infos method needs to be updated
     * accordingly This line can be commented and class can be set from the
     * properties file
     */
    // dag.setInputPortAttribute(jdbcOutputOperator.input, Context.PortContext.TUPLE_CLASS, PojoEvent.class);
    dag.addStream("POJO's", jdbcInputOperator.outputPort, jdbcOutputOperator.input).setLocality(Locality.CONTAINER_LOCAL);
}
Also used : JdbcPOJOInsertOutputOperator(org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInsertOutputOperator) JdbcTransactionalStore(org.apache.apex.malhar.lib.db.jdbc.JdbcTransactionalStore) JdbcPOJOInputOperator(org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator) JdbcStore(org.apache.apex.malhar.lib.db.jdbc.JdbcStore)

Aggregations

JdbcPOJOInputOperator (org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInputOperator)3 JdbcStore (org.apache.apex.malhar.lib.db.jdbc.JdbcStore)3 JdbcPOJOInsertOutputOperator (org.apache.apex.malhar.lib.db.jdbc.JdbcPOJOInsertOutputOperator)2 JdbcTransactionalStore (org.apache.apex.malhar.lib.db.jdbc.JdbcTransactionalStore)2 TriggerOption (org.apache.apex.malhar.lib.window.TriggerOption)1 WindowOption (org.apache.apex.malhar.lib.window.WindowOption)1