Search in sources :

Example 76 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class DecisionActionExecutor method start.

@SuppressWarnings("unchecked")
public void start(Context context, WorkflowAction action) throws ActionExecutorException {
    LOG.info("Starting action");
    try {
        String confStr = action.getConf();
        context.setStartData("-", "-", "-");
        Element conf = XmlUtils.parseXml(confStr);
        Namespace ns = conf.getNamespace();
        String externalState = null;
        for (Element eval : (List<Element>) conf.getChildren("case", ns)) {
            if (TRUE.equals(eval.getTextTrim())) {
                externalState = eval.getAttributeValue("to");
                break;
            }
        }
        if (externalState == null) {
            Element def = conf.getChild("default", ns);
            if (def != null) {
                externalState = def.getAttributeValue("to");
            }
        }
        if (externalState == null) {
            throw new IllegalStateException("Transition cannot be NULL");
        }
        // for decision we are piggybacking on external status to transfer the transition,
        // the {@link ActionEndCommand} does the special handling of setting it as signal value.
        context.setExecutionData(externalState, null);
    } catch (JDOMException ex) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.FAILED, XML_ERROR, ex.getMessage(), ex);
    }
}
Also used : Element(org.jdom2.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) List(java.util.List) JDOMException(org.jdom2.JDOMException) Namespace(org.jdom2.Namespace)

Example 77 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class InputLogicParser method parse.

public String parse(Element root, String opt, String min, String wait) {
    StringBuilder parsedString = new StringBuilder();
    Namespace ns = root.getNamespace();
    if (root.getName().equals(COMBINE)) {
        parsedString.append("(");
        parsedString.append(processCombinedNode(root, getOpt(root.getName()), getMin(root, min), getWait(root, wait)));
        parsedString.append(")");
    } else if (root.getName().equals(AND) || root.getName().equals(OR)) {
        parsedString.append("(");
        parsedString.append(parseAllChildren(root, opt, getOpt(root.getName()), getMin(root, min), getWait(root, wait)));
        parsedString.append(")");
    } else if (root.getChild(COORD_INPUT_EVENTS_DATA_IN, ns) != null) {
        parsedString.append("(");
        parsedString.append(processChildNode(root, getOpt(root.getName()), getMin(root, min), getWait(root, wait)));
        parsedString.append(")");
    } else if (root.getName().equals(COORD_INPUT_EVENTS_DATA_IN)) {
        parsedString.append(parseDataInNode(root, min, wait));
    }
    return parsedString.toString();
}
Also used : Namespace(org.jdom2.Namespace)

Example 78 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class InputLogicParser method processCombinedNode.

/**
 * Process combined node.
 *
 * @param root the root
 * @param opt the opt
 * @param min the min
 * @param wait the wait
 * @return the string
 */
@SuppressWarnings("unchecked")
private String processCombinedNode(final Element root, final String opt, final String min, final String wait) {
    StringBuilder parsedString = new StringBuilder();
    Namespace ns = root.getNamespace();
    List<Element> childrens = root.getChildren(COORD_INPUT_EVENTS_DATA_IN, ns);
    parsedString.append("dependencyBuilder.combine(");
    for (int i = 0; i < childrens.size(); i++) {
        String nestedChildDataName = childrens.get(i).getAttributeValue("dataset");
        parsedString.append("\"" + nestedChildDataName + "\"");
        if (i < childrens.size() - 1) {
            parsedString.append(",");
        }
    }
    parsedString.append(")");
    appendMin(root, min, parsedString);
    appendWait(root, wait, parsedString);
    parsedString.append(".build()");
    return parsedString.toString();
}
Also used : Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 79 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class InputLogicParser method processChildNode.

/**
 * Process child node.
 *
 * @param root the root
 * @param opt the opt
 * @param min the min
 * @param wait the wait
 * @return the string
 */
@SuppressWarnings("unchecked")
private String processChildNode(final Element root, final String opt, final String min, final String wait) {
    StringBuilder parsedString = new StringBuilder();
    Namespace ns = root.getNamespace();
    List<Element> childrens = root.getChildren(COORD_INPUT_EVENTS_DATA_IN, ns);
    for (int i = 0; i < childrens.size(); i++) {
        parsedString.append(parseDataInNode(childrens.get(i), min, wait));
        if (i < childrens.size() - 1) {
            parsedString.append(" " + opt + " ");
        }
    }
    return parsedString.toString();
}
Also used : Element(org.jdom2.Element) Namespace(org.jdom2.Namespace)

Example 80 with Namespace

use of com.google.cloud.servicedirectory.v1.Namespace in project oozie by apache.

the class ForTestingActionExecutor method start.

public void start(Context context, WorkflowAction action) throws ActionExecutorException {
    Element eConf = getConfiguration(action.getConf());
    Namespace ns = eConf.getNamespace();
    String error = eConf.getChild("error", ns).getText().trim();
    if ("start.transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.TRANSIENT, TEST_ERROR, "start");
    }
    if ("start.non-transient".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.NON_TRANSIENT, TEST_ERROR, "start");
    }
    if ("start.error".equals(error)) {
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
    }
    String externalStatus = eConf.getChild("external-status", ns).getText().trim();
    Element externalChildIds = eConf.getChild("external-childIds", ns);
    String runningMode = "sync";
    Element runningModeElement = eConf.getChild("running-mode", ns);
    if (null != runningModeElement) {
        runningMode = runningModeElement.getText().trim();
    }
    if (runningMode.equals("async")) {
        context.setStartData("blah", "blah", "blah");
        return;
    }
    if (runningMode.equals("async-error")) {
        context.setStartData("blah", "blah", "blah");
        context.setExecutionData(externalStatus, null);
        if (null != externalChildIds) {
            context.setExternalChildIDs(externalChildIds.getText());
        }
        throw new ActionExecutorException(ActionExecutorException.ErrorType.ERROR, TEST_ERROR, "start");
    }
    boolean callSetExecutionData = true;
    Element setStartData = eConf.getChild("avoid-set-execution-data", ns);
    if (null != setStartData) {
        if (setStartData.getText().trim().equals("true")) {
            callSetExecutionData = false;
        }
    }
    if (callSetExecutionData) {
        context.setExecutionData(externalStatus, null);
    }
    if (null != externalChildIds) {
        context.setExternalChildIDs(externalChildIds.getText());
    }
}
Also used : Element(org.jdom2.Element) ActionExecutorException(org.apache.oozie.action.ActionExecutorException) Namespace(org.jdom2.Namespace)

Aggregations

Namespace (org.jdom2.Namespace)105 Element (org.jdom2.Element)87 IOException (java.io.IOException)24 XConfiguration (org.apache.oozie.util.XConfiguration)19 ArrayList (java.util.ArrayList)16 Configuration (org.apache.hadoop.conf.Configuration)15 HashMap (java.util.HashMap)14 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)14 StringReader (java.io.StringReader)13 List (java.util.List)13 Path (org.apache.hadoop.fs.Path)12 JDOMException (org.jdom2.JDOMException)10 ScyllaValidationException (de.hpi.bpt.scylla.exception.ScyllaValidationException)9 ProcessModel (de.hpi.bpt.scylla.model.process.ProcessModel)9 Attribute (org.jdom2.Attribute)9 Writer (java.io.Writer)8 RegistrationServiceClient (com.google.cloud.servicedirectory.v1.RegistrationServiceClient)7 Map (java.util.Map)7 Document (org.jdom2.Document)7 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)6