Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / main / java / org / openecomp / dcae / apod / analytics / cdap / tca / flow / TCAVESCollectorFlow.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
4  * ================================================================================
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  *  Licensed under the Apache License, Version 2.0 (the "License");
8  *  you may not use this file except in compliance with the License.
9  *   You may obtain a copy of the License at
10  *
11  *          http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS,
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *  ============================LICENSE_END===========================================
19  */
20
21 package org.openecomp.dcae.apod.analytics.cdap.tca.flow;
22
23 import co.cask.cdap.api.flow.AbstractFlow;
24 import org.openecomp.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
25 import org.openecomp.dcae.apod.analytics.cdap.tca.flowlet.TCAVESAlertsSinkFlowlet;
26 import org.openecomp.dcae.apod.analytics.cdap.tca.flowlet.TCAVESMessageRouterFlowlet;
27 import org.openecomp.dcae.apod.analytics.cdap.tca.flowlet.TCAVESThresholdViolationCalculatorFlowlet;
28 import org.openecomp.dcae.apod.analytics.cdap.tca.settings.TCAAppConfig;
29
30 /**
31  * TCA Flow for VES (Virtual Event Streaming) Collector Flow
32  *
33  * @author Rajiv Singla . Creation Date: 11/3/2016.
34  */
35 public class TCAVESCollectorFlow extends AbstractFlow {
36
37     private final TCAAppConfig tcaAppConfig;
38
39     public TCAVESCollectorFlow(TCAAppConfig tcaAppConfig) {
40         this.tcaAppConfig = tcaAppConfig;
41     }
42
43     @Override
44     protected void configure() {
45
46         setName(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_NAME_FLOW);
47         setDescription(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_DESCRIPTION_FLOW);
48
49         final TCAVESMessageRouterFlowlet messageRouterFlowlet = new TCAVESMessageRouterFlowlet();
50         addFlowlet(messageRouterFlowlet);
51
52         final TCAVESThresholdViolationCalculatorFlowlet thresholdViolationCalculatorFlowlet =
53                 new TCAVESThresholdViolationCalculatorFlowlet(tcaAppConfig.getTcaVESMessageStatusTableName());
54         addFlowlet(thresholdViolationCalculatorFlowlet, tcaAppConfig.getThresholdCalculatorFlowletInstances());
55
56         final TCAVESAlertsSinkFlowlet alertsSinkFlowlet =
57                 new TCAVESAlertsSinkFlowlet(tcaAppConfig.getTcaVESAlertsTableName());
58         addFlowlet(alertsSinkFlowlet);
59
60
61         // connect DMaaP MR VES Subscriber output stream to VES Message Router Flowlet
62         connectStream(tcaAppConfig.getTcaSubscriberOutputStreamName(), messageRouterFlowlet);
63         // connect message router to VES threshold calculator
64         connect(messageRouterFlowlet, thresholdViolationCalculatorFlowlet);
65         // connect VES threshold calculator flowlet to Alerts Sink Flowlet
66         connect(thresholdViolationCalculatorFlowlet, alertsSinkFlowlet);
67
68     }
69 }