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