2 * ===============================LICENSE_START======================================
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 package org.openecomp.dcae.apod.analytics.cdap.tca.flowlet;
\r
23 import co.cask.cdap.api.annotation.ProcessInput;
\r
24 import co.cask.cdap.api.annotation.Property;
\r
25 import co.cask.cdap.api.dataset.lib.ObjectMappedTable;
\r
26 import co.cask.cdap.api.flow.flowlet.AbstractFlowlet;
\r
27 import co.cask.cdap.api.flow.flowlet.FlowletContext;
\r
28 import org.openecomp.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
\r
29 import org.openecomp.dcae.apod.analytics.cdap.common.persistance.tca.TCAVESAlertEntity;
\r
30 import org.openecomp.dcae.apod.analytics.cdap.common.persistance.tca.TCAVESAlertsPersister;
\r
33 * Saves TCA VES Alert Messages in a Time series Table
\r
35 * @author Rajiv Singla . Creation Date: 11/15/2016.
\r
37 public class TCAVESAlertsSinkFlowlet extends AbstractFlowlet {
\r
40 private final String tcaVESAlertsTableName;
\r
42 private ObjectMappedTable<TCAVESAlertEntity> tcaVESAlertsTable;
\r
44 public TCAVESAlertsSinkFlowlet(String tcaVESAlertsTableName) {
\r
45 this.tcaVESAlertsTableName = tcaVESAlertsTableName;
\r
49 public void configure() {
\r
50 setName(CDAPComponentsConstants.TCA_FIXED_VES_ALERTS_SINK_NAME_FLOWLET);
\r
51 setDescription(CDAPComponentsConstants.TCA_FIXED_VES_ALERTS_SINK_DESCRIPTION_FLOWLET);
\r
55 public void initialize(FlowletContext flowletContext) throws Exception {
\r
56 super.initialize(flowletContext);
\r
57 tcaVESAlertsTable = getContext().getDataset(tcaVESAlertsTableName);
\r
61 * Saves messages to Alerts table
\r
63 * @param alertMessage alert message
\r
65 @ProcessInput(CDAPComponentsConstants.TCA_FIXED_VES_AAI_ENRICHMENT_NAME_OUTPUT)
\r
66 public void saveAlerts(String alertMessage) {
\r
67 // Saves alert message in alerts table
\r
68 TCAVESAlertsPersister.persist(alertMessage, tcaVESAlertsTable);
\r