Search in sources :

Example 1 with HdfsStringOutputOperator

use of org.apache.apex.examples.frauddetect.operator.HdfsStringOutputOperator in project apex-malhar by apache.

the class Application method getHdfsOutputOperator.

public HdfsStringOutputOperator getHdfsOutputOperator(String name, DAG dag, String folderName) {
    HdfsStringOutputOperator oper = dag.addOperator("hdfs", HdfsStringOutputOperator.class);
    oper.setFilePath(folderName);
    oper.setMaxLength(1024 * 1024 * 1024);
    return oper;
}
Also used : HdfsStringOutputOperator(org.apache.apex.examples.frauddetect.operator.HdfsStringOutputOperator)

Example 2 with HdfsStringOutputOperator

use of org.apache.apex.examples.frauddetect.operator.HdfsStringOutputOperator in project apex-malhar by apache.

the class Application method populateDAG.

@SuppressWarnings("unchecked")
@Override
public void populateDAG(DAG dag, Configuration conf) {
    try {
        URI duri = PubSubHelper.getURIWithDefault(dag, "localhost:9090");
        PubSubWebSocketInputOperator userTxWsInput = getPubSubWebSocketInputOperator("userTxInput", dag, duri, "examples.app.frauddetect.submitTransaction");
        PubSubWebSocketOutputOperator ccUserAlertWsOutput = getPubSubWebSocketOutputOperator("ccUserAlertQueryOutput", dag, duri, "examples.app.frauddetect.fraudAlert");
        PubSubWebSocketOutputOperator avgUserAlertwsOutput = getPubSubWebSocketOutputOperator("avgUserAlertQueryOutput", dag, duri, "examples.app.frauddetect.fraudAlert");
        PubSubWebSocketOutputOperator binUserAlertwsOutput = getPubSubWebSocketOutputOperator("binUserAlertOutput", dag, duri, "examples.app.frauddetect.fraudAlert");
        PubSubWebSocketOutputOperator txSummaryWsOutput = getPubSubWebSocketOutputOperator("txSummaryWsOutput", dag, duri, "examples.app.frauddetect.txSummary");
        SlidingWindowSumKeyVal<KeyValPair<MerchantKey, String>, Integer> smsOperator = dag.addOperator("movingSum", SlidingWindowSumKeyVal.class);
        MerchantTransactionGenerator txReceiver = dag.addOperator("txReceiver", MerchantTransactionGenerator.class);
        MerchantTransactionInputHandler txInputHandler = dag.addOperator("txInputHandler", new MerchantTransactionInputHandler());
        BankIdNumberSamplerOperator binSampler = dag.addOperator("bankInfoFraudDetector", BankIdNumberSamplerOperator.class);
        MerchantTransactionBucketOperator txBucketOperator = dag.addOperator("txFilter", MerchantTransactionBucketOperator.class);
        RangeKeyVal rangeOperator = dag.addOperator("rangePerMerchant", new RangeKeyVal<MerchantKey, Long>());
        SimpleMovingAverage<MerchantKey, Long> smaOperator = dag.addOperator("smaPerMerchant", SimpleMovingAverage.class);
        TransactionStatsAggregator txStatsAggregator = dag.addOperator("txStatsAggregator", TransactionStatsAggregator.class);
        AverageAlertingOperator avgAlertingOperator = dag.addOperator("avgAlerter", AverageAlertingOperator.class);
        CreditCardAmountSamplerOperator ccSamplerOperator = dag.addOperator("amountFraudDetector", CreditCardAmountSamplerOperator.class);
        HdfsStringOutputOperator hdfsOutputOperator = getHdfsOutputOperator("hdfsOutput", dag, "fraud");
        MongoDBOutputOperator mongoTxStatsOperator = dag.addOperator("mongoTxStatsOutput", MongoDBOutputOperator.class);
        MongoDBOutputOperator mongoBinAlertsOperator = dag.addOperator("mongoBinAlertsOutput", MongoDBOutputOperator.class);
        MongoDBOutputOperator mongoCcAlertsOperator = dag.addOperator("mongoCcAlertsOutput", MongoDBOutputOperator.class);
        MongoDBOutputOperator mongoAvgAlertsOperator = dag.addOperator("mongoAvgAlertsOutput", MongoDBOutputOperator.class);
        dag.addStream("userTxStream", userTxWsInput.outputPort, txInputHandler.userTxInputPort);
        dag.addStream("transactions", txReceiver.txOutputPort, txBucketOperator.inputPort).setLocality(DAG.Locality.CONTAINER_LOCAL);
        // dump all tx into Hdfs
        dag.addStream("txData", txReceiver.txDataOutputPort, hdfsOutputOperator.input);
        dag.addStream("userTransactions", txInputHandler.txOutputPort, txBucketOperator.txUserInputPort);
        dag.addStream("bankInfoData", txBucketOperator.binCountOutputPort, smsOperator.data);
        dag.addStream("bankInfoCount", smsOperator.integerSum, binSampler.txCountInputPort);
        dag.addStream("filteredTransactions", txBucketOperator.txOutputPort, rangeOperator.data, smaOperator.data, avgAlertingOperator.txInputPort);
        KeyPartitionCodec<MerchantKey, Long> txCodec = new KeyPartitionCodec<MerchantKey, Long>();
        dag.setInputPortAttribute(rangeOperator.data, Context.PortContext.STREAM_CODEC, txCodec);
        dag.setInputPortAttribute(smaOperator.data, Context.PortContext.STREAM_CODEC, txCodec);
        dag.setInputPortAttribute(avgAlertingOperator.txInputPort, Context.PortContext.STREAM_CODEC, txCodec);
        dag.addStream("creditCardData", txBucketOperator.ccAlertOutputPort, ccSamplerOperator.inputPort);
        dag.addStream("txnSummaryData", txBucketOperator.summaryTxnOutputPort, txSummaryWsOutput.input);
        dag.addStream("smaAlerts", smaOperator.doubleSMA, avgAlertingOperator.smaInputPort);
        dag.addStream("binAlerts", binSampler.countAlertOutputPort, mongoBinAlertsOperator.inputPort);
        dag.addStream("binAlertsNotification", binSampler.countAlertNotificationPort, binUserAlertwsOutput.input);
        dag.addStream("rangeData", rangeOperator.range, txStatsAggregator.rangeInputPort);
        dag.addStream("smaData", smaOperator.longSMA, txStatsAggregator.smaInputPort);
        dag.addStream("txStatsOutput", txStatsAggregator.txDataOutputPort, mongoTxStatsOperator.inputPort);
        dag.addStream("avgAlerts", avgAlertingOperator.avgAlertOutputPort, mongoAvgAlertsOperator.inputPort);
        dag.addStream("avgAlertsNotification", avgAlertingOperator.avgAlertNotificationPort, avgUserAlertwsOutput.input);
        dag.addStream("ccAlerts", ccSamplerOperator.ccAlertOutputPort, mongoCcAlertsOperator.inputPort);
        dag.addStream("ccAlertsNotification", ccSamplerOperator.ccAlertNotificationPort, ccUserAlertWsOutput.input);
    } catch (Exception exc) {
        DTThrowable.rethrow(exc);
    }
}
Also used : PubSubWebSocketOutputOperator(org.apache.apex.malhar.lib.io.PubSubWebSocketOutputOperator) URI(java.net.URI) PubSubWebSocketInputOperator(org.apache.apex.malhar.lib.io.PubSubWebSocketInputOperator) RangeKeyVal(org.apache.apex.malhar.lib.math.RangeKeyVal) MongoDBOutputOperator(org.apache.apex.examples.frauddetect.operator.MongoDBOutputOperator) HdfsStringOutputOperator(org.apache.apex.examples.frauddetect.operator.HdfsStringOutputOperator) KeyValPair(org.apache.apex.malhar.lib.util.KeyValPair)

Aggregations

HdfsStringOutputOperator (org.apache.apex.examples.frauddetect.operator.HdfsStringOutputOperator)2 URI (java.net.URI)1 MongoDBOutputOperator (org.apache.apex.examples.frauddetect.operator.MongoDBOutputOperator)1 PubSubWebSocketInputOperator (org.apache.apex.malhar.lib.io.PubSubWebSocketInputOperator)1 PubSubWebSocketOutputOperator (org.apache.apex.malhar.lib.io.PubSubWebSocketOutputOperator)1 RangeKeyVal (org.apache.apex.malhar.lib.math.RangeKeyVal)1 KeyValPair (org.apache.apex.malhar.lib.util.KeyValPair)1