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