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.policy.tca.Direction;
26 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
27 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFJsonProcessor;
28 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyDomainFilter;
29 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyEventNameFilter;
30 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyThresholdsProcessor;
32 import java.io.DataInput;
33 import java.io.DataOutput;
34 import java.io.IOException;
35 import java.io.Serializable;
38 * TCA Message Status is an Entity which is used to persist TCA VES Message status information in Message Status Table
40 * @author Rajiv Singla . Creation Date: 11/16/2016.
42 public class TCAMessageStatusEntity implements Writable, Serializable {
44 private static final long serialVersionUID = 1L;
46 private long creationTS;
47 private int instanceId;
48 private String messageType;
49 private String vesMessage;
50 private String domain;
51 private String eventName;
52 private String thresholdPath;
53 private String thresholdSeverity;
54 private String thresholdDirection;
55 private Long thresholdValue;
56 private String jsonProcessorStatus;
57 private String jsonProcessorMessage;
58 private String domainFilterStatus;
59 private String domainFilterMessage;
60 private String eventNameFilterStatus;
61 private String eventNameFilterMessage;
62 private String thresholdCalculatorStatus;
63 private String thresholdCalculatorMessage;
64 private String alertMessage;
67 * No Arg constructor required for Jackson Json Serialization / Deserialization
69 public TCAMessageStatusEntity() {
70 // no argument constructor required for json serialization / deserialization
74 * Create new Instance of {@link TCAMessageStatusEntity}
76 * @param creationTS creation Timestamp
77 * @param instanceId CDAP flowlet instance ID
78 * @param messageType {@link TCACalculatorMessageType}
79 * @param vesMessage incoming VES message from collector
80 * @param domain VES message domain if present
81 * @param eventName VES message functional role if present
83 public TCAMessageStatusEntity(final long creationTS, final int instanceId, final String messageType,
84 final String vesMessage, final String domain, final String eventName) {
85 this(creationTS, instanceId, messageType, vesMessage, domain, eventName, null, null, null, null,
86 null, null, null, null, null, null, null, null, null);
91 * Create new Instance of {@link TCAMessageStatusEntity}
93 * @param creationTS creation Timestamp
94 * @param instanceId CDAP flowlet instance ID
95 * @param messageType {@link TCACalculatorMessageType}
96 * @param vesMessage incoming VES message from collector
97 * @param domain VES message domain if present
98 * @param eventName VES message event name if present
99 * @param thresholdPath Violated threshold path
100 * @param thresholdSeverity Violated threshold Severity if any
101 * @param thresholdDirection Violated threshold Direction if any
102 * @param thresholdValue Violated threshold value if any
103 * @param jsonProcessorStatus {@link TCACEFJsonProcessor} status
104 * @param jsonProcessorMessage {@link TCACEFJsonProcessor} message
105 * @param domainFilterStatus {@link TCACEFPolicyDomainFilter} status
106 * @param domainFilterMessage {@link TCACEFPolicyDomainFilter} message
107 * @param eventNameFilterStatus {@link TCACEFPolicyEventNameFilter} status
108 * @param eventNameFilterMessage {@link TCACEFPolicyEventNameFilter} message
109 * @param thresholdCalculatorStatus {@link TCACEFPolicyThresholdsProcessor} status
110 * @param thresholdCalculatorMessage {@link TCACEFPolicyThresholdsProcessor} message
111 * @param alertMessage alert message that will be sent out in case of threshold violation
113 public TCAMessageStatusEntity(long creationTS, int instanceId, String messageType, String vesMessage,
114 String domain, String eventName,
115 String thresholdPath, String thresholdSeverity, String thresholdDirection,
117 String jsonProcessorStatus, String jsonProcessorMessage,
118 String domainFilterStatus, String domainFilterMessage,
119 String eventNameFilterStatus, String eventNameFilterMessage,
120 String thresholdCalculatorStatus, String thresholdCalculatorMessage,
121 String alertMessage) {
122 this.creationTS = creationTS;
123 this.instanceId = instanceId;
124 this.messageType = messageType;
125 this.vesMessage = vesMessage;
126 this.domain = domain;
127 this.eventName = eventName;
128 this.thresholdPath = thresholdPath;
129 this.thresholdSeverity = thresholdSeverity;
130 this.thresholdDirection = thresholdDirection;
131 this.thresholdValue = thresholdValue;
132 this.jsonProcessorStatus = jsonProcessorStatus;
133 this.jsonProcessorMessage = jsonProcessorMessage;
134 this.domainFilterStatus = domainFilterStatus;
135 this.domainFilterMessage = domainFilterMessage;
136 this.eventNameFilterStatus = eventNameFilterStatus;
137 this.eventNameFilterMessage = eventNameFilterMessage;
138 this.thresholdCalculatorStatus = thresholdCalculatorStatus;
139 this.thresholdCalculatorMessage = thresholdCalculatorMessage;
140 this.alertMessage = alertMessage;
144 * Provides Creation Timestamp
146 * @return creation timestamp long value
148 public long getCreationTS() {
153 * Sets Creations Timestamp
155 * @param creationTS creation timestamp long value
157 public void setCreationTS(long creationTS) {
158 this.creationTS = creationTS;
163 * Provides CDAP Flowlet instance ID
165 * @return cdap flowlet instance ID
167 public int getInstanceId() {
172 * Sets CDAP Flowlet instance ID
174 * @param instanceId flowlet instance ID
176 public void setInstanceId(int instanceId) {
177 this.instanceId = instanceId;
181 * Provides Message Calculator Type {@link TCACalculatorMessageType}
183 * @return calculator message type
185 public String getMessageType() {
190 * Sets Calculator message Type {@link TCACalculatorMessageType}
192 * @param messageType calculator message type
194 public void setMessageType(String messageType) {
195 this.messageType = messageType;
199 * Provides incoming VES Message
201 * @return ves message
203 public String getVesMessage() {
208 * Set new value for VES message
210 * @param vesMessage ves message
212 public void setVesMessage(String vesMessage) {
213 this.vesMessage = vesMessage;
217 * Provides VES message Domain
219 * @return ves message domain
221 public String getDomain() {
226 * Sets VES Message Domain
228 * @param domain ves message domain
230 public void setDomain(String domain) {
231 this.domain = domain;
235 * Provides VES Message Event Name
237 * @return ves message Event Name
239 public String getEventName() {
244 * Sets VES Message Functional Role
246 * @param eventName ves message Functional Role
248 public void setEventName(String eventName) {
249 this.eventName = eventName;
253 * Violated Threshold Path as extracted from {@link TCAPolicy}
255 * @return violated threshold path
257 public String getThresholdPath() {
258 return thresholdPath;
262 * Sets value for Violated Threshold Path
264 * @param thresholdPath violated threshold path
266 public void setThresholdPath(String thresholdPath) {
267 this.thresholdPath = thresholdPath;
271 * Violated threshold Event Severity
273 * @return event severity
275 public String getThresholdSeverity() {
276 return thresholdSeverity;
280 * Violated Threshold Severity
282 * @param thresholdSeverity violated threshold severity
284 public void setThresholdSeverity(String thresholdSeverity) {
285 this.thresholdSeverity = thresholdSeverity;
289 * Violated Threshold {@link Direction}
291 * @return violated threshold Direction
293 public String getThresholdDirection() {
294 return thresholdDirection;
298 * Sets Violated Threshold Direction
300 * @param thresholdDirection violated threshold direction
302 public void setThresholdDirection(String thresholdDirection) {
303 this.thresholdDirection = thresholdDirection;
307 * Provides Violated Threshold Value
309 * @return violated Threshold value
311 public Long getThresholdValue() {
312 return thresholdValue;
316 * Sets Violated Threshold Value
318 * @param thresholdValue violated threshold value
320 public void setThresholdValue(Long thresholdValue) {
321 this.thresholdValue = thresholdValue;
325 * Provides {@link TCACEFJsonProcessor} status
327 * @return json processor status
329 public String getJsonProcessorStatus() {
330 return jsonProcessorStatus;
334 * Sets Json Processor status
336 * @param jsonProcessorStatus json processor status
338 public void setJsonProcessorStatus(String jsonProcessorStatus) {
339 this.jsonProcessorStatus = jsonProcessorStatus;
343 * Provides {@link TCACEFJsonProcessor} message
345 * @return json processor message
347 public String getJsonProcessorMessage() {
348 return jsonProcessorMessage;
352 * Sets Json Processor Message
354 * @param jsonProcessorMessage json processor message
356 public void setJsonProcessorMessage(String jsonProcessorMessage) {
357 this.jsonProcessorMessage = jsonProcessorMessage;
361 * Provides {@link TCACEFPolicyDomainFilter} status
363 * @return domain filter status
365 public String getDomainFilterStatus() {
366 return domainFilterStatus;
370 * Sets Domain Filter status
372 * @param domainFilterStatus domain filter status
374 public void setDomainFilterStatus(String domainFilterStatus) {
375 this.domainFilterStatus = domainFilterStatus;
379 * Provides {@link TCACEFPolicyDomainFilter} message
381 * @return domain filter message
383 public String getDomainFilterMessage() {
384 return domainFilterMessage;
388 * Sets Domain filter message
390 * @param domainFilterMessage domain filter message
392 public void setDomainFilterMessage(String domainFilterMessage) {
393 this.domainFilterMessage = domainFilterMessage;
396 public String getEventNameFilterStatus() {
397 return eventNameFilterStatus;
401 * Provides {@link TCACEFPolicyEventNameFilter} status
403 * @param eventNameFilterStatus functional Role filter status
405 public void setEventNameFilterStatus(String eventNameFilterStatus) {
406 this.eventNameFilterStatus = eventNameFilterStatus;
410 * Provides {@link TCACEFPolicyEventNameFilter} message
412 * @return functional role filter message
414 public String getEventNameFilterMessage() {
415 return eventNameFilterMessage;
419 * Sets Functional Role filter message
421 * @param eventNameFilterMessage functional role filter message
423 public void setEventNameFilterMessage(String eventNameFilterMessage) {
424 this.eventNameFilterMessage = eventNameFilterMessage;
428 * Provides {@link TCACEFPolicyThresholdsProcessor} status
430 * @return threshold processor status
432 public String getThresholdCalculatorStatus() {
433 return thresholdCalculatorStatus;
437 * Sets threshold calculator status
439 * @param thresholdCalculatorStatus threshold calculator status
441 public void setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
442 this.thresholdCalculatorStatus = thresholdCalculatorStatus;
446 * Provides {@link TCACEFPolicyThresholdsProcessor} message
448 * @return threshold processor message
450 public String getThresholdCalculatorMessage() {
451 return thresholdCalculatorMessage;
455 * Sets Threshold Calculator Processor Message
457 * @param thresholdCalculatorMessage threshold calculator message
459 public void setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
460 this.thresholdCalculatorMessage = thresholdCalculatorMessage;
464 * Provides generated alert message
466 * @return generated alert message
468 public String getAlertMessage() {
475 * @param alertMessage alert message
477 public void setAlertMessage(String alertMessage) {
478 this.alertMessage = alertMessage;
482 * Write entity to Table
484 * @param dataOutput data output
486 * @throws IOException io exception
489 public void write(DataOutput dataOutput) throws IOException {
490 WritableUtils.writeVLong(dataOutput, creationTS);
491 WritableUtils.writeVInt(dataOutput, instanceId);
492 WritableUtils.writeString(dataOutput, messageType);
493 WritableUtils.writeString(dataOutput, vesMessage);
495 WritableUtils.writeString(dataOutput, domain);
496 WritableUtils.writeString(dataOutput, eventName);
498 WritableUtils.writeString(dataOutput, thresholdPath);
499 WritableUtils.writeString(dataOutput, thresholdSeverity);
500 WritableUtils.writeString(dataOutput, thresholdDirection);
501 WritableUtils.writeVLong(dataOutput, thresholdValue);
503 WritableUtils.writeString(dataOutput, jsonProcessorStatus);
504 WritableUtils.writeString(dataOutput, jsonProcessorMessage);
505 WritableUtils.writeString(dataOutput, domainFilterStatus);
506 WritableUtils.writeString(dataOutput, domainFilterMessage);
507 WritableUtils.writeString(dataOutput, eventNameFilterStatus);
508 WritableUtils.writeString(dataOutput, eventNameFilterMessage);
509 WritableUtils.writeString(dataOutput, thresholdCalculatorStatus);
510 WritableUtils.writeString(dataOutput, thresholdCalculatorMessage);
512 WritableUtils.writeString(dataOutput, alertMessage);
517 * Read entity from table
519 * @param dataInput data input
520 * @throws IOException io exception
523 public void readFields(DataInput dataInput) throws IOException {
524 creationTS = WritableUtils.readVLong(dataInput);
525 instanceId = WritableUtils.readVInt(dataInput);
526 messageType = WritableUtils.readString(dataInput);
527 vesMessage = WritableUtils.readString(dataInput);
529 domain = WritableUtils.readString(dataInput);
530 eventName = WritableUtils.readString(dataInput);
532 thresholdPath = WritableUtils.readString(dataInput);
533 thresholdSeverity = WritableUtils.readString(dataInput);
534 thresholdDirection = WritableUtils.readString(dataInput);
535 thresholdValue = WritableUtils.readVLong(dataInput);
537 jsonProcessorStatus = WritableUtils.readString(dataInput);
538 jsonProcessorMessage = WritableUtils.readString(dataInput);
539 domainFilterStatus = WritableUtils.readString(dataInput);
540 domainFilterMessage = WritableUtils.readString(dataInput);
541 eventNameFilterStatus = WritableUtils.readString(dataInput);
542 eventNameFilterMessage = WritableUtils.readString(dataInput);
543 thresholdCalculatorStatus = WritableUtils.readString(dataInput);
544 thresholdCalculatorMessage = WritableUtils.readString(dataInput);
546 alertMessage = WritableUtils.readString(dataInput);