This project has retired. For details please refer to its
Attic page.
001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.oozie.client.event.message;
019
020 import java.util.Date;
021
022 import javax.jms.JMSException;
023 import javax.jms.Message;
024
025 import org.apache.oozie.AppType;
026 import org.apache.oozie.client.event.Event.MessageType;
027 import org.apache.oozie.client.event.SLAEvent;
028 import org.apache.oozie.client.event.jms.JMSHeaderConstants;
029 import org.apache.oozie.client.event.message.EventMessage;
030 import org.codehaus.jackson.annotate.JsonIgnore;
031 import org.codehaus.jackson.annotate.JsonProperty;
032 import org.codehaus.jackson.map.annotate.JsonSerialize;
033
034 @JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
035 public class SLAMessage extends EventMessage {
036
037 @JsonProperty
038 private String id;
039 @JsonProperty
040 private String parentId;
041 @JsonProperty
042 private Date nominalTime;
043 @JsonProperty
044 private Date expectedStartTime;
045 @JsonProperty
046 private Date actualStartTime;
047 @JsonProperty
048 private Date expectedEndTime;
049 @JsonProperty
050 private Date actualEndTime;
051 @JsonProperty
052 private long expectedDuration;
053 @JsonProperty
054 private long actualDuration;
055 @JsonProperty
056 private String notificationMessage;
057 @JsonProperty
058 private String upstreamApps;
059
060 private String user;
061 private String appName;
062 private SLAEvent.EventStatus eventStatus;
063 private SLAEvent.SLAStatus slaStatus;
064
065 public SLAMessage(){
066 // Dummy constructor for JSON
067 }
068
069 public SLAMessage(SLAEvent.EventStatus eventStatus, SLAEvent.SLAStatus slaStatus, AppType appType, String appName,
070 String user, String jobId, String parentJobId, Date nominalTime, Date expectedStartTime,
071 Date actualStartTime, Date expectedEndTime, Date actualEndTime, long expectedDuration, long actualDuration,
072 String notificationMessage, String upstreamApps) {
073
074 super(MessageType.SLA, appType);
075 this.eventStatus = eventStatus;
076 this.slaStatus = slaStatus;
077 this.appName = appName;
078 this.user = user;
079 this.id = jobId;
080 this.parentId = parentJobId;
081 this.nominalTime = nominalTime;
082 this.expectedStartTime = expectedStartTime;
083 this.actualStartTime = actualStartTime;
084 this.expectedEndTime = expectedEndTime;
085 this.actualEndTime = actualEndTime;
086 this.expectedDuration = expectedDuration;
087 this.actualDuration = actualDuration;
088 this.notificationMessage = notificationMessage;
089 this.upstreamApps = upstreamApps;
090 }
091
092 /**
093 * Get the job Id
094 *
095 * @return id the job id
096 */
097 public String getId() {
098 return id;
099 }
100
101 /**
102 * Set the job Id for message
103 *
104 * @param id the job id
105 */
106 public void setId(String id) {
107 this.id = id;
108 }
109
110 /**
111 * Gets the parent job id
112 *
113 * @return the parent job Id
114 */
115 public String getParentId() {
116 return parentId;
117 }
118
119 /**
120 * Set the parent job Id for message
121 *
122 * @param parentId the parent job Id
123 */
124 public void setParentId(String parentId) {
125 this.parentId = parentId;
126 }
127
128 /**
129 * Get nominal time
130 *
131 * @return nominal time
132 */
133 public Date getNominalTime() {
134 return nominalTime;
135 }
136
137 /**
138 * Set nominal time for message
139 *
140 * @param nominalTime
141 */
142 public void setNominalTime(Date nominalTime) {
143 this.nominalTime = nominalTime;
144 }
145
146 /**
147 * Get expected start time
148 *
149 * @return the expected start time
150 */
151 public Date getExpectedStartTime() {
152 return expectedStartTime;
153 }
154
155 /**
156 * Set expected start time for message
157 *
158 * @param expectedStartTime
159 */
160 public void setExpectedStartTime(Date expectedStartTime) {
161 this.expectedStartTime = expectedStartTime;
162 }
163
164 /**
165 * Get actual start time
166 *
167 * @return actual start time
168 */
169 public Date getActualStartTime() {
170 return actualStartTime;
171 }
172
173 /**
174 * Set actual start time for message
175 *
176 * @param actualStartTime
177 */
178 public void setActualStartTime(Date actualStartTime) {
179 this.actualStartTime = actualStartTime;
180 }
181
182 /**
183 * Get expected end time
184 *
185 * @return expectedEndTime
186 */
187 public Date getExpectedEndTime() {
188 return expectedEndTime;
189 }
190
191 /**
192 * Set expected end time for message
193 *
194 * @param expectedEndTime
195 */
196 public void setExpectedEndTime(Date expectedEndTime) {
197 this.expectedEndTime = expectedEndTime;
198 }
199
200 /**
201 * Get actual end time
202 *
203 * @return actual end time
204 */
205 public Date getActualEndTime() {
206 return actualEndTime;
207 }
208
209 /**
210 * Set actual end time for message
211 *
212 * @param actualEndTime
213 */
214 public void setActualEndTime(Date actualEndTime) {
215 this.actualEndTime = actualEndTime;
216 }
217
218 /**
219 * Get expected duration time (in milliseconds)
220 *
221 * @return expectedDuration (in milliseconds)
222 */
223 public long getExpectedDuration() {
224 return expectedDuration;
225 }
226
227 /**
228 * Set expected duration (in milliseconds) for message
229 *
230 * @param expectedDuration (in milliseconds)
231 */
232 public void setExpectedDuration(long expectedDuration) {
233 this.expectedDuration = expectedDuration;
234 }
235
236 /**
237 * Get actual duration (in milliseconds)
238 *
239 * @return actual duration (in milliseconds)
240 */
241 public long getActualDuration() {
242 return actualDuration;
243 }
244
245 /**
246 * Set actual duration (in milliseconds) for message
247 *
248 * @param actualDuration (in milliseconds)
249 */
250 public void setActualDuration(long actualDuration) {
251 this.actualDuration = actualDuration;
252 }
253
254 /**
255 * Get notification message
256 *
257 * @return notification message
258 */
259 public String getNotificationMessage() {
260 return notificationMessage;
261 }
262
263 /**
264 * Set notification message
265 *
266 * @param notificationMessage
267 */
268 public void setNotificationMessage(String notificationMessage) {
269 this.notificationMessage = notificationMessage;
270 }
271
272 /**
273 * Get upstream app names
274 *
275 * @return upstreamApps
276 */
277 public String getUpstreamApps() {
278 return upstreamApps;
279 }
280
281 /**
282 * Set upstream app names
283 *
284 * @param upstreamApps
285 */
286 public void setUpstreamApps(String upstreamApps) {
287 this.upstreamApps = upstreamApps;
288 }
289
290 /**
291 * Get user name
292 *
293 * @return user name
294 */
295 @JsonIgnore
296 public String getUser() {
297 return user;
298 }
299
300 /**
301 * Set user name for message
302 *
303 * @param user
304 */
305 public void setUser(String user) {
306 this.user = user;
307 }
308
309 /**
310 * Get application name
311 *
312 * @return application name
313 */
314 @JsonIgnore
315 public String getAppName() {
316 return appName;
317 }
318
319 /**
320 * Set application name for message
321 *
322 * @param appName
323 */
324 public void setAppName(String appName) {
325 this.appName = appName;
326 }
327
328 /**
329 * Get event status
330 *
331 * @return event status
332 */
333 @JsonIgnore
334 public SLAEvent.EventStatus getEventStatus() {
335 return eventStatus;
336 }
337
338 /**
339 * Set event status
340 *
341 * @param eventStatus
342 */
343 public void setEventStatus(SLAEvent.EventStatus eventStatus){
344 this.eventStatus = eventStatus;
345 }
346
347 /**
348 * Get SLA status
349 *
350 * @return sla status
351 */
352 @JsonIgnore
353 public SLAEvent.SLAStatus getSLAStatus() {
354 return slaStatus;
355 }
356
357 /**
358 * Set SLA status for message
359 *
360 * @param slaStatus
361 */
362 public void setSLAStatus(SLAEvent.SLAStatus slaStatus) {
363 this.slaStatus = slaStatus;
364 }
365
366 /**
367 * Set the JMS properties for SLA message
368 *
369 * @param message the JMS message
370 * @throws JMSException
371 */
372 @Override
373 @JsonIgnore
374 public void setProperties(Message message) throws JMSException {
375 super.setProperties(message);
376 setEventStatus(SLAEvent.EventStatus.valueOf(message.getStringProperty(JMSHeaderConstants.EVENT_STATUS)));
377 setSLAStatus(SLAEvent.SLAStatus.valueOf(message.getStringProperty(JMSHeaderConstants.SLA_STATUS)));
378 setAppName(message.getStringProperty(JMSHeaderConstants.APP_NAME));
379 setUser(message.getStringProperty(JMSHeaderConstants.USER));
380 }
381 }