001 /** 002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved. 003 * Licensed under the Apache License, Version 2.0 (the "License"); 004 * you may not use this file except in compliance with the License. 005 * You may obtain a copy of the License at 006 * 007 * http://www.apache.org/licenses/LICENSE-2.0 008 * 009 * Unless required by applicable law or agreed to in writing, software 010 * distributed under the License is distributed on an "AS IS" BASIS, 011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 * See the License for the specific language governing permissions and 013 * limitations under the License. See accompanying LICENSE file. 014 */ 015 package org.apache.oozie.command.bundle; 016 017 import org.apache.oozie.BundleJobBean; 018 import org.apache.oozie.client.Job; 019 import org.apache.oozie.command.CommandException; 020 import org.apache.oozie.command.PreconditionException; 021 import org.apache.oozie.command.UnpauseTransitionXCommand; 022 import org.apache.oozie.executor.jpa.BundleJobUpdateJPAExecutor; 023 import org.apache.oozie.executor.jpa.JPAExecutorException; 024 import org.apache.oozie.service.JPAService; 025 import org.apache.oozie.service.Services; 026 import org.apache.oozie.util.LogUtils; 027 028 public class BundleUnpauseXCommand extends UnpauseTransitionXCommand { 029 private BundleJobBean bundleJob; 030 private JPAService jpaService = Services.get().get(JPAService.class); 031 032 public BundleUnpauseXCommand(BundleJobBean bundleJob) { 033 super("bundle_unpause", "bundle_unpause", 1); 034 this.bundleJob = bundleJob; 035 } 036 037 /* 038 * (non-Javadoc) 039 * 040 * @see org.apache.oozie.command.XCommand#getEntityKey() 041 */ 042 @Override 043 protected String getEntityKey() { 044 return bundleJob.getId(); 045 } 046 047 /* 048 * (non-Javadoc) 049 * 050 * @see org.apache.oozie.command.XCommand#isLockRequired() 051 */ 052 @Override 053 protected boolean isLockRequired() { 054 return true; 055 } 056 057 /* 058 * (non-Javadoc) 059 * 060 * @see org.apache.oozie.command.XCommand#loadState() 061 */ 062 @Override 063 public void loadState() throws CommandException { 064 LogUtils.setLogInfo(bundleJob, logInfo); 065 } 066 067 /* 068 * (non-Javadoc) 069 * 070 * @see org.apache.oozie.command.XCommand#verifyPrecondition() 071 */ 072 @Override 073 protected void verifyPrecondition() throws CommandException, PreconditionException { 074 } 075 076 /* 077 * (non-Javadoc) 078 * 079 * @see org.apache.oozie.command.TransitionXCommand#notifyParent() 080 */ 081 @Override 082 public void notifyParent() { 083 } 084 085 /* 086 * (non-Javadoc) 087 * 088 * @see org.apache.oozie.command.TransitionXCommand#getJob() 089 */ 090 @Override 091 public Job getJob() { 092 return bundleJob; 093 } 094 095 /* 096 * (non-Javadoc) 097 * 098 * @see org.apache.oozie.command.TransitionXCommand#updateJob() 099 */ 100 @Override 101 public void updateJob() throws CommandException { 102 try { 103 jpaService.execute(new BundleJobUpdateJPAExecutor(bundleJob)); 104 } 105 catch (JPAExecutorException e) { 106 throw new CommandException(e); 107 } 108 } 109 110 @Override 111 public void unpauseChildren() throws CommandException { 112 // TODO - need revisit when revisiting coord job status redesign; 113 114 } 115 116 }