blob: b31f0db273ae8d651b7e49a45381a6652e8fe70a [file] [log] [blame]
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.oozie.event;
import java.util.Date;
import org.apache.oozie.AppType;
import org.apache.oozie.client.BundleJob;
import org.apache.oozie.client.event.JobEvent;
import org.apache.oozie.service.EventHandlerService;
import org.apache.oozie.util.XLog;
/**
* Class implementing JobEvent for events generated by Bundle Jobs
*
*/
@SuppressWarnings("serial")
public class BundleJobEvent extends JobEvent {
private BundleJob.Status status;
public BundleJobEvent(String id, BundleJob.Status status, String user, String appName, Date startTime, Date endTime) {
super(id, null, user, AppType.BUNDLE_JOB, appName); // parentId is null
setStatus(status);
setStartTime(startTime);
setEndTime(endTime);
XLog.getLog(EventHandlerService.class).trace("Event generated - " + this.toString());
}
public BundleJob.Status getStatus() {
return status;
}
public void setStatus(BundleJob.Status bstatus) {
status = bstatus;
// set high-level status for event based on low-level actual job status
// this is to ease filtering on the consumer side
switch (status) {
case SUCCEEDED:
setEventStatus(EventStatus.SUCCESS);
break;
case RUNNING:
setEventStatus(EventStatus.STARTED);
break;
case SUSPENDED:
case SUSPENDEDWITHERROR:
setEventStatus(EventStatus.SUSPEND);
break;
case KILLED:
case FAILED:
case DONEWITHERROR:
setEventStatus(EventStatus.FAILURE);
}
}
}