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; 016 017 /** 018 * Transition command for materialize the job. The derived class has to override these following functions: 019 * <p/> 020 * loadState() : load the job's and/or actions' state 021 * updateJob() : update job status and attributes 022 * StartChildren() : submit or queue commands to start children 023 * notifyParent() : update the status to upstream if any 024 */ 025 public abstract class MaterializeTransitionXCommand extends TransitionXCommand<Void> { 026 027 /** 028 * The constructor for abstract class {@link MaterializeTransitionXCommand} 029 * 030 * @param name the command name 031 * @param type the command type 032 * @param priority the command priority 033 */ 034 public MaterializeTransitionXCommand(String name, String type, int priority) { 035 super(name, type, priority); 036 } 037 038 /** 039 * The constructor for abstract class {@link MaterializeTransitionXCommand} 040 * 041 * @param name the command name 042 * @param type the command type 043 * @param priority the command priority 044 * @param dryrun true if dryrun is enable 045 */ 046 public MaterializeTransitionXCommand(String name, String type, int priority, boolean dryrun) { 047 super(name, type, priority, dryrun); 048 } 049 050 /* (non-Javadoc) 051 * @see org.apache.oozie.command.TransitionXCommand#transitToNext() 052 */ 053 @Override 054 public void transitToNext() throws CommandException { 055 } 056 057 /** 058 * Materialize the actions for current job 059 * @throws CommandException thrown if failed to materialize 060 */ 061 protected abstract void materialize() throws CommandException; 062 063 /* (non-Javadoc) 064 * @see org.apache.oozie.command.TransitionXCommand#execute() 065 */ 066 @Override 067 protected Void execute() throws CommandException { 068 try { 069 materialize(); 070 updateJob(); 071 } finally { 072 notifyParent(); 073 } 074 return null; 075 } 076 077 }