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 019package org.apache.oozie.client.event; 020 021import java.io.Serializable; 022import java.util.Date; 023 024import org.apache.oozie.AppType; 025 026/** 027 * An abstract implementation of the Event interface, related to 028 * notification events after job status changes 029 */ 030public abstract class JobEvent extends Event implements Serializable { 031 032 private static final long serialVersionUID = 1L; 033 034 /** 035 * Coarse-grained status of the job event 036 */ 037 public static enum EventStatus { 038 WAITING, STARTED, SUCCESS, SUSPEND, FAILURE 039 } 040 041 private String id; 042 private String parentId; 043 private String user; 044 private AppType appType; 045 private String appName; 046 private EventStatus eventStatus; 047 private Date startTime; 048 private Date endTime; 049 050 public JobEvent(String id, String parentId, String user, AppType appType, String appName) { 051 super(MessageType.JOB); 052 this.id = id; 053 this.parentId = parentId; 054 this.user = user; 055 this.appType = appType; 056 this.appName = appName; 057 } 058 059 public String getId() { 060 return id; 061 } 062 063 public void setId(String id) { 064 this.id = id; 065 } 066 067 public String getParentId() { 068 return parentId; 069 } 070 071 public void setParentId(String id) { 072 parentId = id; 073 } 074 075 /** 076 * Get the AppType of the event 077 * 078 * @return AppType 079 */ 080 public AppType getAppType() { 081 return appType; 082 } 083 084 public void setAppType(AppType type) { 085 appType = type; 086 } 087 088 /** 089 * Get the app-name of the job generating this event 090 * 091 * @return String app-name 092 */ 093 public String getAppName() { 094 return appName; 095 } 096 097 public void setAppName(String name) { 098 appName = name; 099 } 100 101 /** 102 * Get user name 103 * 104 * @return user 105 */ 106 public String getUser() { 107 return user; 108 } 109 110 public void setUser(String euser) { 111 user = euser; 112 } 113 114 /** 115 * Get the coarse status 116 * 117 * @return EventStatus 118 */ 119 public EventStatus getEventStatus() { 120 return eventStatus; 121 } 122 123 public void setEventStatus(EventStatus eStatus) { 124 eventStatus = eStatus; 125 } 126 127 128 public Date getStartTime() { 129 return startTime; 130 } 131 132 public void setStartTime(Date time) { 133 startTime = time; 134 } 135 136 public Date getEndTime() { 137 return endTime; 138 } 139 140 public void setEndTime(Date time) { 141 endTime = time; 142 } 143 144 @Override 145 public String toString() { 146 return "ID: " + getId() + ", MsgType:" + getMsgType() + ", AppType: " + getAppType() + ", Appname: " 147 + getAppName() + ", Status: " + getEventStatus(); 148 } 149 150}