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    public ControlNodeActionExecutor(String type) {
045        super(type);
046    }
047
048    @SuppressWarnings("unchecked")
049    public void start(Context context, WorkflowAction action) throws ActionExecutorException {
050        context.setStartData("-", "-", "-");
051        context.setExecutionData("OK", null);
052    }
053
054    public void end(Context context, WorkflowAction action) throws ActionExecutorException {
055        context.setEndData(WorkflowAction.Status.OK, getActionSignal(WorkflowAction.Status.OK));
056    }
057
058    public void check(Context context, WorkflowAction action) throws ActionExecutorException {
059        throw new UnsupportedOperationException();
060    }
061
062    public void kill(Context context, WorkflowAction action) throws ActionExecutorException {
063        throw new UnsupportedOperationException();
064    }
065
066    public boolean isCompleted(String externalStatus) {
067        return true;
068    }
069
070}