Initial TCA commit into DCAEGEN2
[dcaegen2/analytics/tca.git] / dcae-analytics-cdap-common / src / main / java / org / openecomp / 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.openecomp.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.openecomp.dcae.apod.analytics.model.domain.cef.EventSeverity;
26 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.Direction;
27 import org.openecomp.dcae.apod.analytics.model.domain.policy.tca.TCAPolicy;
28 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFJsonProcessor;
29 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyDomainFilter;
30 import org.openecomp.dcae.apod.analytics.tca.processor.TCACEFPolicyFunctionalRoleFilter;
31 import org.openecomp.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 functionalRole;
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 functionalRoleFilterStatus;
62     private String functionalRoleFilterMessage;
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 functionalRole 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 functionalRole) {
86         this(creationTS, instanceId, messageType, vesMessage, domain, functionalRole, null, null, null, null,
87                 null, null, null, null, null, null, null, null, null);
88     }
89
90
91     /**
92      * Create new Instance of {@link TCAMessageStatusEntity}
93      *
94      * @param creationTS creation Timestamp
95      * @param instanceId CDAP flowlet instance ID
96      * @param messageType {@link TCACalculatorMessageType}
97      * @param vesMessage incoming VES message from collector
98      * @param domain VES message domain if present
99      * @param functionalRole VES message functional role if present
100      * @param thresholdPath Violated threshold path
101      * @param thresholdSeverity Violated threshold Severity if any
102      * @param thresholdDirection Violated threshold Direction if any
103      * @param thresholdValue Violated threshold value if any
104      * @param jsonProcessorStatus {@link TCACEFJsonProcessor} status
105      * @param jsonProcessorMessage {@link TCACEFJsonProcessor} message
106      * @param domainFilterStatus {@link TCACEFPolicyDomainFilter} status
107      * @param domainFilterMessage {@link TCACEFPolicyDomainFilter} message
108      * @param functionalRoleFilterStatus
109      * {@link TCACEFPolicyFunctionalRoleFilter} status
110      * @param functionalRoleFilterMessage
111      * {@link TCACEFPolicyFunctionalRoleFilter} message
112      * @param thresholdCalculatorStatus
113      * {@link TCACEFPolicyThresholdsProcessor} status
114      * @param thresholdCalculatorMessage
115      * {@link TCACEFPolicyThresholdsProcessor} message
116      * @param alertMessage alert message that will be sent out in case of threshold violation
117      */
118     public TCAMessageStatusEntity(long creationTS, int instanceId, String messageType, String vesMessage,
119                                   String domain, String functionalRole,
120                                   String thresholdPath, String thresholdSeverity, String thresholdDirection,
121                                   Long thresholdValue,
122                                   String jsonProcessorStatus, String jsonProcessorMessage,
123                                   String domainFilterStatus, String domainFilterMessage,
124                                   String functionalRoleFilterStatus, String functionalRoleFilterMessage,
125                                   String thresholdCalculatorStatus, String thresholdCalculatorMessage,
126                                   String alertMessage) {
127         this.creationTS = creationTS;
128         this.instanceId = instanceId;
129         this.messageType = messageType;
130         this.vesMessage = vesMessage;
131         this.domain = domain;
132         this.functionalRole = functionalRole;
133         this.thresholdPath = thresholdPath;
134         this.thresholdSeverity = thresholdSeverity;
135         this.thresholdDirection = thresholdDirection;
136         this.thresholdValue = thresholdValue;
137         this.jsonProcessorStatus = jsonProcessorStatus;
138         this.jsonProcessorMessage = jsonProcessorMessage;
139         this.domainFilterStatus = domainFilterStatus;
140         this.domainFilterMessage = domainFilterMessage;
141         this.functionalRoleFilterStatus = functionalRoleFilterStatus;
142         this.functionalRoleFilterMessage = functionalRoleFilterMessage;
143         this.thresholdCalculatorStatus = thresholdCalculatorStatus;
144         this.thresholdCalculatorMessage = thresholdCalculatorMessage;
145         this.alertMessage = alertMessage;
146     }
147
148     /**
149      * Provides Creation Timestamp
150      *
151      * @return creation timestamp long value
152      */
153     public long getCreationTS() {
154         return creationTS;
155     }
156
157     /**
158      * Sets Creations Timestamp
159      *
160      * @param creationTS creation timestamp long value
161      */
162     public void setCreationTS(long creationTS) {
163         this.creationTS = creationTS;
164     }
165
166
167     /**
168      * Provides CDAP Flowlet instance ID
169      *
170      * @return cdap flowlet instance ID
171      */
172     public int getInstanceId() {
173         return instanceId;
174     }
175
176     /**
177      * Sets CDAP Flowlet instance ID
178      *
179      * @param instanceId flowlet instance ID
180      */
181     public void setInstanceId(int instanceId) {
182         this.instanceId = instanceId;
183     }
184
185     /**
186      * Provides Message Calculator Type {@link TCACalculatorMessageType}
187      *
188      * @return calculator message type
189      */
190     public String getMessageType() {
191         return messageType;
192     }
193
194     /**
195      * Sets Calculator message Type {@link TCACalculatorMessageType}
196      *
197      * @param messageType calculator message type
198      */
199     public void setMessageType(String messageType) {
200         this.messageType = messageType;
201     }
202
203     /**
204      * Provides incoming VES Message
205      *
206      * @return ves message
207      */
208     public String getVesMessage() {
209         return vesMessage;
210     }
211
212     /**
213      * Set new value for VES message
214      *
215      * @param vesMessage ves message
216      */
217     public void setVesMessage(String vesMessage) {
218         this.vesMessage = vesMessage;
219     }
220
221     /**
222      * Provides VES message Domain
223      *
224      * @return ves message domain
225      */
226     public String getDomain() {
227         return domain;
228     }
229
230     /**
231      * Sets VES Message Domain
232      *
233      * @param domain ves message domain
234      */
235     public void setDomain(String domain) {
236         this.domain = domain;
237     }
238
239     /**
240      * Provides VES Message Functional Role
241      *
242      * @return ves message functional role
243      */
244     public String getFunctionalRole() {
245         return functionalRole;
246     }
247
248     /**
249      * Sets VES Message Functional Role
250      *
251      * @param functionalRole ves message Functional Role
252      */
253     public void setFunctionalRole(String functionalRole) {
254         this.functionalRole = functionalRole;
255     }
256
257     /**
258      * Violated Threshold Path as extracted from {@link TCAPolicy}
259      *
260      * @return violated threshold path
261      */
262     public String getThresholdPath() {
263         return thresholdPath;
264     }
265
266     /**
267      * Sets value for Violated Threshold Path
268      *
269      * @param thresholdPath violated threshold path
270      */
271     public void setThresholdPath(String thresholdPath) {
272         this.thresholdPath = thresholdPath;
273     }
274
275     /**
276      * Violated threshold {@link EventSeverity}
277      *
278      * @return event severity
279      */
280     public String getThresholdSeverity() {
281         return thresholdSeverity;
282     }
283
284     /**
285      * Violated Threshold Severity
286      *
287      * @param thresholdSeverity violated threshold severity
288      */
289     public void setThresholdSeverity(String thresholdSeverity) {
290         this.thresholdSeverity = thresholdSeverity;
291     }
292
293     /**
294      * Violated Threshold {@link Direction}
295      *
296      * @return violated threshold Direction
297      */
298     public String getThresholdDirection() {
299         return thresholdDirection;
300     }
301
302     /**
303      * Sets Violated Threshold Direction
304      *
305      * @param thresholdDirection violated threshold direction
306      */
307     public void setThresholdDirection(String thresholdDirection) {
308         this.thresholdDirection = thresholdDirection;
309     }
310
311     /**
312      * Provides Violated Threshold Value
313      *
314      * @return violated Threshold value
315      */
316     public Long getThresholdValue() {
317         return thresholdValue;
318     }
319
320     /**
321      * Sets Violated Threshold Value
322      *
323      * @param thresholdValue violated threshold value
324      */
325     public void setThresholdValue(Long thresholdValue) {
326         this.thresholdValue = thresholdValue;
327     }
328
329     /**
330      * Provides {@link TCACEFJsonProcessor} status
331      *
332      * @return json processor status
333      */
334     public String getJsonProcessorStatus() {
335         return jsonProcessorStatus;
336     }
337
338     /**
339      * Sets Json Processor status
340      *
341      * @param jsonProcessorStatus json processor status
342      */
343     public void setJsonProcessorStatus(String jsonProcessorStatus) {
344         this.jsonProcessorStatus = jsonProcessorStatus;
345     }
346
347     /**
348      * Provides {@link TCACEFJsonProcessor} message
349      *
350      * @return json processor message
351      */
352     public String getJsonProcessorMessage() {
353         return jsonProcessorMessage;
354     }
355
356     /**
357      * Sets Json Processor Message
358      *
359      * @param jsonProcessorMessage json processor message
360      */
361     public void setJsonProcessorMessage(String jsonProcessorMessage) {
362         this.jsonProcessorMessage = jsonProcessorMessage;
363     }
364
365     /**
366      * Provides {@link TCACEFPolicyDomainFilter} status
367      *
368      * @return domain filter status
369      */
370     public String getDomainFilterStatus() {
371         return domainFilterStatus;
372     }
373
374     /**
375      * Sets Domain Filter status
376      *
377      * @param domainFilterStatus domain filter status
378      */
379     public void setDomainFilterStatus(String domainFilterStatus) {
380         this.domainFilterStatus = domainFilterStatus;
381     }
382
383     /**
384      * Provides {@link TCACEFPolicyDomainFilter} message
385      *
386      * @return domain filter message
387      */
388     public String getDomainFilterMessage() {
389         return domainFilterMessage;
390     }
391
392     /**
393      * Sets Domain filter message
394      *
395      * @param domainFilterMessage domain filter message
396      */
397     public void setDomainFilterMessage(String domainFilterMessage) {
398         this.domainFilterMessage = domainFilterMessage;
399     }
400
401     public String getFunctionalRoleFilterStatus() {
402         return functionalRoleFilterStatus;
403     }
404
405     /**
406      * Provides {@link TCACEFPolicyFunctionalRoleFilter} status
407      *
408      * @param functionalRoleFilterStatus functional Role filter status
409      */
410     public void setFunctionalRoleFilterStatus(String functionalRoleFilterStatus) {
411         this.functionalRoleFilterStatus = functionalRoleFilterStatus;
412     }
413
414     /**
415      * Provides {@link TCACEFPolicyFunctionalRoleFilter} message
416      *
417      * @return functional role filter message
418      */
419     public String getFunctionalRoleFilterMessage() {
420         return functionalRoleFilterMessage;
421     }
422
423     /**
424      * Sets Functional Role filter message
425      *
426      * @param functionalRoleFilterMessage functional role filter message
427      */
428     public void setFunctionalRoleFilterMessage(String functionalRoleFilterMessage) {
429         this.functionalRoleFilterMessage = functionalRoleFilterMessage;
430     }
431
432     /**
433      * Provides {@link TCACEFPolicyThresholdsProcessor} status
434      *
435      * @return threshold processor status
436      */
437     public String getThresholdCalculatorStatus() {
438         return thresholdCalculatorStatus;
439     }
440
441     /**
442      * Sets threshold calculator status
443      *
444      * @param thresholdCalculatorStatus threshold calculator status
445      */
446     public void setThresholdCalculatorStatus(String thresholdCalculatorStatus) {
447         this.thresholdCalculatorStatus = thresholdCalculatorStatus;
448     }
449
450     /**
451      * Provides {@link TCACEFPolicyThresholdsProcessor} message
452      *
453      * @return threshold processor message
454      */
455     public String getThresholdCalculatorMessage() {
456         return thresholdCalculatorMessage;
457     }
458
459     /**
460      * Sets Threshold Calculator Processor Message
461      *
462      * @param thresholdCalculatorMessage threshold calculator message
463      */
464     public void setThresholdCalculatorMessage(String thresholdCalculatorMessage) {
465         this.thresholdCalculatorMessage = thresholdCalculatorMessage;
466     }
467
468     /**
469      * Provides generated alert message
470      *
471      * @return generated alert message
472      */
473     public String getAlertMessage() {
474         return alertMessage;
475     }
476
477     /**
478      * Sets alert message
479      *
480      * @param alertMessage alert message
481      */
482     public void setAlertMessage(String alertMessage) {
483         this.alertMessage = alertMessage;
484     }
485
486     /**
487      * Write entity to Table
488      *
489      * @param dataOutput data output
490      *
491      * @throws IOException io exception
492      */
493     @Override
494     public void write(DataOutput dataOutput) throws IOException {
495         WritableUtils.writeVLong(dataOutput, creationTS);
496         WritableUtils.writeVInt(dataOutput, instanceId);
497         WritableUtils.writeString(dataOutput, messageType);
498         WritableUtils.writeString(dataOutput, vesMessage);
499
500         WritableUtils.writeString(dataOutput, domain);
501         WritableUtils.writeString(dataOutput, functionalRole);
502
503         WritableUtils.writeString(dataOutput, thresholdPath);
504         WritableUtils.writeString(dataOutput, thresholdSeverity);
505         WritableUtils.writeString(dataOutput, thresholdDirection);
506         WritableUtils.writeVLong(dataOutput, thresholdValue);
507
508         WritableUtils.writeString(dataOutput, jsonProcessorStatus);
509         WritableUtils.writeString(dataOutput, jsonProcessorMessage);
510         WritableUtils.writeString(dataOutput, domainFilterStatus);
511         WritableUtils.writeString(dataOutput, domainFilterMessage);
512         WritableUtils.writeString(dataOutput, functionalRoleFilterStatus);
513         WritableUtils.writeString(dataOutput, functionalRoleFilterMessage);
514         WritableUtils.writeString(dataOutput, thresholdCalculatorStatus);
515         WritableUtils.writeString(dataOutput, thresholdCalculatorMessage);
516
517         WritableUtils.writeString(dataOutput, alertMessage);
518
519     }
520
521     /**
522      * Read entity from table
523      *
524      * @param dataInput data input
525      * @throws IOException io exception
526      */
527     @Override
528     public void readFields(DataInput dataInput) throws IOException {
529         creationTS = WritableUtils.readVLong(dataInput);
530         instanceId = WritableUtils.readVInt(dataInput);
531         messageType = WritableUtils.readString(dataInput);
532         vesMessage = WritableUtils.readString(dataInput);
533
534         domain = WritableUtils.readString(dataInput);
535         functionalRole = WritableUtils.readString(dataInput);
536
537         thresholdPath = WritableUtils.readString(dataInput);
538         thresholdSeverity = WritableUtils.readString(dataInput);
539         thresholdDirection = WritableUtils.readString(dataInput);
540         thresholdValue = WritableUtils.readVLong(dataInput);
541
542         jsonProcessorStatus = WritableUtils.readString(dataInput);
543         jsonProcessorMessage = WritableUtils.readString(dataInput);
544         domainFilterStatus = WritableUtils.readString(dataInput);
545         domainFilterMessage = WritableUtils.readString(dataInput);
546         functionalRoleFilterStatus = WritableUtils.readString(dataInput);
547         functionalRoleFilterMessage = WritableUtils.readString(dataInput);
548         thresholdCalculatorStatus = WritableUtils.readString(dataInput);
549         thresholdCalculatorMessage = WritableUtils.readString(dataInput);
550
551         alertMessage = WritableUtils.readString(dataInput);
552
553     }
554
555 }