Search in sources :

Example 1 with ParameterVerifierException

use of org.apache.oozie.util.ParameterVerifierException in project oozie by apache.

the class CoordSubmitXCommand method submitJob.

protected String submitJob() throws CommandException {
    String jobId = null;
    InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
    boolean exceptionOccured = false;
    try {
        mergeDefaultConfig();
        String appXml = readAndValidateXml();
        coordJob.setOrigJobXml(appXml);
        LOG.debug("jobXml after initial validation " + XmlUtils.prettyPrint(appXml).toString());
        Element eXml = XmlUtils.parseXml(appXml);
        String appNamespace = readAppNamespace(eXml);
        coordJob.setAppNamespace(appNamespace);
        ParameterVerifier.verifyParameters(conf, eXml);
        appXml = XmlUtils.removeComments(appXml);
        initEvaluators();
        Element eJob = basicResolveAndIncludeDS(appXml, conf, coordJob);
        validateCoordinatorJob();
        // checking if the coordinator application data input/output events
        // specify multiple data instance values in erroneous manner
        checkMultipleTimeInstances(eJob, COORD_INPUT_EVENTS, COORD_INPUT_EVENTS_DATA_IN);
        checkMultipleTimeInstances(eJob, COORD_OUTPUT_EVENTS, COORD_OUTPUT_EVENTS_DATA_OUT);
        LOG.debug("jobXml after all validation " + XmlUtils.prettyPrint(eJob).toString());
        jobId = storeToDB(appXml, eJob, coordJob);
        // log job info for coordinator job
        LogUtils.setLogInfo(coordJob);
        if (!dryrun) {
            queueMaterializeTransitionXCommand(jobId);
        } else {
            return getDryRun(coordJob);
        }
    } catch (JDOMException jex) {
        exceptionOccured = true;
        LOG.warn("ERROR: ", jex);
        throw new CommandException(ErrorCode.E0700, jex.getMessage(), jex);
    } catch (CoordinatorJobException cex) {
        exceptionOccured = true;
        LOG.warn("ERROR:  ", cex);
        throw new CommandException(cex);
    } catch (ParameterVerifierException pex) {
        exceptionOccured = true;
        LOG.warn("ERROR: ", pex);
        throw new CommandException(pex);
    } catch (IllegalArgumentException iex) {
        exceptionOccured = true;
        LOG.warn("ERROR:  ", iex);
        throw new CommandException(ErrorCode.E1003, iex.getMessage(), iex);
    } catch (Exception ex) {
        exceptionOccured = true;
        LOG.warn("ERROR:  ", ex);
        throw new CommandException(ErrorCode.E0803, ex.getMessage(), ex);
    } finally {
        if (exceptionOccured) {
            if (coordJob.getId() == null || coordJob.getId().equalsIgnoreCase("")) {
                coordJob.setStatus(CoordinatorJob.Status.FAILED);
                coordJob.resetPending();
            }
        }
    }
    return jobId;
}
Also used : CoordinatorJobException(org.apache.oozie.coord.CoordinatorJobException) Element(org.jdom.Element) CommandException(org.apache.oozie.command.CommandException) JDOMException(org.jdom.JDOMException) ParameterVerifierException(org.apache.oozie.util.ParameterVerifierException) 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 2 with ParameterVerifierException

use of org.apache.oozie.util.ParameterVerifierException in project oozie by apache.

the class LiteWorkflowAppParser method validateAndParse.

/**
 * Parse and validate xml to {@link LiteWorkflowApp}
 *
 * @param reader
 * @return LiteWorkflowApp
 * @throws WorkflowException
 */
public LiteWorkflowApp validateAndParse(Reader reader, Configuration jobConf, Configuration configDefault) throws WorkflowException {
    try {
        StringWriter writer = new StringWriter();
        IOUtils.copyCharStream(reader, writer);
        String strDef = writer.toString();
        if (schema != null) {
            Validator validator = SchemaService.getValidator(schema);
            validator.validate(new StreamSource(new StringReader(strDef)));
        }
        Element wfDefElement = XmlUtils.parseXml(strDef);
        ParameterVerifier.verifyParameters(jobConf, wfDefElement);
        LiteWorkflowApp app = parse(strDef, wfDefElement, configDefault, jobConf);
        boolean validateForkJoin = false;
        if (jobConf.getBoolean(WF_VALIDATE_FORK_JOIN, true) && ConfigurationService.getBoolean(VALIDATE_FORK_JOIN)) {
            validateForkJoin = true;
        }
        LiteWorkflowValidator validator = new LiteWorkflowValidator();
        validator.validateWorkflow(app, validateForkJoin);
        return app;
    } catch (ParameterVerifierException ex) {
        throw new WorkflowException(ex);
    } catch (JDOMException ex) {
        throw new WorkflowException(ErrorCode.E0700, ex.getMessage(), ex);
    } catch (SAXException ex) {
        throw new WorkflowException(ErrorCode.E0701, ex.getMessage(), ex);
    } catch (IOException ex) {
        throw new WorkflowException(ErrorCode.E0702, ex.getMessage(), ex);
    }
}
Also used : StreamSource(javax.xml.transform.stream.StreamSource) Element(org.jdom.Element) WorkflowException(org.apache.oozie.workflow.WorkflowException) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException) SAXException(org.xml.sax.SAXException) StringWriter(java.io.StringWriter) StringReader(java.io.StringReader) ParameterVerifierException(org.apache.oozie.util.ParameterVerifierException) Validator(javax.xml.validation.Validator)

Aggregations

IOException (java.io.IOException)2 ParameterVerifierException (org.apache.oozie.util.ParameterVerifierException)2 Element (org.jdom.Element)2 JDOMException (org.jdom.JDOMException)2 SAXException (org.xml.sax.SAXException)2 StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 URISyntaxException (java.net.URISyntaxException)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Validator (javax.xml.validation.Validator)1 CommandException (org.apache.oozie.command.CommandException)1 CoordinatorJobException (org.apache.oozie.coord.CoordinatorJobException)1 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)1 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)1 WorkflowException (org.apache.oozie.workflow.WorkflowException)1