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
019 package org.apache.oozie.event;
020
021 import java.util.Date;
022
023 import org.apache.oozie.AppType;
024 import org.apache.oozie.client.CoordinatorAction;
025 import org.apache.oozie.client.event.JobEvent;
026 import org.apache.oozie.service.EventHandlerService;
027 import org.apache.oozie.util.XLog;
028
029 /**
030 * Class implementing JobEvent for events generated by Coordinator Actions
031 */
032 @SuppressWarnings("serial")
033 public class CoordinatorActionEvent extends JobEvent {
034
035 private CoordinatorAction.Status status;
036 private Date nominalTime;
037 private String missingDeps;
038 private String errorCode;
039 private String errorMessage;
040 // TODO more attributes - frequency, timeunit, bundleName
041 // for some advanced processing and linking using events
042
043 public CoordinatorActionEvent(String id, String parentId, CoordinatorAction.Status status, String user,
044 String appName, Date nomTime, Date startTime, String missDeps) {
045 super(id, parentId, user, AppType.COORDINATOR_ACTION, appName);
046 setStatus(status);
047 setNominalTime(nomTime);
048 setStartTime(startTime);
049 setMissingDeps(missDeps);
050 XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
051 }
052
053 public String getBundleJobId() {
054 return null; // TODO extract prefix from bundleActionId before '@'
055 }
056
057 public CoordinatorAction.Status getStatus() {
058 return status;
059 }
060
061 public void setStatus(CoordinatorAction.Status castatus) {
062 status = castatus;
063 // set high-level status for event based on low-level actual job status
064 // this is to ease filtering on the consumer side
065 switch (status) {
066 case WAITING:
067 setEventStatus(EventStatus.WAITING);
068 break;
069 case SUCCEEDED:
070 setEventStatus(EventStatus.SUCCESS);
071 setEndTime(new Date());
072 break;
073 case RUNNING:
074 setEventStatus(EventStatus.STARTED);
075 break;
076 case SUSPENDED:
077 setEventStatus(EventStatus.SUSPEND);
078 break;
079 case KILLED:
080 case FAILED:
081 case TIMEDOUT:
082 setEventStatus(EventStatus.FAILURE);
083 setEndTime(new Date());
084 }
085 }
086
087 public Date getNominalTime() {
088 return nominalTime;
089 }
090
091 public void setNominalTime(Date time) {
092 nominalTime = time;
093 }
094
095 public String getMissingDeps() {
096 return missingDeps;
097 }
098
099 public void setMissingDeps(String dependencies) {
100 missingDeps = dependencies;
101 }
102
103 public String getErrorCode() {
104 return errorCode;
105 }
106
107 public void setErrorCode(String code) {
108 errorCode = code;
109 }
110
111 public String getErrorMessage() {
112 return errorMessage;
113 }
114
115 public void setErrorMessage(String msg) {
116 errorMessage = msg;
117 }
118
119 }