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.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.openecomp.dcae.apod.analytics.cdap.common.CDAPComponentsConstants;
31 import static org.openecomp.dcae.apod.analytics.common.AnalyticsConstants.TCA_VES_MESSAGE_ROUTER_PARTITION_KEY;
35 * TCA Message Router Flowlet emits VES Message to {@link TCAVESThresholdViolationCalculatorFlowlet} instances
37 * @author Rajiv Singla . Creation Date: 11/14/2016.
39 public class TCAVESMessageRouterFlowlet extends AbstractFlowlet {
42 * Emits ves message to TCA Calculator Instances
44 @Output(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_OUTPUT)
45 protected OutputEmitter<String> vesMessageEmitter;
49 public void configure() {
50 setName(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_NAME_FLOWLET);
51 setDescription(CDAPComponentsConstants.TCA_FIXED_VES_MESSAGE_ROUTER_DESCRIPTION_FLOWLET);
55 public void routeVESMessage(StreamEvent vesMessageStreamEvent) {
56 final String vesMessage = Charsets.UTF_8.decode(vesMessageStreamEvent.getBody()).toString();
57 vesMessageEmitter.emit(vesMessage, TCA_VES_MESSAGE_ROUTER_PARTITION_KEY, vesMessage.hashCode());