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 */ 018package org.apache.oozie.command.bundle; 019 020import org.apache.oozie.BundleJobBean; 021import org.apache.oozie.client.Job; 022import org.apache.oozie.command.CommandException; 023import org.apache.oozie.command.PauseTransitionXCommand; 024import org.apache.oozie.command.PreconditionException; 025import org.apache.oozie.executor.jpa.BundleJobQueryExecutor; 026import org.apache.oozie.executor.jpa.BundleJobQueryExecutor.BundleJobQuery; 027import org.apache.oozie.executor.jpa.JPAExecutorException; 028import org.apache.oozie.util.LogUtils; 029 030public class BundlePauseXCommand extends PauseTransitionXCommand { 031 private BundleJobBean bundleJob; 032 033 public BundlePauseXCommand(BundleJobBean bundleJob) { 034 super("bundle_pause", "bundle_pause", 1); 035 this.bundleJob = bundleJob; 036 } 037 038 /* (non-Javadoc) 039 * @see org.apache.oozie.command.XCommand#getEntityKey() 040 */ 041 @Override 042 public String getEntityKey() { 043 return bundleJob.getId(); 044 } 045 046 /* (non-Javadoc) 047 * @see org.apache.oozie.command.XCommand#isLockRequired() 048 */ 049 @Override 050 protected boolean isLockRequired() { 051 return true; 052 } 053 054 /* (non-Javadoc) 055 * @see org.apache.oozie.command.XCommand#loadState() 056 */ 057 @Override 058 public void loadState() throws CommandException { 059 LogUtils.setLogInfo(bundleJob, logInfo); 060 } 061 062 /* (non-Javadoc) 063 * @see org.apache.oozie.command.XCommand#verifyPrecondition() 064 */ 065 @Override 066 protected void verifyPrecondition() throws CommandException, PreconditionException { 067 } 068 069 /* (non-Javadoc) 070 * @see org.apache.oozie.command.TransitionXCommand#notifyParent() 071 */ 072 @Override 073 public void notifyParent() { 074 } 075 076 /* (non-Javadoc) 077 * @see org.apache.oozie.command.TransitionXCommand#getJob() 078 */ 079 @Override 080 public Job getJob() { 081 return bundleJob; 082 } 083 084 /* (non-Javadoc) 085 * @see org.apache.oozie.command.TransitionXCommand#updateJob() 086 */ 087 @Override 088 public void updateJob() throws CommandException { 089 try { 090 BundleJobQueryExecutor.getInstance().executeUpdate(BundleJobQuery.UPDATE_BUNDLE_JOB_STATUS, bundleJob); 091 } 092 catch (JPAExecutorException e) { 093 throw new CommandException(e); 094 } 095 } 096 097 @Override 098 public void pauseChildren() throws CommandException { 099 // TODO - need revisit when revisiting coord job status redesign; 100 101 } 102 103 @Override 104 public void performWrites() throws CommandException { 105 } 106 107}