Search in sources :

Example 16 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class BundleSubmitXCommand method verifyCoordNameUnique.

/**
 * Verify the uniqueness of coordinator names
 *
 * @param resolved job xml
 * @throws CommandException thrown if failed to verify the uniqueness of coordinator names
 */
@SuppressWarnings("unchecked")
private Void verifyCoordNameUnique(String resolvedJobXml) throws CommandException {
    Set<String> set = new HashSet<String>();
    try {
        Element bAppXml = XmlUtils.parseXml(resolvedJobXml);
        List<Element> coordElems = bAppXml.getChildren("coordinator", bAppXml.getNamespace());
        for (Element elem : coordElems) {
            Attribute name = elem.getAttribute("name");
            if (name != null) {
                String coordName = name.getValue();
                try {
                    coordName = ELUtils.resolveAppName(name.getValue(), conf);
                } catch (Exception e) {
                    throw new CommandException(ErrorCode.E1321, e.getMessage(), e);
                }
                if (set.contains(coordName)) {
                    throw new CommandException(ErrorCode.E1304, name);
                }
                set.add(coordName);
            } else {
                throw new CommandException(ErrorCode.E1305);
            }
        }
    } catch (JDOMException jex) {
        throw new CommandException(ErrorCode.E1301, jex.getMessage(), jex);
    }
    return null;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) CommandException(org.apache.oozie.command.CommandException) JDOMException(org.jdom.JDOMException) 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) PreconditionException(org.apache.oozie.command.PreconditionException) IOException(java.io.IOException) HashSet(java.util.HashSet)

Example 17 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class CoordinatorEngine method killJobs.

/**
 * return a list of killed Coordinator job
 *
 * @param filter the filter string for which the coordinator jobs are killed
 * @param start the starting index for coordinator jobs
 * @param length maximum number of jobs to be killed
 * @return coordinatorJobInfo the list of jobs being killed
 * @throws CoordinatorEngineException thrown if one or more of the jobs cannot be killed
 */
public CoordinatorJobInfo killJobs(String filter, int start, int length) throws CoordinatorEngineException {
    try {
        Map<String, List<String>> filterMap = parseJobsFilter(filter);
        CoordinatorJobInfo coordinatorJobInfo = new BulkCoordXCommand(filterMap, start, length, OperationType.Kill).call();
        if (coordinatorJobInfo == null) {
            return new CoordinatorJobInfo(new ArrayList<CoordinatorJobBean>(), 0, 0, 0);
        }
        return coordinatorJobInfo;
    } catch (CommandException ex) {
        throw new CoordinatorEngineException(ex);
    }
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) CommandException(org.apache.oozie.command.CommandException) BulkCoordXCommand(org.apache.oozie.command.coord.BulkCoordXCommand)

Example 18 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class CoordinatorEngine method kill.

/*
     * (non-Javadoc)
     *
     * @see org.apache.oozie.BaseEngine#kill(java.lang.String)
     */
@Override
public void kill(String jobId) throws CoordinatorEngineException {
    try {
        new CoordKillXCommand(jobId).call();
        LOG.info("User " + user + " killed the Coordinator job " + jobId);
    } catch (CommandException e) {
        throw new CoordinatorEngineException(e);
    }
}
Also used : CoordKillXCommand(org.apache.oozie.command.coord.CoordKillXCommand) CommandException(org.apache.oozie.command.CommandException)

Example 19 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class DagEngine method killJobs.

/**
 * return the jobs that've been killed
 * @param filter Jobs that satisfy the filter will be killed
 * @param start start index in the database of jobs
 * @param len maximum number of jobs that will be killed
 * @return workflowsInfo return the jobs that've been killed
 * @throws DagEngineException if the jobs could not be killed
 */
public WorkflowsInfo killJobs(String filter, int start, int len) throws DagEngineException {
    try {
        Map<String, List<String>> filterList = parseFilter(filter);
        WorkflowsInfo workflowsInfo = new BulkWorkflowXCommand(filterList, start, len, OperationType.Kill).call();
        if (workflowsInfo == null) {
            return new WorkflowsInfo(new ArrayList<WorkflowJobBean>(), 0, 0, 0);
        }
        return workflowsInfo;
    } catch (CommandException ex) {
        throw new DagEngineException(ex);
    }
}
Also used : BulkWorkflowXCommand(org.apache.oozie.command.wf.BulkWorkflowXCommand) List(java.util.List) ArrayList(java.util.ArrayList) CommandException(org.apache.oozie.command.CommandException)

Example 20 with CommandException

use of org.apache.oozie.command.CommandException in project oozie by apache.

the class DagEngine method submitHttpJob.

/**
 * Submit a pig/hive/mapreduce job through HTTP.
 * <p>
 * It validates configuration properties.
 *
 * @param conf job configuration.
 * @param jobType job type - can be "pig", "hive", "sqoop" or "mapreduce".
 * @return the job Id.
 * @throws DagEngineException thrown if the job could not be created.
 */
public String submitHttpJob(Configuration conf, String jobType) throws DagEngineException {
    validateSubmitConfiguration(conf);
    try {
        String jobId;
        SubmitHttpXCommand submit = null;
        if (jobType.equals("pig")) {
            submit = new SubmitPigXCommand(conf);
        } else if (jobType.equals("mapreduce")) {
            submit = new SubmitMRXCommand(conf);
        } else if (jobType.equals("hive")) {
            submit = new SubmitHiveXCommand(conf);
        } else if (jobType.equals("sqoop")) {
            submit = new SubmitSqoopXCommand(conf);
        }
        jobId = submit.call();
        start(jobId);
        return jobId;
    } catch (CommandException ex) {
        throw new DagEngineException(ex);
    }
}
Also used : SubmitPigXCommand(org.apache.oozie.command.wf.SubmitPigXCommand) SubmitHiveXCommand(org.apache.oozie.command.wf.SubmitHiveXCommand) SubmitMRXCommand(org.apache.oozie.command.wf.SubmitMRXCommand) SubmitSqoopXCommand(org.apache.oozie.command.wf.SubmitSqoopXCommand) CommandException(org.apache.oozie.command.CommandException) SubmitHttpXCommand(org.apache.oozie.command.wf.SubmitHttpXCommand)

Aggregations

CommandException (org.apache.oozie.command.CommandException)225 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)85 XConfiguration (org.apache.oozie.util.XConfiguration)62 Date (java.util.Date)59 IOException (java.io.IOException)57 Configuration (org.apache.hadoop.conf.Configuration)56 JPAService (org.apache.oozie.service.JPAService)56 XException (org.apache.oozie.XException)42 PreconditionException (org.apache.oozie.command.PreconditionException)35 ArrayList (java.util.ArrayList)26 StringReader (java.io.StringReader)25 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)24 List (java.util.List)23 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)23 Element (org.jdom.Element)23 JDOMException (org.jdom.JDOMException)20 File (java.io.File)16 HadoopAccessorException (org.apache.oozie.service.HadoopAccessorException)16 WorkflowException (org.apache.oozie.workflow.WorkflowException)16 URISyntaxException (java.net.URISyntaxException)14