Search in sources :

Example 6 with CoordinatorJobException

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);
    }
}
Also used : CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) SchemaService(org.apache.oozie.service.SchemaService) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader) IOException(java.io.IOException) Validator(javax.xml.validation.Validator) SAXException(org.xml.sax.SAXException)

Example 7 with CoordinatorJobException

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;
}
Also used : CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) Attribute(org.jdom.Attribute) CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) URISyntaxException(java.net.URISyntaxException) JDOMException(org.jdom.JDOMException) URIHandlerException(org.apache.oozie.dependency.URIHandlerException) ParseException(java.text.ParseException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Example 8 with CoordinatorJobException

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;
}
Also used : CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) Element(org.jdom.Element) List(java.util.List) ArrayList(java.util.ArrayList) CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) URISyntaxException(java.net.URISyntaxException) JDOMException(org.jdom.JDOMException) HadoopAccessorException(org.apache.oozie.service.HadoopAccessorException) CommandException(org.apache.oozie.command.CommandException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParameterVerifierException(org.apache.oozie.util.ParameterVerifierException)

Example 9 with CoordinatorJobException

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;
}
Also used : CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) Attribute(org.jdom.Attribute) CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) URISyntaxException(java.net.URISyntaxException) JDOMException(org.jdom.JDOMException) HadoopAccessorException(org.apache.oozie.service.HadoopAccessorException) CommandException(org.apache.oozie.command.CommandException) SAXException(org.xml.sax.SAXException) IOException(java.io.IOException) ParameterVerifierException(org.apache.oozie.util.ParameterVerifierException)

Example 10 with CoordinatorJobException

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;
}
Also used : CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) Element(org.jdom.Element) CoordELEvaluator(org.apache.oozie.coord.CoordELEvaluator) ELEvaluator(org.apache.oozie.util.ELEvaluator) CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) URISyntaxException(java.net.URISyntaxException) JDOMException(org.jdom.JDOMException) URIHandlerException(org.apache.oozie.dependency.URIHandlerException) ParseException(java.text.ParseException) IOException(java.io.IOException) CommandException(org.apache.oozie.command.CommandException)

Aggregations

CoordinatorJobException (org.apache.oozie.coord.CoordinatorJobException)10 IOException (java.io.IOException)9 JDOMException (org.jdom.JDOMException)9 URISyntaxException (java.net.URISyntaxException)8 CommandException (org.apache.oozie.command.CommandException)8 SAXException (org.xml.sax.SAXException)7 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)6 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)6 ParameterVerifierException (org.apache.oozie.util.ParameterVerifierException)6 Element (org.jdom.Element)5 StringReader (java.io.StringReader)2 ParseException (java.text.ParseException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 URIHandlerException (org.apache.oozie.dependency.URIHandlerException)2 Attribute (org.jdom.Attribute)2 InputStreamReader (java.io.InputStreamReader)1 Reader (java.io.Reader)1 StringWriter (java.io.StringWriter)1 URI (java.net.URI)1