64b116e9722b9d7d0a38d9bd205108aa3b213df1
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-common / src / main / java / org / onap / dcae / apod / analytics / cdap / common / persistance / tca / TCAMessageStatusEntity.java
1 /*
2  * ===============================LICENSE_START======================================
3  *  dcae-analytics
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
11  *
12  *          http://www.apache.org/licenses/LICENSE-2.0
13  *
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===========================================
20  */
21
22 package org.onap.dcae.apod.analytics.cdap.common.persistance.tca;
23
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;
32
33 import java.io.DataInput;
34 import java.io.DataOutput;
35 import java.io.IOException;
36 import java.io.Serializable;
37
38 /**
39  * TCA Message Status is an Entity which is used to persist TCA VES Message status information in Message Status Table
40  *
41  * @author Rajiv Singla . Creation Date: 11/16/2016.
42  */
43 public class TCAMessageStatusEntity implements Writable, Serializable {
44
45     private static final long serialVersionUID = 1L;
46
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;
66
67     /**
68      * No Arg constructor required for Jackson Json Serialization / Deserialization
69      */
70     public TCAMessageStatusEntity() {
71         // no argument constructor required for json serialization / deserialization
72     }
73
74     /**
75      * Create new Instance of {@link TCAMessageStatusEntity}
76      *
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
83      */
84     public TCAMessageStatusEntity(final long creationTS, final int instanceId, final String messageType,
85                                   final String vesMessage, final String domain, final String eventName) {
86
87         this(new TCAMessageStatusEntity.TCAMessageStatusEntityBuilder().setCreationTS(creationTS)
88                 .setInstanceId(instanceId).setMessageType(messageType).setVesMessage(vesMessage).setDomain(domain)
89                 .setEventName(eventName));
90     }
91
92
93     /**
94      * Create new Instance of {@link TCAMessageStatusEntity}
95      *
96      * @param builder {@link TCAMessageStatusEntityBuilder}
97      */
98
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;
119
120     }
121
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;
142
143         public TCAMessageStatusEntityBuilder setCreationTS(long creationTS) {
144             this.creationTS = creationTS;
145             return this;
146         }
147
148         public TCAMessageStatusEntityBuilder setInstanceId(int instanceId) {
149             this.instanceId = instanceId;
150             return this;
151         }
152
153         public TCAMessageStatusEntityBuilder setMessageType(String messageType) {
154             this.messageType = messageType;
155             return this;
156         }
157
158         public TCAMessageStatusEntityBuilder setVesMessage(String vesMessage) {
159             this.vesMessage = vesMessage;
160             return this;
161         }
162
163         public TCAMessageStatusEntityBuilder setDomain(String domain) {
164             this.domain = domain;
165             return this;
166         }
167
168         public TCAMessageStatusEntityBuilder setEventName(String eventName) {
169             this.eventName = eventName;
170             return this;
171         }
172
173         public TCAMessageStatusEntityBuilder setThresholdPath(String thresholdPath) {
174             this.thresholdPath = thresholdPath;
175             return this;
176         }
177
178         public TCAMessageStatusEntityBuilder setThresholdSeverity(String thresholdSeverity) {
179             this.thresholdSeverity = thresholdSeverity;
180             return this;
181         }
182
183         public TCAMessageStatusEntityBuilder setThresholdDirection(String thresholdDirection) {
184             this.thresholdDirection = thresholdDirection;
185             return this;
186         }
187
188         public TCAMessageStatusEntityBuilder setThresholdValue(Long thresholdValue) {
189             this.thresholdValue = thresholdValue;
190             return this;
191         }
192
193         public TCAMessageStatusEntityBuilder setJsonProcessorStatus(String jsonProcessorStatus) {
194             this.jsonProcessorStatus = jsonProcessorStatus;
195             return this;
196         }
197
198         public TCAMessageStatusEntityBuilder setJsonProcessorMessage(String jsonProcessorMessage) {
199             this.jsonProcessorMessage = jsonProcessorMessage;
200             return this;
201         }
202
203         public TCAMessageStatusEntityBuilder setDomainFilterStatus(String domainFilterStatus) {
204             this.domainFilterStatus = domainFilterStatus;
205             return this;
206         }
207
208         public TCAMessageStatusEntityBuilder setDomainFilterMessage(String domainFilterMessage) {
209             this.domainFilterMessage = domainFilterMessage;
210             return this;
211         }
212
213         public TCAMessageStatusEntityBuilder setEventNameFilterStatus(String eventNameFilterStatus) {
214             this.eventNameFilterStatus = eventNameFilterStatus;
215             return this;
216         }
217
218         public TCAMessageStatusEntityBuilder setEventNameFilterMessage(String eventNameFilterMessage) {
219             this.eventNameFilterMessage = eventNameFilterMessage;
220             return this;
221         }
222
223         public TCAMessageStatusEntityBuilder setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
224             this.thresholdCalculatorStatus = thresholdCalculatorStatus;
225             return this;
226         }
227
228         public TCAMessageStatusEntityBuilder setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
229             this.thresholdCalculatorMessage = thresholdCalculatorMessage;
230             return this;
231         }
232
233         public TCAMessageStatusEntityBuilder setAlertMessage(String alertMessage) {
234             this.alertMessage = alertMessage;
235             return this;
236         }
237
238         public TCAMessageStatusEntity createTCAMessageStatusEntity() {
239             return new TCAMessageStatusEntity(this);
240         }
241     }
242
243     /**
244      * Provides Creation Timestamp
245      *
246      * @return creation timestamp long value
247      */
248     public long getCreationTS() {
249         return creationTS;
250     }
251
252     /**
253      * Sets Creations Timestamp
254      *
255      * @param creationTS creation timestamp long value
256      */
257     public void setCreationTS(long creationTS) {
258         this.creationTS = creationTS;
259     }
260
261
262     /**
263      * Provides CDAP Flowlet instance ID
264      *
265      * @return cdap flowlet instance ID
266      */
267     public int getInstanceId() {
268         return instanceId;
269     }
270
271     /**
272      * Sets CDAP Flowlet instance ID
273      *
274      * @param instanceId flowlet instance ID
275      */
276     public void setInstanceId(int instanceId) {
277         this.instanceId = instanceId;
278     }
279
280     /**
281      * Provides Message Calculator Type {@link TCACalculatorMessageType}
282      *
283      * @return calculator message type
284      */
285     public String getMessageType() {
286         return messageType;
287     }
288
289     /**
290      * Sets Calculator message Type {@link TCACalculatorMessageType}
291      *
292      * @param messageType calculator message type
293      */
294     public void setMessageType(String messageType) {
295         this.messageType = messageType;
296     }
297
298     /**
299      * Provides incoming VES Message
300      *
301      * @return ves message
302      */
303     public String getVesMessage() {
304         return vesMessage;
305     }
306
307     /**
308      * Set new value for VES message
309      *
310      * @param vesMessage ves message
311      */
312     public void setVesMessage(String vesMessage) {
313         this.vesMessage = vesMessage;
314     }
315
316     /**
317      * Provides VES message Domain
318      *
319      * @return ves message domain
320      */
321     public String getDomain() {
322         return domain;
323     }
324
325     /**
326      * Sets VES Message Domain
327      *
328      * @param domain ves message domain
329      */
330     public void setDomain(String domain) {
331         this.domain = domain;
332     }
333
334     /**
335      * Provides VES Message Event Name
336      *
337      * @return ves message Event Name
338      */
339     public String getEventName() {
340         return eventName;
341     }
342
343     /**
344      * Sets VES Message Functional Role
345      *
346      * @param eventName ves message Functional Role
347      */
348     public void setEventName(String eventName) {
349         this.eventName = eventName;
350     }
351
352     /**
353      * Violated Threshold Path as extracted from {@link TCAPolicy}
354      *
355      * @return violated threshold path
356      */
357     public String getThresholdPath() {
358         return thresholdPath;
359     }
360
361     /**
362      * Sets value for Violated Threshold Path
363      *
364      * @param thresholdPath violated threshold path
365      */
366     public void setThresholdPath(String thresholdPath) {
367         this.thresholdPath = thresholdPath;
368     }
369
370     /**
371      * Violated threshold Event Severity
372      *
373      * @return event severity
374      */
375     public String getThresholdSeverity() {
376         return thresholdSeverity;
377     }
378
379     /**
380      * Violated Threshold Severity
381      *
382      * @param thresholdSeverity violated threshold severity
383      */
384     public void setThresholdSeverity(String thresholdSeverity) {
385         this.thresholdSeverity = thresholdSeverity;
386     }
387
388     /**
389      * Violated Threshold {@link Direction}
390      *
391      * @return violated threshold Direction
392      */
393     public String getThresholdDirection() {
394         return thresholdDirection;
395     }
396
397     /**
398      * Sets Violated Threshold Direction
399      *
400      * @param thresholdDirection violated threshold direction
401      */
402     public void setThresholdDirection(String thresholdDirection) {
403         this.thresholdDirection = thresholdDirection;
404     }
405
406     /**
407      * Provides Violated Threshold Value
408      *
409      * @return violated Threshold value
410      */
411     public Long getThresholdValue() {
412         return thresholdValue;
413     }
414
415     /**
416      * Sets Violated Threshold Value
417      *
418      * @param thresholdValue violated threshold value
419      */
420     public void setThresholdValue(Long thresholdValue) {
421         this.thresholdValue = thresholdValue;
422     }
423
424     /**
425      * Provides {@link TCACEFJsonProcessor} status
426      *
427      * @return json processor status
428      */
429     public String getJsonProcessorStatus() {
430         return jsonProcessorStatus;
431     }
432
433     /**
434      * Sets Json Processor status
435      *
436      * @param jsonProcessorStatus json processor status
437      */
438     public void setJsonProcessorStatus(String jsonProcessorStatus) {
439         this.jsonProcessorStatus = jsonProcessorStatus;
440     }
441
442     /**
443      * Provides {@link TCACEFJsonProcessor} message
444      *
445      * @return json processor message
446      */
447     public String getJsonProcessorMessage() {
448         return jsonProcessorMessage;
449     }
450
451     /**
452      * Sets Json Processor Message
453      *
454      * @param jsonProcessorMessage json processor message
455      */
456     public void setJsonProcessorMessage(String jsonProcessorMessage) {
457         this.jsonProcessorMessage = jsonProcessorMessage;
458     }
459
460     /**
461      * Provides {@link TCACEFPolicyDomainFilter} status
462      *
463      * @return domain filter status
464      */
465     public String getDomainFilterStatus() {
466         return domainFilterStatus;
467     }
468
469     /**
470      * Sets Domain Filter status
471      *
472      * @param domainFilterStatus domain filter status
473      */
474     public void setDomainFilterStatus(String domainFilterStatus) {
475         this.domainFilterStatus = domainFilterStatus;
476     }
477
478     /**
479      * Provides {@link TCACEFPolicyDomainFilter} message
480      *
481      * @return domain filter message
482      */
483     public String getDomainFilterMessage() {
484         return domainFilterMessage;
485     }
486
487     /**
488      * Sets Domain filter message
489      *
490      * @param domainFilterMessage domain filter message
491      */
492     public void setDomainFilterMessage(String domainFilterMessage) {
493         this.domainFilterMessage = domainFilterMessage;
494     }
495
496     public String getEventNameFilterStatus() {
497         return eventNameFilterStatus;
498     }
499
500     /**
501      * Provides {@link TCACEFPolicyEventNameFilter} status
502      *
503      * @param eventNameFilterStatus functional Role filter status
504      */
505     public void setEventNameFilterStatus(String eventNameFilterStatus) {
506         this.eventNameFilterStatus = eventNameFilterStatus;
507     }
508
509     /**
510      * Provides {@link TCACEFPolicyEventNameFilter} message
511      *
512      * @return functional role filter message
513      */
514     public String getEventNameFilterMessage() {
515         return eventNameFilterMessage;
516     }
517
518     /**
519      * Sets Functional Role filter message
520      *
521      * @param eventNameFilterMessage functional role filter message
522      */
523     public void setEventNameFilterMessage(String eventNameFilterMessage) {
524         this.eventNameFilterMessage = eventNameFilterMessage;
525     }
526
527     /**
528      * Provides {@link TCACEFPolicyThresholdsProcessor} status
529      *
530      * @return threshold processor status
531      */
532     public String getThresholdCalculatorStatus() {
533         return thresholdCalculatorStatus;
534     }
535
536     /**
537      * Sets threshold calculator status
538      *
539      * @param thresholdCalculatorStatus threshold calculator status
540      */
541     public void setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
542         this.thresholdCalculatorStatus = thresholdCalculatorStatus;
543     }
544
545     /**
546      * Provides {@link TCACEFPolicyThresholdsProcessor} message
547      *
548      * @return threshold processor message
549      */
550     public String getThresholdCalculatorMessage() {
551         return thresholdCalculatorMessage;
552     }
553
554     /**
555      * Sets Threshold Calculator Processor Message
556      *
557      * @param thresholdCalculatorMessage threshold calculator message
558      */
559     public void setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
560         this.thresholdCalculatorMessage = thresholdCalculatorMessage;
561     }
562
563     /**
564      * Provides generated alert message
565      *
566      * @return generated alert message
567      */
568     public String getAlertMessage() {
569         return alertMessage;
570     }
571
572     /**
573      * Sets alert message
574      *
575      * @param alertMessage alert message
576      */
577     public void setAlertMessage(String alertMessage) {
578         this.alertMessage = alertMessage;
579     }
580
581     /**
582      * Write entity to Table
583      *
584      * @param dataOutput data output
585      *
586      * @throws IOException io exception
587      */
588     @Override
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);
594
595         WritableUtils.writeString(dataOutput, domain);
596         WritableUtils.writeString(dataOutput, eventName);
597
598         WritableUtils.writeString(dataOutput, thresholdPath);
599         WritableUtils.writeString(dataOutput, thresholdSeverity);
600         WritableUtils.writeString(dataOutput, thresholdDirection);
601         WritableUtils.writeVLong(dataOutput, thresholdValue);
602
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);
611
612         WritableUtils.writeString(dataOutput, alertMessage);
613
614     }
615
616     /**
617      * Read entity from table
618      *
619      * @param dataInput data input
620      * @throws IOException io exception
621      */
622     @Override
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);
628
629         domain = WritableUtils.readString(dataInput);
630         eventName = WritableUtils.readString(dataInput);
631
632         thresholdPath = WritableUtils.readString(dataInput);
633         thresholdSeverity = WritableUtils.readString(dataInput);
634         thresholdDirection = WritableUtils.readString(dataInput);
635         thresholdValue = WritableUtils.readVLong(dataInput);
636
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);
645
646         alertMessage = WritableUtils.readString(dataInput);
647
648     }
649
650 }