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.action.control; 020 021import org.apache.oozie.action.ActionExecutor; 022import org.apache.oozie.action.ActionExecutorException; 023import org.apache.oozie.action.hadoop.FsActionExecutor; 024import org.apache.oozie.client.WorkflowAction; 025import org.apache.oozie.util.XLog; 026import org.apache.oozie.util.XmlUtils; 027import org.apache.oozie.workflow.lite.ControlNodeHandler; 028import org.jdom.Element; 029import org.jdom.JDOMException; 030import org.jdom.Namespace; 031 032import java.util.List; 033 034/** 035 * Base action executor for control nodes: START/END/KILL/FORK/JOIN 036 * <p> 037 * This action executor, similar to {@link FsActionExecutor}, is completed during the 038 * {@link #start(Context, WorkflowAction)}. 039 * <p> 040 * By hooking control nodes to an action executor, control nodes get WF action entries in the DB. 041 */ 042public abstract class ControlNodeActionExecutor extends ActionExecutor { 043 044 protected final XLog LOG = XLog.getLog(getClass()); 045 046 public ControlNodeActionExecutor(String type) { 047 super(type); 048 } 049 050 @SuppressWarnings("unchecked") 051 public void start(Context context, WorkflowAction action) throws ActionExecutorException { 052 LOG.info("Starting action"); 053 context.setStartData("-", "-", "-"); 054 context.setExecutionData("OK", null); 055 } 056 057 public void end(Context context, WorkflowAction action) throws ActionExecutorException { 058 context.setEndData(WorkflowAction.Status.OK, getActionSignal(WorkflowAction.Status.OK)); 059 LOG.info("Action ended with external status [{0}]", action.getExternalStatus()); 060 } 061 062 public void check(Context context, WorkflowAction action) throws ActionExecutorException { 063 throw new UnsupportedOperationException(); 064 } 065 066 public void kill(Context context, WorkflowAction action) throws ActionExecutorException { 067 throw new UnsupportedOperationException(); 068 } 069 070 public boolean isCompleted(String externalStatus) { 071 return true; 072 } 073 074}