Search in sources :

Example 1 with MachineInfoAveragingOperator

use of org.apache.apex.examples.machinedata.operator.MachineInfoAveragingOperator in project apex-malhar by apache.

the class Application method addAverageCalculation.

/**
 * This function sets up the DAG for calculating the average
 *
 * @param dag  the DAG instance
 * @param conf the configuration instance
 * @return MachineInfoAveragingPrerequisitesOperator
 */
private MachineInfoAveragingPrerequisitesOperator addAverageCalculation(DAG dag, Configuration conf) {
    MachineInfoAveragingPrerequisitesOperator prereqAverageOper = dag.addOperator("Aggregator", MachineInfoAveragingPrerequisitesOperator.class);
    MachineInfoAveragingOperator averageOperator = dag.addOperator("AverageCalculator", MachineInfoAveragingOperator.class);
    RedisKeyValPairOutputOperator<MachineKey, Map<String, String>> redisAvgOperator = dag.addOperator("Persister", new RedisKeyValPairOutputOperator<MachineKey, Map<String, String>>());
    dag.addStream("Average", averageOperator.outputPort, redisAvgOperator.input);
    SmtpOutputOperator smtpOutputOperator = dag.addOperator("Alerter", new SmtpOutputOperator());
    dag.addStream("Aggregates", prereqAverageOper.outputPort, averageOperator.inputPort);
    dag.addStream("Alerts", averageOperator.smtpAlert, smtpOutputOperator.input);
    return prereqAverageOper;
}
Also used : MachineKey(org.apache.apex.examples.machinedata.data.MachineKey) MachineInfoAveragingOperator(org.apache.apex.examples.machinedata.operator.MachineInfoAveragingOperator) SmtpOutputOperator(org.apache.apex.malhar.lib.io.SmtpOutputOperator) MachineInfoAveragingPrerequisitesOperator(org.apache.apex.examples.machinedata.operator.MachineInfoAveragingPrerequisitesOperator) Map(java.util.Map)

Aggregations

Map (java.util.Map)1 MachineKey (org.apache.apex.examples.machinedata.data.MachineKey)1 MachineInfoAveragingOperator (org.apache.apex.examples.machinedata.operator.MachineInfoAveragingOperator)1 MachineInfoAveragingPrerequisitesOperator (org.apache.apex.examples.machinedata.operator.MachineInfoAveragingPrerequisitesOperator)1 SmtpOutputOperator (org.apache.apex.malhar.lib.io.SmtpOutputOperator)1