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