2 * ===============================LICENSE_START======================================
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * Modifications Copyright (C) 2019 Samsung. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============================LICENSE_END===========================================
22 package org.onap.dcae.apod.analytics.cdap.common.persistance.tca;
24 import org.apache.hadoop.io.Writable;
25 import org.apache.hadoop.io.WritableUtils;
26 import org.onap.dcae.apod.analytics.model.domain.policy.tca.Direction;
27 import org.onap.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
28 import org.onap.dcae.apod.analytics.tca.processor.TCACEFJsonProcessor;
29 import org.onap.dcae.apod.analytics.tca.processor.TCACEFPolicyDomainFilter;
30 import org.onap.dcae.apod.analytics.tca.processor.TCACEFPolicyEventNameFilter;
31 import org.onap.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 eventName;
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 eventNameFilterStatus;
62 private String eventNameFilterMessage;
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 eventName 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 eventName) {
87 this(new TCAMessageStatusEntity.TCAMessageStatusEntityBuilder().setCreationTS(creationTS)
88 .setInstanceId(instanceId).setMessageType(messageType).setVesMessage(vesMessage).setDomain(domain)
89 .setEventName(eventName));
94 * Create new Instance of {@link TCAMessageStatusEntity}
96 * @param builder {@link TCAMessageStatusEntityBuilder}
99 public TCAMessageStatusEntity(TCAMessageStatusEntityBuilder builder) {
100 this.creationTS = builder.creationTS;
101 this.instanceId = builder.instanceId;
102 this.messageType = builder.messageType;
103 this.vesMessage = builder.vesMessage;
104 this.domain = builder.domain;
105 this.eventName = builder.eventName;
106 this.thresholdPath = builder.thresholdPath;
107 this.thresholdSeverity = builder.thresholdSeverity;
108 this.thresholdDirection = builder.thresholdDirection;
109 this.thresholdValue = builder.thresholdValue;
110 this.jsonProcessorStatus = builder.jsonProcessorStatus;
111 this.jsonProcessorMessage = builder.jsonProcessorMessage;
112 this.domainFilterStatus = builder.domainFilterStatus;
113 this.domainFilterMessage = builder.domainFilterMessage;
114 this.eventNameFilterStatus = builder.eventNameFilterStatus;
115 this.eventNameFilterMessage = builder.eventNameFilterMessage;
116 this.thresholdCalculatorStatus = builder.thresholdCalculatorStatus;
117 this.thresholdCalculatorMessage = builder.thresholdCalculatorMessage;
118 this.alertMessage = builder.alertMessage;
122 public static class TCAMessageStatusEntityBuilder {
123 private long creationTS;
124 private int instanceId;
125 private String messageType;
126 private String vesMessage;
127 private String domain;
128 private String eventName;
129 private String thresholdPath = null;
130 private String thresholdSeverity = null;
131 private String thresholdDirection = null;
132 private Long thresholdValue = null;
133 private String jsonProcessorStatus = null;
134 private String jsonProcessorMessage = null;
135 private String domainFilterStatus = null;
136 private String domainFilterMessage = null;
137 private String eventNameFilterStatus = null;
138 private String eventNameFilterMessage = null;
139 private String thresholdCalculatorStatus = null;
140 private String thresholdCalculatorMessage = null;
141 private String alertMessage = null;
143 public TCAMessageStatusEntityBuilder setCreationTS(long creationTS) {
144 this.creationTS = creationTS;
148 public TCAMessageStatusEntityBuilder setInstanceId(int instanceId) {
149 this.instanceId = instanceId;
153 public TCAMessageStatusEntityBuilder setMessageType(String messageType) {
154 this.messageType = messageType;
158 public TCAMessageStatusEntityBuilder setVesMessage(String vesMessage) {
159 this.vesMessage = vesMessage;
163 public TCAMessageStatusEntityBuilder setDomain(String domain) {
164 this.domain = domain;
168 public TCAMessageStatusEntityBuilder setEventName(String eventName) {
169 this.eventName = eventName;
173 public TCAMessageStatusEntityBuilder setThresholdPath(String thresholdPath) {
174 this.thresholdPath = thresholdPath;
178 public TCAMessageStatusEntityBuilder setThresholdSeverity(String thresholdSeverity) {
179 this.thresholdSeverity = thresholdSeverity;
183 public TCAMessageStatusEntityBuilder setThresholdDirection(String thresholdDirection) {
184 this.thresholdDirection = thresholdDirection;
188 public TCAMessageStatusEntityBuilder setThresholdValue(Long thresholdValue) {
189 this.thresholdValue = thresholdValue;
193 public TCAMessageStatusEntityBuilder setJsonProcessorStatus(String jsonProcessorStatus) {
194 this.jsonProcessorStatus = jsonProcessorStatus;
198 public TCAMessageStatusEntityBuilder setJsonProcessorMessage(String jsonProcessorMessage) {
199 this.jsonProcessorMessage = jsonProcessorMessage;
203 public TCAMessageStatusEntityBuilder setDomainFilterStatus(String domainFilterStatus) {
204 this.domainFilterStatus = domainFilterStatus;
208 public TCAMessageStatusEntityBuilder setDomainFilterMessage(String domainFilterMessage) {
209 this.domainFilterMessage = domainFilterMessage;
213 public TCAMessageStatusEntityBuilder setEventNameFilterStatus(String eventNameFilterStatus) {
214 this.eventNameFilterStatus = eventNameFilterStatus;
218 public TCAMessageStatusEntityBuilder setEventNameFilterMessage(String eventNameFilterMessage) {
219 this.eventNameFilterMessage = eventNameFilterMessage;
223 public TCAMessageStatusEntityBuilder setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
224 this.thresholdCalculatorStatus = thresholdCalculatorStatus;
228 public TCAMessageStatusEntityBuilder setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
229 this.thresholdCalculatorMessage = thresholdCalculatorMessage;
233 public TCAMessageStatusEntityBuilder setAlertMessage(String alertMessage) {
234 this.alertMessage = alertMessage;
238 public TCAMessageStatusEntity createTCAMessageStatusEntity() {
239 return new TCAMessageStatusEntity(this);
244 * Provides Creation Timestamp
246 * @return creation timestamp long value
248 public long getCreationTS() {
253 * Sets Creations Timestamp
255 * @param creationTS creation timestamp long value
257 public void setCreationTS(long creationTS) {
258 this.creationTS = creationTS;
263 * Provides CDAP Flowlet instance ID
265 * @return cdap flowlet instance ID
267 public int getInstanceId() {
272 * Sets CDAP Flowlet instance ID
274 * @param instanceId flowlet instance ID
276 public void setInstanceId(int instanceId) {
277 this.instanceId = instanceId;
281 * Provides Message Calculator Type {@link TCACalculatorMessageType}
283 * @return calculator message type
285 public String getMessageType() {
290 * Sets Calculator message Type {@link TCACalculatorMessageType}
292 * @param messageType calculator message type
294 public void setMessageType(String messageType) {
295 this.messageType = messageType;
299 * Provides incoming VES Message
301 * @return ves message
303 public String getVesMessage() {
308 * Set new value for VES message
310 * @param vesMessage ves message
312 public void setVesMessage(String vesMessage) {
313 this.vesMessage = vesMessage;
317 * Provides VES message Domain
319 * @return ves message domain
321 public String getDomain() {
326 * Sets VES Message Domain
328 * @param domain ves message domain
330 public void setDomain(String domain) {
331 this.domain = domain;
335 * Provides VES Message Event Name
337 * @return ves message Event Name
339 public String getEventName() {
344 * Sets VES Message Functional Role
346 * @param eventName ves message Functional Role
348 public void setEventName(String eventName) {
349 this.eventName = eventName;
353 * Violated Threshold Path as extracted from {@link TCAPolicy}
355 * @return violated threshold path
357 public String getThresholdPath() {
358 return thresholdPath;
362 * Sets value for Violated Threshold Path
364 * @param thresholdPath violated threshold path
366 public void setThresholdPath(String thresholdPath) {
367 this.thresholdPath = thresholdPath;
371 * Violated threshold Event Severity
373 * @return event severity
375 public String getThresholdSeverity() {
376 return thresholdSeverity;
380 * Violated Threshold Severity
382 * @param thresholdSeverity violated threshold severity
384 public void setThresholdSeverity(String thresholdSeverity) {
385 this.thresholdSeverity = thresholdSeverity;
389 * Violated Threshold {@link Direction}
391 * @return violated threshold Direction
393 public String getThresholdDirection() {
394 return thresholdDirection;
398 * Sets Violated Threshold Direction
400 * @param thresholdDirection violated threshold direction
402 public void setThresholdDirection(String thresholdDirection) {
403 this.thresholdDirection = thresholdDirection;
407 * Provides Violated Threshold Value
409 * @return violated Threshold value
411 public Long getThresholdValue() {
412 return thresholdValue;
416 * Sets Violated Threshold Value
418 * @param thresholdValue violated threshold value
420 public void setThresholdValue(Long thresholdValue) {
421 this.thresholdValue = thresholdValue;
425 * Provides {@link TCACEFJsonProcessor} status
427 * @return json processor status
429 public String getJsonProcessorStatus() {
430 return jsonProcessorStatus;
434 * Sets Json Processor status
436 * @param jsonProcessorStatus json processor status
438 public void setJsonProcessorStatus(String jsonProcessorStatus) {
439 this.jsonProcessorStatus = jsonProcessorStatus;
443 * Provides {@link TCACEFJsonProcessor} message
445 * @return json processor message
447 public String getJsonProcessorMessage() {
448 return jsonProcessorMessage;
452 * Sets Json Processor Message
454 * @param jsonProcessorMessage json processor message
456 public void setJsonProcessorMessage(String jsonProcessorMessage) {
457 this.jsonProcessorMessage = jsonProcessorMessage;
461 * Provides {@link TCACEFPolicyDomainFilter} status
463 * @return domain filter status
465 public String getDomainFilterStatus() {
466 return domainFilterStatus;
470 * Sets Domain Filter status
472 * @param domainFilterStatus domain filter status
474 public void setDomainFilterStatus(String domainFilterStatus) {
475 this.domainFilterStatus = domainFilterStatus;
479 * Provides {@link TCACEFPolicyDomainFilter} message
481 * @return domain filter message
483 public String getDomainFilterMessage() {
484 return domainFilterMessage;
488 * Sets Domain filter message
490 * @param domainFilterMessage domain filter message
492 public void setDomainFilterMessage(String domainFilterMessage) {
493 this.domainFilterMessage = domainFilterMessage;
496 public String getEventNameFilterStatus() {
497 return eventNameFilterStatus;
501 * Provides {@link TCACEFPolicyEventNameFilter} status
503 * @param eventNameFilterStatus functional Role filter status
505 public void setEventNameFilterStatus(String eventNameFilterStatus) {
506 this.eventNameFilterStatus = eventNameFilterStatus;
510 * Provides {@link TCACEFPolicyEventNameFilter} message
512 * @return functional role filter message
514 public String getEventNameFilterMessage() {
515 return eventNameFilterMessage;
519 * Sets Functional Role filter message
521 * @param eventNameFilterMessage functional role filter message
523 public void setEventNameFilterMessage(String eventNameFilterMessage) {
524 this.eventNameFilterMessage = eventNameFilterMessage;
528 * Provides {@link TCACEFPolicyThresholdsProcessor} status
530 * @return threshold processor status
532 public String getThresholdCalculatorStatus() {
533 return thresholdCalculatorStatus;
537 * Sets threshold calculator status
539 * @param thresholdCalculatorStatus threshold calculator status
541 public void setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
542 this.thresholdCalculatorStatus = thresholdCalculatorStatus;
546 * Provides {@link TCACEFPolicyThresholdsProcessor} message
548 * @return threshold processor message
550 public String getThresholdCalculatorMessage() {
551 return thresholdCalculatorMessage;
555 * Sets Threshold Calculator Processor Message
557 * @param thresholdCalculatorMessage threshold calculator message
559 public void setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
560 this.thresholdCalculatorMessage = thresholdCalculatorMessage;
564 * Provides generated alert message
566 * @return generated alert message
568 public String getAlertMessage() {
575 * @param alertMessage alert message
577 public void setAlertMessage(String alertMessage) {
578 this.alertMessage = alertMessage;
582 * Write entity to Table
584 * @param dataOutput data output
586 * @throws IOException io exception
589 public void write(DataOutput dataOutput) throws IOException {
590 WritableUtils.writeVLong(dataOutput, creationTS);
591 WritableUtils.writeVInt(dataOutput, instanceId);
592 WritableUtils.writeString(dataOutput, messageType);
593 WritableUtils.writeString(dataOutput, vesMessage);
595 WritableUtils.writeString(dataOutput, domain);
596 WritableUtils.writeString(dataOutput, eventName);
598 WritableUtils.writeString(dataOutput, thresholdPath);
599 WritableUtils.writeString(dataOutput, thresholdSeverity);
600 WritableUtils.writeString(dataOutput, thresholdDirection);
601 WritableUtils.writeVLong(dataOutput, thresholdValue);
603 WritableUtils.writeString(dataOutput, jsonProcessorStatus);
604 WritableUtils.writeString(dataOutput, jsonProcessorMessage);
605 WritableUtils.writeString(dataOutput, domainFilterStatus);
606 WritableUtils.writeString(dataOutput, domainFilterMessage);
607 WritableUtils.writeString(dataOutput, eventNameFilterStatus);
608 WritableUtils.writeString(dataOutput, eventNameFilterMessage);
609 WritableUtils.writeString(dataOutput, thresholdCalculatorStatus);
610 WritableUtils.writeString(dataOutput, thresholdCalculatorMessage);
612 WritableUtils.writeString(dataOutput, alertMessage);
617 * Read entity from table
619 * @param dataInput data input
620 * @throws IOException io exception
623 public void readFields(DataInput dataInput) throws IOException {
624 creationTS = WritableUtils.readVLong(dataInput);
625 instanceId = WritableUtils.readVInt(dataInput);
626 messageType = WritableUtils.readString(dataInput);
627 vesMessage = WritableUtils.readString(dataInput);
629 domain = WritableUtils.readString(dataInput);
630 eventName = WritableUtils.readString(dataInput);
632 thresholdPath = WritableUtils.readString(dataInput);
633 thresholdSeverity = WritableUtils.readString(dataInput);
634 thresholdDirection = WritableUtils.readString(dataInput);
635 thresholdValue = WritableUtils.readVLong(dataInput);
637 jsonProcessorStatus = WritableUtils.readString(dataInput);
638 jsonProcessorMessage = WritableUtils.readString(dataInput);
639 domainFilterStatus = WritableUtils.readString(dataInput);
640 domainFilterMessage = WritableUtils.readString(dataInput);
641 eventNameFilterStatus = WritableUtils.readString(dataInput);
642 eventNameFilterMessage = WritableUtils.readString(dataInput);
643 thresholdCalculatorStatus = WritableUtils.readString(dataInput);
644 thresholdCalculatorMessage = WritableUtils.readString(dataInput);
646 alertMessage = WritableUtils.readString(dataInput);