Search in sources :

Example 11 with InvalidJobConfException

use of org.apache.hadoop.mapred.InvalidJobConfException in project hadoop by apache.

the class StreamJob method submitAndMonitorJob.

// Based on JobClient
public int submitAndMonitorJob() throws IOException {
    if (jar_ != null && isLocalHadoop()) {
        // getAbs became required when shell and subvm have different working dirs...
        File wd = new File(".").getAbsoluteFile();
        RunJar.unJar(new File(jar_), wd);
    }
    // if jobConf_ changes must recreate a JobClient
    jc_ = new JobClient(jobConf_);
    running_ = null;
    try {
        running_ = jc_.submitJob(jobConf_);
        jobId_ = running_.getID();
        if (background_) {
            LOG.info("Job is running in background.");
        } else if (!jc_.monitorAndPrintJob(jobConf_, running_)) {
            LOG.error("Job not successful!");
            return 1;
        }
        LOG.info("Output directory: " + output_);
    } catch (FileNotFoundException fe) {
        LOG.error("Error launching job , bad input path : " + fe.getMessage());
        return 2;
    } catch (InvalidJobConfException je) {
        LOG.error("Error launching job , Invalid job conf : " + je.getMessage());
        return 3;
    } catch (FileAlreadyExistsException fae) {
        LOG.error("Error launching job , Output path already exists : " + fae.getMessage());
        return 4;
    } catch (IOException ioe) {
        LOG.error("Error Launching job : " + ioe.getMessage());
        return 5;
    } catch (InterruptedException ie) {
        LOG.error("Error monitoring job : " + ie.getMessage());
        return 6;
    } finally {
        jc_.close();
    }
    return 0;
}
Also used : FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) FileNotFoundException(java.io.FileNotFoundException) InvalidJobConfException(org.apache.hadoop.mapred.InvalidJobConfException) IOException(java.io.IOException) File(java.io.File) JobClient(org.apache.hadoop.mapred.JobClient)

Example 12 with InvalidJobConfException

use of org.apache.hadoop.mapred.InvalidJobConfException in project cdap by caskdata.

the class DynamicPartitioningOutputFormat method checkOutputSpecs.

@Override
public void checkOutputSpecs(JobContext job) throws IOException {
    // Ensure that the output directory is set and not already there
    Path outDir = getOutputPath(job);
    if (outDir == null) {
        throw new InvalidJobConfException("Output directory not set.");
    }
    // get delegation token for outDir's file system
    TokenCache.obtainTokensForNamenodes(job.getCredentials(), new Path[] { outDir }, job.getConfiguration());
    // additionally check that output dataset and dynamic partitioner class name has been set in conf
    if (job.getConfiguration().get(Constants.Dataset.Partitioned.HCONF_ATTR_OUTPUT_DATASET) == null) {
        throw new InvalidJobConfException("The job configuration does not contain required property: " + Constants.Dataset.Partitioned.HCONF_ATTR_OUTPUT_DATASET);
    }
    Class<? extends DynamicPartitioner> partitionerClass = job.getConfiguration().getClass(PartitionedFileSetArguments.DYNAMIC_PARTITIONER_CLASS_NAME, null, DynamicPartitioner.class);
    if (partitionerClass == null) {
        throw new InvalidJobConfException("The job configuration does not contain required property: " + PartitionedFileSetArguments.DYNAMIC_PARTITIONER_CLASS_NAME);
    }
    Class<? extends FileOutputFormat> delegateOutputFormatClass = job.getConfiguration().getClass(Constants.Dataset.Partitioned.HCONF_ATTR_OUTPUT_FORMAT_CLASS_NAME, null, FileOutputFormat.class);
    if (delegateOutputFormatClass == null) {
        throw new InvalidJobConfException("The job configuration does not contain required property: " + Constants.Dataset.Partitioned.HCONF_ATTR_OUTPUT_FORMAT_CLASS_NAME);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) InvalidJobConfException(org.apache.hadoop.mapred.InvalidJobConfException)

Aggregations

InvalidJobConfException (org.apache.hadoop.mapred.InvalidJobConfException)12 Path (org.apache.hadoop.fs.Path)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 OrbTracker (org.goldenorb.OrbTracker)4 OrbConfiguration (org.goldenorb.conf.OrbConfiguration)4 IOException (java.io.IOException)3 FileSystem (org.apache.hadoop.fs.FileSystem)3 FileNotFoundException (java.io.FileNotFoundException)2 FileAlreadyExistsException (org.apache.hadoop.mapred.FileAlreadyExistsException)2 File (java.io.File)1 URI (java.net.URI)1 Date (java.util.Date)1 Configuration (org.apache.hadoop.conf.Configuration)1 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 LongWritable (org.apache.hadoop.io.LongWritable)1 JobClient (org.apache.hadoop.mapred.JobClient)1 TaskAttemptID (org.apache.hadoop.mapred.TaskAttemptID)1 INativeSerializer (org.apache.hadoop.mapred.nativetask.serde.INativeSerializer)1