Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-common / src / main / java / org / openecomp / dcae / apod / analytics / cdap / common / persistance / tca / TCAMessageStatusEntity.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.cdap.common.persistance.tca;\r
22 \r
23 import org.apache.hadoop.io.Writable;\r
24 import org.apache.hadoop.io.WritableUtils;\r
25 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Direction;\r
26 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;\r
27 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFJsonProcessor;\r
28 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyDomainFilter;\r
29 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyEventNameFilter;\r
30 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyThresholdsProcessor;\r
31 \r
32 import java.io.DataInput;\r
33 import java.io.DataOutput;\r
34 import java.io.IOException;\r
35 import java.io.Serializable;\r
36 \r
37 /**\r
38  * TCA Message Status is an Entity which is used to persist TCA VES Message status information in Message Status Table\r
39  *\r
40  * @author Rajiv Singla . Creation Date: 11/16/2016.\r
41  */\r
42 public class TCAMessageStatusEntity implements Writable, Serializable {\r
43 \r
44     private static final long serialVersionUID = 1L;\r
45 \r
46     private long creationTS;\r
47     private int instanceId;\r
48     private String messageType;\r
49     private String vesMessage;\r
50     private String domain;\r
51     private String eventName;\r
52     private String thresholdPath;\r
53     private String thresholdSeverity;\r
54     private String thresholdDirection;\r
55     private Long thresholdValue;\r
56     private String jsonProcessorStatus;\r
57     private String jsonProcessorMessage;\r
58     private String domainFilterStatus;\r
59     private String domainFilterMessage;\r
60     private String eventNameFilterStatus;\r
61     private String eventNameFilterMessage;\r
62     private String thresholdCalculatorStatus;\r
63     private String thresholdCalculatorMessage;\r
64     private String alertMessage;\r
65 \r
66     /**\r
67      * No Arg constructor required for Jackson Json Serialization / Deserialization\r
68      */\r
69     public TCAMessageStatusEntity() {\r
70         // no argument constructor required for json serialization / deserialization\r
71     }\r
72 \r
73     /**\r
74      * Create new Instance of {@link TCAMessageStatusEntity}\r
75      *\r
76      * @param creationTS creation Timestamp\r
77      * @param instanceId CDAP flowlet instance ID\r
78      * @param messageType {@link TCACalculatorMessageType}\r
79      * @param vesMessage incoming VES message from collector\r
80      * @param domain VES message domain if present\r
81      * @param eventName VES message functional role if present\r
82      */\r
83     public TCAMessageStatusEntity(final long creationTS, final int instanceId, final String messageType,\r
84                                   final String vesMessage, final String domain, final String eventName) {\r
85         this(creationTS, instanceId, messageType, vesMessage, domain, eventName, null, null, null, null,\r
86                 null, null, null, null, null, null, null, null, null);\r
87     }\r
88 \r
89 \r
90     /**\r
91      * Create new Instance of {@link TCAMessageStatusEntity}\r
92      *\r
93      * @param creationTS creation Timestamp\r
94      * @param instanceId CDAP flowlet instance ID\r
95      * @param messageType {@link TCACalculatorMessageType}\r
96      * @param vesMessage incoming VES message from collector\r
97      * @param domain VES message domain if present\r
98      * @param eventName VES message event name if present\r
99      * @param thresholdPath Violated threshold path\r
100      * @param thresholdSeverity Violated threshold Severity if any\r
101      * @param thresholdDirection Violated threshold Direction if any\r
102      * @param thresholdValue Violated threshold value if any\r
103      * @param jsonProcessorStatus {@link TCACEFJsonProcessor} status\r
104      * @param jsonProcessorMessage {@link TCACEFJsonProcessor} message\r
105      * @param domainFilterStatus {@link TCACEFPolicyDomainFilter} status\r
106      * @param domainFilterMessage {@link TCACEFPolicyDomainFilter} message\r
107      * @param eventNameFilterStatus {@link TCACEFPolicyEventNameFilter} status\r
108      * @param eventNameFilterMessage {@link TCACEFPolicyEventNameFilter} message\r
109      * @param thresholdCalculatorStatus {@link TCACEFPolicyThresholdsProcessor} status\r
110      * @param thresholdCalculatorMessage {@link TCACEFPolicyThresholdsProcessor} message\r
111      * @param alertMessage alert message that will be sent out in case of threshold violation\r
112      */\r
113     public TCAMessageStatusEntity(long creationTS, int instanceId, String messageType, String vesMessage,\r
114                                   String domain, String eventName,\r
115                                   String thresholdPath, String thresholdSeverity, String thresholdDirection,\r
116                                   Long thresholdValue,\r
117                                   String jsonProcessorStatus, String jsonProcessorMessage,\r
118                                   String domainFilterStatus, String domainFilterMessage,\r
119                                   String eventNameFilterStatus, String eventNameFilterMessage,\r
120                                   String thresholdCalculatorStatus, String thresholdCalculatorMessage,\r
121                                   String alertMessage) {\r
122         this.creationTS = creationTS;\r
123         this.instanceId = instanceId;\r
124         this.messageType = messageType;\r
125         this.vesMessage = vesMessage;\r
126         this.domain = domain;\r
127         this.eventName = eventName;\r
128         this.thresholdPath = thresholdPath;\r
129         this.thresholdSeverity = thresholdSeverity;\r
130         this.thresholdDirection = thresholdDirection;\r
131         this.thresholdValue = thresholdValue;\r
132         this.jsonProcessorStatus = jsonProcessorStatus;\r
133         this.jsonProcessorMessage = jsonProcessorMessage;\r
134         this.domainFilterStatus = domainFilterStatus;\r
135         this.domainFilterMessage = domainFilterMessage;\r
136         this.eventNameFilterStatus = eventNameFilterStatus;\r
137         this.eventNameFilterMessage = eventNameFilterMessage;\r
138         this.thresholdCalculatorStatus = thresholdCalculatorStatus;\r
139         this.thresholdCalculatorMessage = thresholdCalculatorMessage;\r
140         this.alertMessage = alertMessage;\r
141     }\r
142 \r
143     /**\r
144      * Provides Creation Timestamp\r
145      *\r
146      * @return creation timestamp long value\r
147      */\r
148     public long getCreationTS() {\r
149         return creationTS;\r
150     }\r
151 \r
152     /**\r
153      * Sets Creations Timestamp\r
154      *\r
155      * @param creationTS creation timestamp long value\r
156      */\r
157     public void setCreationTS(long creationTS) {\r
158         this.creationTS = creationTS;\r
159     }\r
160 \r
161 \r
162     /**\r
163      * Provides CDAP Flowlet instance ID\r
164      *\r
165      * @return cdap flowlet instance ID\r
166      */\r
167     public int getInstanceId() {\r
168         return instanceId;\r
169     }\r
170 \r
171     /**\r
172      * Sets CDAP Flowlet instance ID\r
173      *\r
174      * @param instanceId flowlet instance ID\r
175      */\r
176     public void setInstanceId(int instanceId) {\r
177         this.instanceId = instanceId;\r
178     }\r
179 \r
180     /**\r
181      * Provides Message Calculator Type {@link TCACalculatorMessageType}\r
182      *\r
183      * @return calculator message type\r
184      */\r
185     public String getMessageType() {\r
186         return messageType;\r
187     }\r
188 \r
189     /**\r
190      * Sets Calculator message Type {@link TCACalculatorMessageType}\r
191      *\r
192      * @param messageType calculator message type\r
193      */\r
194     public void setMessageType(String messageType) {\r
195         this.messageType = messageType;\r
196     }\r
197 \r
198     /**\r
199      * Provides incoming VES Message\r
200      *\r
201      * @return ves message\r
202      */\r
203     public String getVesMessage() {\r
204         return vesMessage;\r
205     }\r
206 \r
207     /**\r
208      * Set new value for VES message\r
209      *\r
210      * @param vesMessage ves message\r
211      */\r
212     public void setVesMessage(String vesMessage) {\r
213         this.vesMessage = vesMessage;\r
214     }\r
215 \r
216     /**\r
217      * Provides VES message Domain\r
218      *\r
219      * @return ves message domain\r
220      */\r
221     public String getDomain() {\r
222         return domain;\r
223     }\r
224 \r
225     /**\r
226      * Sets VES Message Domain\r
227      *\r
228      * @param domain ves message domain\r
229      */\r
230     public void setDomain(String domain) {\r
231         this.domain = domain;\r
232     }\r
233 \r
234     /**\r
235      * Provides VES Message Event Name\r
236      *\r
237      * @return ves message Event Name\r
238      */\r
239     public String getEventName() {\r
240         return eventName;\r
241     }\r
242 \r
243     /**\r
244      * Sets VES Message Functional Role\r
245      *\r
246      * @param eventName ves message Functional Role\r
247      */\r
248     public void setEventName(String eventName) {\r
249         this.eventName = eventName;\r
250     }\r
251 \r
252     /**\r
253      * Violated Threshold Path as extracted from {@link TCAPolicy}\r
254      *\r
255      * @return violated threshold path\r
256      */\r
257     public String getThresholdPath() {\r
258         return thresholdPath;\r
259     }\r
260 \r
261     /**\r
262      * Sets value for Violated Threshold Path\r
263      *\r
264      * @param thresholdPath violated threshold path\r
265      */\r
266     public void setThresholdPath(String thresholdPath) {\r
267         this.thresholdPath = thresholdPath;\r
268     }\r
269 \r
270     /**\r
271      * Violated threshold Event Severity\r
272      *\r
273      * @return event severity\r
274      */\r
275     public String getThresholdSeverity() {\r
276         return thresholdSeverity;\r
277     }\r
278 \r
279     /**\r
280      * Violated Threshold Severity\r
281      *\r
282      * @param thresholdSeverity violated threshold severity\r
283      */\r
284     public void setThresholdSeverity(String thresholdSeverity) {\r
285         this.thresholdSeverity = thresholdSeverity;\r
286     }\r
287 \r
288     /**\r
289      * Violated Threshold {@link Direction}\r
290      *\r
291      * @return violated threshold Direction\r
292      */\r
293     public String getThresholdDirection() {\r
294         return thresholdDirection;\r
295     }\r
296 \r
297     /**\r
298      * Sets Violated Threshold Direction\r
299      *\r
300      * @param thresholdDirection violated threshold direction\r
301      */\r
302     public void setThresholdDirection(String thresholdDirection) {\r
303         this.thresholdDirection = thresholdDirection;\r
304     }\r
305 \r
306     /**\r
307      * Provides Violated Threshold Value\r
308      *\r
309      * @return violated Threshold value\r
310      */\r
311     public Long getThresholdValue() {\r
312         return thresholdValue;\r
313     }\r
314 \r
315     /**\r
316      * Sets Violated Threshold Value\r
317      *\r
318      * @param thresholdValue violated threshold value\r
319      */\r
320     public void setThresholdValue(Long thresholdValue) {\r
321         this.thresholdValue = thresholdValue;\r
322     }\r
323 \r
324     /**\r
325      * Provides {@link TCACEFJsonProcessor} status\r
326      *\r
327      * @return json processor status\r
328      */\r
329     public String getJsonProcessorStatus() {\r
330         return jsonProcessorStatus;\r
331     }\r
332 \r
333     /**\r
334      * Sets Json Processor status\r
335      *\r
336      * @param jsonProcessorStatus json processor status\r
337      */\r
338     public void setJsonProcessorStatus(String jsonProcessorStatus) {\r
339         this.jsonProcessorStatus = jsonProcessorStatus;\r
340     }\r
341 \r
342     /**\r
343      * Provides {@link TCACEFJsonProcessor} message\r
344      *\r
345      * @return json processor message\r
346      */\r
347     public String getJsonProcessorMessage() {\r
348         return jsonProcessorMessage;\r
349     }\r
350 \r
351     /**\r
352      * Sets Json Processor Message\r
353      *\r
354      * @param jsonProcessorMessage json processor message\r
355      */\r
356     public void setJsonProcessorMessage(String jsonProcessorMessage) {\r
357         this.jsonProcessorMessage = jsonProcessorMessage;\r
358     }\r
359 \r
360     /**\r
361      * Provides {@link TCACEFPolicyDomainFilter} status\r
362      *\r
363      * @return domain filter status\r
364      */\r
365     public String getDomainFilterStatus() {\r
366         return domainFilterStatus;\r
367     }\r
368 \r
369     /**\r
370      * Sets Domain Filter status\r
371      *\r
372      * @param domainFilterStatus domain filter status\r
373      */\r
374     public void setDomainFilterStatus(String domainFilterStatus) {\r
375         this.domainFilterStatus = domainFilterStatus;\r
376     }\r
377 \r
378     /**\r
379      * Provides {@link TCACEFPolicyDomainFilter} message\r
380      *\r
381      * @return domain filter message\r
382      */\r
383     public String getDomainFilterMessage() {\r
384         return domainFilterMessage;\r
385     }\r
386 \r
387     /**\r
388      * Sets Domain filter message\r
389      *\r
390      * @param domainFilterMessage domain filter message\r
391      */\r
392     public void setDomainFilterMessage(String domainFilterMessage) {\r
393         this.domainFilterMessage = domainFilterMessage;\r
394     }\r
395 \r
396     public String getEventNameFilterStatus() {\r
397         return eventNameFilterStatus;\r
398     }\r
399 \r
400     /**\r
401      * Provides {@link TCACEFPolicyEventNameFilter} status\r
402      *\r
403      * @param eventNameFilterStatus functional Role filter status\r
404      */\r
405     public void setEventNameFilterStatus(String eventNameFilterStatus) {\r
406         this.eventNameFilterStatus = eventNameFilterStatus;\r
407     }\r
408 \r
409     /**\r
410      * Provides {@link TCACEFPolicyEventNameFilter} message\r
411      *\r
412      * @return functional role filter message\r
413      */\r
414     public String getEventNameFilterMessage() {\r
415         return eventNameFilterMessage;\r
416     }\r
417 \r
418     /**\r
419      * Sets Functional Role filter message\r
420      *\r
421      * @param eventNameFilterMessage functional role filter message\r
422      */\r
423     public void setEventNameFilterMessage(String eventNameFilterMessage) {\r
424         this.eventNameFilterMessage = eventNameFilterMessage;\r
425     }\r
426 \r
427     /**\r
428      * Provides {@link TCACEFPolicyThresholdsProcessor} status\r
429      *\r
430      * @return threshold processor status\r
431      */\r
432     public String getThresholdCalculatorStatus() {\r
433         return thresholdCalculatorStatus;\r
434     }\r
435 \r
436     /**\r
437      * Sets threshold calculator status\r
438      *\r
439      * @param thresholdCalculatorStatus threshold calculator status\r
440      */\r
441     public void setThresholdCalculatorStatus(String thresholdCalculatorStatus) {\r
442         this.thresholdCalculatorStatus = thresholdCalculatorStatus;\r
443     }\r
444 \r
445     /**\r
446      * Provides {@link TCACEFPolicyThresholdsProcessor} message\r
447      *\r
448      * @return threshold processor message\r
449      */\r
450     public String getThresholdCalculatorMessage() {\r
451         return thresholdCalculatorMessage;\r
452     }\r
453 \r
454     /**\r
455      * Sets Threshold Calculator Processor Message\r
456      *\r
457      * @param thresholdCalculatorMessage threshold calculator message\r
458      */\r
459     public void setThresholdCalculatorMessage(String thresholdCalculatorMessage) {\r
460         this.thresholdCalculatorMessage = thresholdCalculatorMessage;\r
461     }\r
462 \r
463     /**\r
464      * Provides generated alert message\r
465      *\r
466      * @return generated alert message\r
467      */\r
468     public String getAlertMessage() {\r
469         return alertMessage;\r
470     }\r
471 \r
472     /**\r
473      * Sets alert message\r
474      *\r
475      * @param alertMessage alert message\r
476      */\r
477     public void setAlertMessage(String alertMessage) {\r
478         this.alertMessage = alertMessage;\r
479     }\r
480 \r
481     /**\r
482      * Write entity to Table\r
483      *\r
484      * @param dataOutput data output\r
485      *\r
486      * @throws IOException io exception\r
487      */\r
488     @Override\r
489     public void write(DataOutput dataOutput) throws IOException {\r
490         WritableUtils.writeVLong(dataOutput, creationTS);\r
491         WritableUtils.writeVInt(dataOutput, instanceId);\r
492         WritableUtils.writeString(dataOutput, messageType);\r
493         WritableUtils.writeString(dataOutput, vesMessage);\r
494 \r
495         WritableUtils.writeString(dataOutput, domain);\r
496         WritableUtils.writeString(dataOutput, eventName);\r
497 \r
498         WritableUtils.writeString(dataOutput, thresholdPath);\r
499         WritableUtils.writeString(dataOutput, thresholdSeverity);\r
500         WritableUtils.writeString(dataOutput, thresholdDirection);\r
501         WritableUtils.writeVLong(dataOutput, thresholdValue);\r
502 \r
503         WritableUtils.writeString(dataOutput, jsonProcessorStatus);\r
504         WritableUtils.writeString(dataOutput, jsonProcessorMessage);\r
505         WritableUtils.writeString(dataOutput, domainFilterStatus);\r
506         WritableUtils.writeString(dataOutput, domainFilterMessage);\r
507         WritableUtils.writeString(dataOutput, eventNameFilterStatus);\r
508         WritableUtils.writeString(dataOutput, eventNameFilterMessage);\r
509         WritableUtils.writeString(dataOutput, thresholdCalculatorStatus);\r
510         WritableUtils.writeString(dataOutput, thresholdCalculatorMessage);\r
511 \r
512         WritableUtils.writeString(dataOutput, alertMessage);\r
513 \r
514     }\r
515 \r
516     /**\r
517      * Read entity from table\r
518      *\r
519      * @param dataInput data input\r
520      * @throws IOException io exception\r
521      */\r
522     @Override\r
523     public void readFields(DataInput dataInput) throws IOException {\r
524         creationTS = WritableUtils.readVLong(dataInput);\r
525         instanceId = WritableUtils.readVInt(dataInput);\r
526         messageType = WritableUtils.readString(dataInput);\r
527         vesMessage = WritableUtils.readString(dataInput);\r
528 \r
529         domain = WritableUtils.readString(dataInput);\r
530         eventName = WritableUtils.readString(dataInput);\r
531 \r
532         thresholdPath = WritableUtils.readString(dataInput);\r
533         thresholdSeverity = WritableUtils.readString(dataInput);\r
534         thresholdDirection = WritableUtils.readString(dataInput);\r
535         thresholdValue = WritableUtils.readVLong(dataInput);\r
536 \r
537         jsonProcessorStatus = WritableUtils.readString(dataInput);\r
538         jsonProcessorMessage = WritableUtils.readString(dataInput);\r
539         domainFilterStatus = WritableUtils.readString(dataInput);\r
540         domainFilterMessage = WritableUtils.readString(dataInput);\r
541         eventNameFilterStatus = WritableUtils.readString(dataInput);\r
542         eventNameFilterMessage = WritableUtils.readString(dataInput);\r
543         thresholdCalculatorStatus = WritableUtils.readString(dataInput);\r
544         thresholdCalculatorMessage = WritableUtils.readString(dataInput);\r
545 \r
546         alertMessage = WritableUtils.readString(dataInput);\r
547 \r
548     }\r
549 \r
550 }\r