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