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);
}
}
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();
}
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();
}
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();
}
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());
}
}
Aggregations