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.onap.dcae.apod.analytics.cdap.tca.flowlet;
23 import co.cask.cdap.api.annotation.Output;
24 import co.cask.cdap.api.annotation.ProcessInput;
25 import co.cask.cdap.api.flow.flowlet.AbstractFlowlet;
26 import co.cask.cdap.api.flow.flowlet.OutputEmitter;
27 import co.cask.cdap.api.flow.flowlet.StreamEvent;
28 import com.google.common.base.Charsets;
29 import org.onap.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
30 import org.onap.dcae.apod.analytics.common.AnalyticsConstants;
34 * TCA Message Router Flowlet emits VES Message to {@link TCAVESThresholdViolationCalculatorFlowlet} instances
36 * @author Rajiv Singla . Creation Date: 11/14/2016.
38 public class TCAVESMessageRouterFlowlet extends AbstractFlowlet {
41 * Emits ves message to TCA Calculator Instances
43 @Output(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_OUTPUT)
44 protected OutputEmitter<String> vesMessageEmitter;
48 public void configure() {
49 setName(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_NAME_FLOWLET);
50 setDescription(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_DESCRIPTION_FLOWLET);
54 public void routeVESMessage(StreamEvent vesMessageStreamEvent) {
55 final String vesMessage = Charsets.UTF_8.decode(vesMessageStreamEvent.getBody()).toString();
56 vesMessageEmitter.emit(
57 vesMessage, AnalyticsConstants.TCA_VES_MESSAGE_ROUTER_PARTITION_KEY, vesMessage.hashCode());