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