This project has retired. For details please refer to its
Attic page.
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;
019
020 import org.apache.oozie.client.Job;
021
022 /**
023 * Transition command for start the job. The derived class has to override these following functions:
024 * <p/>
025 * loadState() : load the job's and/or actions' state
026 * updateJob() : update job status and attributes
027 * StartChildren() : submit or queue commands to start children
028 * notifyParent() : update the status to upstream if any
029 */
030 public abstract class StartTransitionXCommand extends TransitionXCommand<Void> {
031
032 /**
033 * The constructor for abstract class {@link StartTransitionXCommand}
034 *
035 * @param name the command name
036 * @param type the command type
037 * @param priority the command priority
038 */
039 public StartTransitionXCommand(String name, String type, int priority) {
040 super(name, type, priority);
041 }
042
043 /**
044 * The constructor for abstract class {@link StartTransitionXCommand}
045 *
046 * @param name the command name
047 * @param type the command type
048 * @param priority the command priority
049 * @param dryrun true if dryrun is enable
050 */
051 public StartTransitionXCommand(String name, String type, int priority, boolean dryrun) {
052 super(name, type, priority, dryrun);
053 }
054
055 /**
056 * Start actions associated with the job
057 *
058 * @throws CommandException thrown if failed to start actions
059 */
060 public abstract void StartChildren() throws CommandException;
061
062 /* (non-Javadoc)
063 * @see org.apache.oozie.command.TransitionXCommand#transitToNext()
064 */
065 @Override
066 public final void transitToNext() {
067 if (job == null) {
068 job = this.getJob();
069 }
070 job.setStatus(Job.Status.RUNNING);
071 job.setPending();
072 }
073
074 /* (non-Javadoc)
075 * @see org.apache.oozie.command.TransitionXCommand#execute()
076 */
077 @Override
078 protected Void execute() throws CommandException {
079 transitToNext();
080 updateJob();
081 StartChildren();
082 performWrites();
083 notifyParent();
084 return null;
085 }
086 }