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.WorkflowAction;
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 Workflow Actions
031 */
032 @SuppressWarnings("serial")
033 public class WorkflowActionEvent extends JobEvent {
034
035 private WorkflowAction.Status status;
036 private String hadoopId;
037 private String errorCode;
038 private String errorMessage;
039
040 public WorkflowActionEvent(String id, String parentId, WorkflowAction.Status status, String user, String appName,
041 Date startTime, Date endTime) {
042 super(id, parentId, user, AppType.WORKFLOW_ACTION, appName);
043 setStatus(status);
044 setStartTime(startTime);
045 setEndTime(endTime);
046 XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
047 }
048
049 public WorkflowAction.Status getStatus() {
050 return status;
051 }
052
053 public void setStatus(WorkflowAction.Status actionStatus) {
054 status = actionStatus;
055 // set high-level status for event based on low-level actual job status
056 // this is to ease filtering on the consumer side
057 switch (actionStatus) {
058 case OK:
059 setEventStatus(EventStatus.SUCCESS);
060 break;
061 case RUNNING:
062 setEventStatus(EventStatus.STARTED);
063 break;
064 case ERROR:
065 case KILLED:
066 case FAILED:
067 setEventStatus(EventStatus.FAILURE);
068 break;
069 case START_MANUAL:
070 case END_MANUAL:
071 setEventStatus(EventStatus.SUSPEND);
072 }
073 }
074
075 public String getHadoopId() {
076 return hadoopId;
077 }
078
079 public void setHadoopId(String id) {
080 hadoopId = id;
081 }
082
083 public String getErrorCode() {
084 return errorCode;
085 }
086
087 public void setErrorCode(String code) {
088 errorCode = code;
089 }
090
091 public String getErrorMessage() {
092 return errorMessage;
093 }
094
095 public void setErrorMessage(String msg) {
096 errorMessage = msg;
097 }
098
099 }