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.common.persistance.tca;
23 import org.apache.hadoop.io.Writable;
24 import org.apache.hadoop.io.WritableUtils;
25 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventSeverity;
26 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Direction;
27 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
28 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFJsonProcessor;
29 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyDomainFilter;
30 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyFunctionalRoleFilter;
31 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyThresholdsProcessor;
33 import java.io.DataInput;
34 import java.io.DataOutput;
35 import java.io.IOException;
36 import java.io.Serializable;
39 * TCA Message Status is an Entity which is used to persist TCA VES Message status information in Message Status Table
41 * @author Rajiv Singla . Creation Date: 11/16/2016.
43 public class TCAMessageStatusEntity implements Writable, Serializable {
45 private static final long serialVersionUID = 1L;
47 private long creationTS;
48 private int instanceId;
49 private String messageType;
50 private String vesMessage;
51 private String domain;
52 private String functionalRole;
53 private String thresholdPath;
54 private String thresholdSeverity;
55 private String thresholdDirection;
56 private Long thresholdValue;
57 private String jsonProcessorStatus;
58 private String jsonProcessorMessage;
59 private String domainFilterStatus;
60 private String domainFilterMessage;
61 private String functionalRoleFilterStatus;
62 private String functionalRoleFilterMessage;
63 private String thresholdCalculatorStatus;
64 private String thresholdCalculatorMessage;
65 private String alertMessage;
68 * No Arg constructor required for Jackson Json Serialization / Deserialization
70 public TCAMessageStatusEntity() {
71 // no argument constructor required for json serialization / deserialization
75 * Create new Instance of {@link TCAMessageStatusEntity}
77 * @param creationTS creation Timestamp
78 * @param instanceId CDAP flowlet instance ID
79 * @param messageType {@link TCACalculatorMessageType}
80 * @param vesMessage incoming VES message from collector
81 * @param domain VES message domain if present
82 * @param functionalRole VES message functional role if present
84 public TCAMessageStatusEntity(final long creationTS, final int instanceId, final String messageType,
85 final String vesMessage, final String domain, final String functionalRole) {
86 this(creationTS, instanceId, messageType, vesMessage, domain, functionalRole, null, null, null, null,
87 null, null, null, null, null, null, null, null, null);
92 * Create new Instance of {@link TCAMessageStatusEntity}
94 * @param creationTS creation Timestamp
95 * @param instanceId CDAP flowlet instance ID
96 * @param messageType {@link TCACalculatorMessageType}
97 * @param vesMessage incoming VES message from collector
98 * @param domain VES message domain if present
99 * @param functionalRole VES message functional role if present
100 * @param thresholdPath Violated threshold path
101 * @param thresholdSeverity Violated threshold Severity if any
102 * @param thresholdDirection Violated threshold Direction if any
103 * @param thresholdValue Violated threshold value if any
104 * @param jsonProcessorStatus {@link TCACEFJsonProcessor} status
105 * @param jsonProcessorMessage {@link TCACEFJsonProcessor} message
106 * @param domainFilterStatus {@link TCACEFPolicyDomainFilter} status
107 * @param domainFilterMessage {@link TCACEFPolicyDomainFilter} message
108 * @param functionalRoleFilterStatus
109 * {@link TCACEFPolicyFunctionalRoleFilter} status
110 * @param functionalRoleFilterMessage
111 * {@link TCACEFPolicyFunctionalRoleFilter} message
112 * @param thresholdCalculatorStatus
113 * {@link TCACEFPolicyThresholdsProcessor} status
114 * @param thresholdCalculatorMessage
115 * {@link TCACEFPolicyThresholdsProcessor} message
116 * @param alertMessage alert message that will be sent out in case of threshold violation
118 public TCAMessageStatusEntity(long creationTS, int instanceId, String messageType, String vesMessage,
119 String domain, String functionalRole,
120 String thresholdPath, String thresholdSeverity, String thresholdDirection,
122 String jsonProcessorStatus, String jsonProcessorMessage,
123 String domainFilterStatus, String domainFilterMessage,
124 String functionalRoleFilterStatus, String functionalRoleFilterMessage,
125 String thresholdCalculatorStatus, String thresholdCalculatorMessage,
126 String alertMessage) {
127 this.creationTS = creationTS;
128 this.instanceId = instanceId;
129 this.messageType = messageType;
130 this.vesMessage = vesMessage;
131 this.domain = domain;
132 this.functionalRole = functionalRole;
133 this.thresholdPath = thresholdPath;
134 this.thresholdSeverity = thresholdSeverity;
135 this.thresholdDirection = thresholdDirection;
136 this.thresholdValue = thresholdValue;
137 this.jsonProcessorStatus = jsonProcessorStatus;
138 this.jsonProcessorMessage = jsonProcessorMessage;
139 this.domainFilterStatus = domainFilterStatus;
140 this.domainFilterMessage = domainFilterMessage;
141 this.functionalRoleFilterStatus = functionalRoleFilterStatus;
142 this.functionalRoleFilterMessage = functionalRoleFilterMessage;
143 this.thresholdCalculatorStatus = thresholdCalculatorStatus;
144 this.thresholdCalculatorMessage = thresholdCalculatorMessage;
145 this.alertMessage = alertMessage;
149 * Provides Creation Timestamp
151 * @return creation timestamp long value
153 public long getCreationTS() {
158 * Sets Creations Timestamp
160 * @param creationTS creation timestamp long value
162 public void setCreationTS(long creationTS) {
163 this.creationTS = creationTS;
168 * Provides CDAP Flowlet instance ID
170 * @return cdap flowlet instance ID
172 public int getInstanceId() {
177 * Sets CDAP Flowlet instance ID
179 * @param instanceId flowlet instance ID
181 public void setInstanceId(int instanceId) {
182 this.instanceId = instanceId;
186 * Provides Message Calculator Type {@link TCACalculatorMessageType}
188 * @return calculator message type
190 public String getMessageType() {
195 * Sets Calculator message Type {@link TCACalculatorMessageType}
197 * @param messageType calculator message type
199 public void setMessageType(String messageType) {
200 this.messageType = messageType;
204 * Provides incoming VES Message
206 * @return ves message
208 public String getVesMessage() {
213 * Set new value for VES message
215 * @param vesMessage ves message
217 public void setVesMessage(String vesMessage) {
218 this.vesMessage = vesMessage;
222 * Provides VES message Domain
224 * @return ves message domain
226 public String getDomain() {
231 * Sets VES Message Domain
233 * @param domain ves message domain
235 public void setDomain(String domain) {
236 this.domain = domain;
240 * Provides VES Message Functional Role
242 * @return ves message functional role
244 public String getFunctionalRole() {
245 return functionalRole;
249 * Sets VES Message Functional Role
251 * @param functionalRole ves message Functional Role
253 public void setFunctionalRole(String functionalRole) {
254 this.functionalRole = functionalRole;
258 * Violated Threshold Path as extracted from {@link TCAPolicy}
260 * @return violated threshold path
262 public String getThresholdPath() {
263 return thresholdPath;
267 * Sets value for Violated Threshold Path
269 * @param thresholdPath violated threshold path
271 public void setThresholdPath(String thresholdPath) {
272 this.thresholdPath = thresholdPath;
276 * Violated threshold {@link EventSeverity}
278 * @return event severity
280 public String getThresholdSeverity() {
281 return thresholdSeverity;
285 * Violated Threshold Severity
287 * @param thresholdSeverity violated threshold severity
289 public void setThresholdSeverity(String thresholdSeverity) {
290 this.thresholdSeverity = thresholdSeverity;
294 * Violated Threshold {@link Direction}
296 * @return violated threshold Direction
298 public String getThresholdDirection() {
299 return thresholdDirection;
303 * Sets Violated Threshold Direction
305 * @param thresholdDirection violated threshold direction
307 public void setThresholdDirection(String thresholdDirection) {
308 this.thresholdDirection = thresholdDirection;
312 * Provides Violated Threshold Value
314 * @return violated Threshold value
316 public Long getThresholdValue() {
317 return thresholdValue;
321 * Sets Violated Threshold Value
323 * @param thresholdValue violated threshold value
325 public void setThresholdValue(Long thresholdValue) {
326 this.thresholdValue = thresholdValue;
330 * Provides {@link TCACEFJsonProcessor} status
332 * @return json processor status
334 public String getJsonProcessorStatus() {
335 return jsonProcessorStatus;
339 * Sets Json Processor status
341 * @param jsonProcessorStatus json processor status
343 public void setJsonProcessorStatus(String jsonProcessorStatus) {
344 this.jsonProcessorStatus = jsonProcessorStatus;
348 * Provides {@link TCACEFJsonProcessor} message
350 * @return json processor message
352 public String getJsonProcessorMessage() {
353 return jsonProcessorMessage;
357 * Sets Json Processor Message
359 * @param jsonProcessorMessage json processor message
361 public void setJsonProcessorMessage(String jsonProcessorMessage) {
362 this.jsonProcessorMessage = jsonProcessorMessage;
366 * Provides {@link TCACEFPolicyDomainFilter} status
368 * @return domain filter status
370 public String getDomainFilterStatus() {
371 return domainFilterStatus;
375 * Sets Domain Filter status
377 * @param domainFilterStatus domain filter status
379 public void setDomainFilterStatus(String domainFilterStatus) {
380 this.domainFilterStatus = domainFilterStatus;
384 * Provides {@link TCACEFPolicyDomainFilter} message
386 * @return domain filter message
388 public String getDomainFilterMessage() {
389 return domainFilterMessage;
393 * Sets Domain filter message
395 * @param domainFilterMessage domain filter message
397 public void setDomainFilterMessage(String domainFilterMessage) {
398 this.domainFilterMessage = domainFilterMessage;
401 public String getFunctionalRoleFilterStatus() {
402 return functionalRoleFilterStatus;
406 * Provides {@link TCACEFPolicyFunctionalRoleFilter} status
408 * @param functionalRoleFilterStatus functional Role filter status
410 public void setFunctionalRoleFilterStatus(String functionalRoleFilterStatus) {
411 this.functionalRoleFilterStatus = functionalRoleFilterStatus;
415 * Provides {@link TCACEFPolicyFunctionalRoleFilter} message
417 * @return functional role filter message
419 public String getFunctionalRoleFilterMessage() {
420 return functionalRoleFilterMessage;
424 * Sets Functional Role filter message
426 * @param functionalRoleFilterMessage functional role filter message
428 public void setFunctionalRoleFilterMessage(String functionalRoleFilterMessage) {
429 this.functionalRoleFilterMessage = functionalRoleFilterMessage;
433 * Provides {@link TCACEFPolicyThresholdsProcessor} status
435 * @return threshold processor status
437 public String getThresholdCalculatorStatus() {
438 return thresholdCalculatorStatus;
442 * Sets threshold calculator status
444 * @param thresholdCalculatorStatus threshold calculator status
446 public void setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
447 this.thresholdCalculatorStatus = thresholdCalculatorStatus;
451 * Provides {@link TCACEFPolicyThresholdsProcessor} message
453 * @return threshold processor message
455 public String getThresholdCalculatorMessage() {
456 return thresholdCalculatorMessage;
460 * Sets Threshold Calculator Processor Message
462 * @param thresholdCalculatorMessage threshold calculator message
464 public void setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
465 this.thresholdCalculatorMessage = thresholdCalculatorMessage;
469 * Provides generated alert message
471 * @return generated alert message
473 public String getAlertMessage() {
480 * @param alertMessage alert message
482 public void setAlertMessage(String alertMessage) {
483 this.alertMessage = alertMessage;
487 * Write entity to Table
489 * @param dataOutput data output
491 * @throws IOException io exception
494 public void write(DataOutput dataOutput) throws IOException {
495 WritableUtils.writeVLong(dataOutput, creationTS);
496 WritableUtils.writeVInt(dataOutput, instanceId);
497 WritableUtils.writeString(dataOutput, messageType);
498 WritableUtils.writeString(dataOutput, vesMessage);
500 WritableUtils.writeString(dataOutput, domain);
501 WritableUtils.writeString(dataOutput, functionalRole);
503 WritableUtils.writeString(dataOutput, thresholdPath);
504 WritableUtils.writeString(dataOutput, thresholdSeverity);
505 WritableUtils.writeString(dataOutput, thresholdDirection);
506 WritableUtils.writeVLong(dataOutput, thresholdValue);
508 WritableUtils.writeString(dataOutput, jsonProcessorStatus);
509 WritableUtils.writeString(dataOutput, jsonProcessorMessage);
510 WritableUtils.writeString(dataOutput, domainFilterStatus);
511 WritableUtils.writeString(dataOutput, domainFilterMessage);
512 WritableUtils.writeString(dataOutput, functionalRoleFilterStatus);
513 WritableUtils.writeString(dataOutput, functionalRoleFilterMessage);
514 WritableUtils.writeString(dataOutput, thresholdCalculatorStatus);
515 WritableUtils.writeString(dataOutput, thresholdCalculatorMessage);
517 WritableUtils.writeString(dataOutput, alertMessage);
522 * Read entity from table
524 * @param dataInput data input
525 * @throws IOException io exception
528 public void readFields(DataInput dataInput) throws IOException {
529 creationTS = WritableUtils.readVLong(dataInput);
530 instanceId = WritableUtils.readVInt(dataInput);
531 messageType = WritableUtils.readString(dataInput);
532 vesMessage = WritableUtils.readString(dataInput);
534 domain = WritableUtils.readString(dataInput);
535 functionalRole = WritableUtils.readString(dataInput);
537 thresholdPath = WritableUtils.readString(dataInput);
538 thresholdSeverity = WritableUtils.readString(dataInput);
539 thresholdDirection = WritableUtils.readString(dataInput);
540 thresholdValue = WritableUtils.readVLong(dataInput);
542 jsonProcessorStatus = WritableUtils.readString(dataInput);
543 jsonProcessorMessage = WritableUtils.readString(dataInput);
544 domainFilterStatus = WritableUtils.readString(dataInput);
545 domainFilterMessage = WritableUtils.readString(dataInput);
546 functionalRoleFilterStatus = WritableUtils.readString(dataInput);
547 functionalRoleFilterMessage = WritableUtils.readString(dataInput);
548 thresholdCalculatorStatus = WritableUtils.readString(dataInput);
549 thresholdCalculatorMessage = WritableUtils.readString(dataInput);
551 alertMessage = WritableUtils.readString(dataInput);