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