2 * ===============================LICENSE_START======================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===========================================
21 package org.openecomp.dcae.apod.analytics.cdap.common.persistance.tca;
23 import com.google.common.base.Objects;
24 import org.apache.hadoop.io.Writable;
25 import org.apache.hadoop.io.WritableUtils;
27 import java.io.DataInput;
28 import java.io.DataOutput;
29 import java.io.IOException;
30 import java.io.Serializable;
33 * TCA Alerts Abatement Entity is used to persist information to determine if abatement event need to sent to downstream
36 * @author rs153v (Rajiv Singla) . Creation Date: 9/11/2017.
38 public class TCAAlertsAbatementEntity implements Writable, Serializable {
40 private static final long serialVersionUID = 1L;
42 private long creationTS;
43 private String requestId;
44 // Kept as string to avoid null checks
45 private String abatementSentTS;
48 * No Arg constructor required for Jackson Json Serialization / Deserialization
50 public TCAAlertsAbatementEntity() {
51 // required no arg constructor
55 * Creates TCA Alerts Abatement Entity to persist information to determine if abatement alerts need to be posted
57 * @param creationTS record creation time
58 * @param requestId request ID of generated alert
59 * @param abatementSentTS time when abatement was sent out for that alert if any
61 public TCAAlertsAbatementEntity(long creationTS, String requestId, String abatementSentTS) {
62 this.creationTS = creationTS;
63 this.requestId = requestId;
64 this.abatementSentTS = abatementSentTS;
68 * Timestamp when record was created
70 * @return timestamp when record was created
72 public long getCreationTS() {
77 * Set value for timestamp when record was created
79 * @param creationTS new value for timestamp when record was created
81 public void setCreationTS(long creationTS) {
82 this.creationTS = creationTS;
86 * Request Id of ONSET alert which was sent
88 * @return request Id of ONSET alert which was sent
90 public String getRequestId() {
95 * Set Request Id of ONSET alert
97 * @param requestId set new value for ONSET alert request id
99 public void setRequestId(String requestId) {
100 this.requestId = requestId;
105 * Get abatement Sent Timestamp
107 * @return get abatement alert sent timestamp
109 public String getAbatementSentTS() {
110 return abatementSentTS;
114 * Set timestamp when abatement alert is sent
116 * @param abatementSentTS sent new value for timestamp when abatement alert is sent
118 public void setAbatementSentTS(String abatementSentTS) {
119 this.abatementSentTS = abatementSentTS;
123 * Write entity to Table
125 * @param dataOutput data output
126 * @throws IOException io exception
129 public void write(DataOutput dataOutput) throws IOException {
130 WritableUtils.writeVLong(dataOutput, creationTS);
131 WritableUtils.writeString(dataOutput, requestId);
132 WritableUtils.writeString(dataOutput, abatementSentTS);
136 * Read entity from table
138 * @param dataInput data input
139 * @throws IOException io exception
142 public void readFields(DataInput dataInput) throws IOException {
143 creationTS = WritableUtils.readVLong(dataInput);
144 requestId = WritableUtils.readString(dataInput);
145 abatementSentTS = WritableUtils.readString(dataInput);
150 public String toString() {
151 return Objects.toStringHelper(this)
152 .add("creationTS", creationTS)
153 .add("requestId", requestId)
154 .add("abatementSentTS", abatementSentTS)