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