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.BundleJob; 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 Bundle Jobs 031 * 032 */ 033 @SuppressWarnings("serial") 034 public class BundleJobEvent extends JobEvent { 035 036 private BundleJob.Status status; 037 038 public BundleJobEvent(String id, BundleJob.Status status, String user, String appName, Date startTime, Date endTime) { 039 super(id, null, user, AppType.BUNDLE_JOB, appName); // parentId is null 040 setStatus(status); 041 setStartTime(startTime); 042 setEndTime(endTime); 043 XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString()); 044 } 045 046 public BundleJob.Status getStatus() { 047 return status; 048 } 049 050 public void setStatus(BundleJob.Status bstatus) { 051 status = bstatus; 052 // set high-level status for event based on low-level actual job status 053 // this is to ease filtering on the consumer side 054 switch (status) { 055 case SUCCEEDED: 056 setEventStatus(EventStatus.SUCCESS); 057 break; 058 case RUNNING: 059 setEventStatus(EventStatus.STARTED); 060 break; 061 case SUSPENDED: 062 case SUSPENDEDWITHERROR: 063 setEventStatus(EventStatus.SUSPEND); 064 break; 065 case KILLED: 066 case FAILED: 067 case DONEWITHERROR: 068 setEventStatus(EventStatus.FAILURE); 069 } 070 } 071 072 }