use of org.apache.oozie.coord.CoordinatorJobException in project oozie by apache.
the class CoordSubmitXCommand method validateXml.
/**
* Validate against Coordinator XSD file
*
* @param xmlContent : Input coordinator xml
* @throws CoordinatorJobException thrown if unable to validate coordinator xml
*/
private void validateXml(String xmlContent) throws CoordinatorJobException {
try {
Validator validator = Services.get().get(SchemaService.class).getValidator(SchemaName.COORDINATOR);
validator.validate(new StreamSource(new StringReader(xmlContent)));
} catch (SAXException ex) {
LOG.warn("SAXException :", ex);
throw new CoordinatorJobException(ErrorCode.E0701, ex.getMessage(), ex);
} catch (IOException ex) {
LOG.warn("IOException :", ex);
throw new CoordinatorJobException(ErrorCode.E0702, ex.getMessage(), ex);
}
}
use of org.apache.oozie.coord.CoordinatorJobException in project oozie by apache.
the class CoordCommandUtils method resolveAttribute.
private static String resolveAttribute(String attrName, Element elem, ELEvaluator eval) throws CoordinatorJobException {
Attribute attr = elem.getAttribute(attrName);
String val = null;
if (attr != null) {
try {
val = CoordELFunctions.evalAndWrap(eval, attr.getValue().trim());
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
attr.setValue(val);
}
return val;
}
use of org.apache.oozie.coord.CoordinatorJobException in project oozie by apache.
the class CoordSubmitXCommand method resolveTagContents.
/**
* Resolve the content of a tag.
*
* @param tagName : Tag name of job XML i.e. <timeout> 10 </timeout>
* @param elem : Element where the tag exists.
* @param eval : EL evealuator
* @return Resolved tag content.
* @throws CoordinatorJobException thrown if failed to resolve tag content
*/
@SuppressWarnings("unchecked")
private String resolveTagContents(String tagName, Element elem, ELEvaluator eval) throws CoordinatorJobException {
String ret = "";
if (elem != null) {
for (Element tagElem : (List<Element>) elem.getChildren(tagName, elem.getNamespace())) {
if (tagElem != null) {
String updated;
try {
updated = CoordELFunctions.evalAndWrap(eval, tagElem.getText().trim());
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
tagElem.removeContent();
tagElem.addContent(updated);
ret += updated;
}
}
}
return ret;
}
use of org.apache.oozie.coord.CoordinatorJobException in project oozie by apache.
the class CoordSubmitXCommand method resolveAttribute.
/**
* Resolve an attribute value.
*
* @param attrName : Attribute name.
* @param elem : XML Element where attribute is defiend
* @param eval : ELEvaluator used to resolve
* @return Resolved attribute value
* @throws CoordinatorJobException thrown if failed to resolve an attribute value
*/
private String resolveAttribute(String attrName, Element elem, ELEvaluator eval) throws CoordinatorJobException {
Attribute attr = elem.getAttribute(attrName);
String val = null;
if (attr != null) {
try {
val = CoordELFunctions.evalAndWrap(eval, attr.getValue().trim());
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
attr.setValue(val);
}
return val;
}
use of org.apache.oozie.coord.CoordinatorJobException in project oozie by apache.
the class CoordCommandUtils method materializeSLA.
/**
* @param eAction
* @param coordAction
* @param conf
* @return boolean to determine whether the SLA element is present or not
* @throws CoordinatorJobException
*/
public static boolean materializeSLA(Element eAction, CoordinatorActionBean coordAction, Configuration conf) throws CoordinatorJobException {
Element eSla = eAction.getChild("action", eAction.getNamespace()).getChild("info", eAction.getNamespace("sla"));
if (eSla == null) {
// eAppXml.getNamespace("sla"));
return false;
}
try {
ELEvaluator evalSla = CoordELEvaluator.createSLAEvaluator(eAction, coordAction, conf);
List<Element> elemList = eSla.getChildren();
for (Element elem : elemList) {
String updated;
try {
updated = CoordELFunctions.evalAndWrap(evalSla, elem.getText().trim());
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
elem.removeContent();
elem.addContent(updated);
}
} catch (Exception e) {
throw new CoordinatorJobException(ErrorCode.E1004, e.getMessage(), e);
}
return true;
}
Aggregations