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