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.CoordinatorJob; 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 Jobs 031 */ 032 @SuppressWarnings("serial") 033 public class CoordinatorJobEvent extends JobEvent { 034 035 private CoordinatorJob.Status status; 036 037 public CoordinatorJobEvent(String id, String parentId, CoordinatorJob.Status status, String user, String appName, 038 Date startTime, Date endTime) { 039 super(id, parentId, user, AppType.COORDINATOR_JOB, appName); 040 setStatus(status); 041 setStartTime(startTime); 042 setEndTime(endTime); 043 XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString()); 044 } 045 046 public CoordinatorJob.Status getStatus() { 047 return status; 048 } 049 050 public void setStatus(CoordinatorJob.Status coordStatus) { 051 status = coordStatus; 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 PREPSUSPENDED: 063 case SUSPENDEDWITHERROR: 064 setEventStatus(EventStatus.SUSPEND); 065 break; 066 case KILLED: 067 case FAILED: 068 case DONEWITHERROR: 069 setEventStatus(EventStatus.FAILURE); 070 } 071 } 072 073 }