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