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