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 019package org.apache.oozie; 020 021import org.apache.oozie.client.BulkResponse; 022import org.apache.oozie.client.BundleJob; 023import org.apache.oozie.client.OozieClientException; 024 025import java.util.List; 026 027/** 028 * Client API to submit and manage Oozie Bundle jobs against an Oozie instance. 029 * <p> 030 * This class is thread safe. 031 * <p> 032 * Syntax for filter for the {@link #getJobsInfo(String)} {@link #getJobsInfo(String, int, int)} methods: 033 * <code>[NAME=VALUE][;NAME=VALUE]*</code>. 034 * <p> 035 * Valid filter names are: 036 * <ul> 037 * <li>name: the bundle application name from the bundle definition.</li> 038 * <li>user: the user that submitted the job.</li> 039 * <li>group: the group for the job.</li> 040 * <li>status: the status of the job.</li> 041 * </ul> 042 * <p> 043 * The query will do an AND among all the filter names. The query will do an OR among all the filter values for the same 044 * name. Multiple values must be specified as different name value pairs. 045 */ 046public class LocalOozieClientBundle extends BaseLocalOozieClient { 047 048 private final BundleEngine bundleEngine; 049 050 public LocalOozieClientBundle(BundleEngine bundleEngine) { 051 super(bundleEngine); 052 this.bundleEngine = bundleEngine; 053 } 054 055 @Override 056 public BundleJob getBundleJobInfo(String jobId) throws OozieClientException { 057 try { 058 return bundleEngine.getBundleJob(jobId); 059 } catch (BundleEngineException e) { 060 throw new OozieClientException(e.getErrorCode().toString(), e); 061 } 062 } 063 064 @Override 065 public Void reRunBundle(String jobId, String coordScope, String dateScope, boolean refresh, boolean noCleanup) 066 throws OozieClientException { 067 try { 068 bundleEngine.reRun(jobId, coordScope, dateScope, refresh, noCleanup); 069 } catch (BaseEngineException e) { 070 throw new OozieClientException(e.getErrorCode().toString(), e); 071 } 072 return null; 073 } 074 075 @Override 076 public List<BundleJob> getBundleJobsInfo(String filter, int start, int len) throws OozieClientException { 077 try { 078 return (List) bundleEngine.getBundleJobs(filter, start, len).getBundleJobs(); 079 } catch (BundleEngineException e) { 080 throw new OozieClientException(e.getErrorCode().toString(), e); 081 } 082 } 083 084 @Override 085 public List<BulkResponse> getBulkInfo(String filter, int start, int len) throws OozieClientException { 086 try { 087 return (List) bundleEngine.getBulkJobs(filter, start, len).getResponses(); 088 } catch (BundleEngineException e) { 089 throw new OozieClientException(e.getErrorCode().toString(), e); 090 } 091 } 092}