TCA: Replace any openecomp reference by onap
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-tca / src / main / java / org / onap / 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.onap.dcae.apod.analytics.cdap.tca.flow;
22
23 import co.cask.cdap.api.flow.AbstractFlow;
24 import org.onap.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
25 import org.onap.dcae.apod.analytics.cdap.tca.flowlet.TCAVESAAIEnrichmentFlowlet;
26 import org.onap.dcae.apod.analytics.cdap.tca.flowlet.TCAVESAlertsAbatementFlowlet;
27 import org.onap.dcae.apod.analytics.cdap.tca.flowlet.TCAVESAlertsSinkFlowlet;
28 import org.onap.dcae.apod.analytics.cdap.tca.flowlet.TCAVESMessageRouterFlowlet;
29 import org.onap.dcae.apod.analytics.cdap.tca.flowlet.TCAVESThresholdViolationCalculatorFlowlet;
30 import org.onap.dcae.apod.analytics.cdap.tca.settings.TCAAppConfig;
31
32 /**
33  * TCA Flow for VES (Virtual Event Streaming) Collector Flow
34  *
35  * @author Rajiv Singla . Creation Date: 11/3/2016.
36  */
37 public class TCAVESCollectorFlow extends AbstractFlow {
38
39     private final TCAAppConfig tcaAppConfig;
40
41     public TCAVESCollectorFlow(TCAAppConfig tcaAppConfig) {
42         this.tcaAppConfig = tcaAppConfig;
43     }
44
45     @Override
46     protected void configure() {
47
48         setName(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_NAME_FLOW);
49         setDescription(CDAPComponentsConstants.TCA_FIXED_VES_COLLECTOR_DESCRIPTION_FLOW);
50
51         final TCAVESMessageRouterFlowlet messageRouterFlowlet = new TCAVESMessageRouterFlowlet();
52         addFlowlet(messageRouterFlowlet);
53
54         final TCAVESThresholdViolationCalculatorFlowlet thresholdViolationCalculatorFlowlet =
55                 new TCAVESThresholdViolationCalculatorFlowlet(tcaAppConfig.getTcaVESMessageStatusTableName());
56         addFlowlet(thresholdViolationCalculatorFlowlet, tcaAppConfig.getThresholdCalculatorFlowletInstances());
57
58         final TCAVESAlertsAbatementFlowlet tcavesAlertsAbatementFlowlet =
59                 new TCAVESAlertsAbatementFlowlet(tcaAppConfig.getTcaAlertsAbatementTableName());
60         addFlowlet(tcavesAlertsAbatementFlowlet);
61
62         final TCAVESAAIEnrichmentFlowlet tcavesaaiEnrichmentFlowlet = new TCAVESAAIEnrichmentFlowlet();
63         addFlowlet(tcavesaaiEnrichmentFlowlet);
64
65         final TCAVESAlertsSinkFlowlet alertsSinkFlowlet =
66                 new TCAVESAlertsSinkFlowlet(tcaAppConfig.getTcaVESAlertsTableName());
67         addFlowlet(alertsSinkFlowlet);
68
69
70         // connect DMaaP MR VES Subscriber output stream to VES Message Router Flowlet
71         connectStream(tcaAppConfig.getTcaSubscriberOutputStreamName(), messageRouterFlowlet);
72         // connect message router to VES threshold calculator
73         connect(messageRouterFlowlet, thresholdViolationCalculatorFlowlet);
74         // connect VES threshold calculator flowlet to Alerts Abatement Flowlet
75         connect(thresholdViolationCalculatorFlowlet, tcavesAlertsAbatementFlowlet);
76         // connect Alerts Abatement flowlet to AAI Enrichment Flowlet
77         connect(tcavesAlertsAbatementFlowlet, tcavesaaiEnrichmentFlowlet);
78         // connect A&AI Enrichment flowlet to Alerts Sink Flowlet
79         connect(tcavesaaiEnrichmentFlowlet,  alertsSinkFlowlet);
80
81     }
82 }