use of org.apache.hadoop.mapreduce.lib.output.NullOutputFormat in project hive by apache.
the class TempletonControllerJob method run.
/**
* Enqueue the job and print out the job id for later collection.
* @see org.apache.hive.hcatalog.templeton.CompleteDelegator
*/
@Override
public int run(String[] args) throws IOException, InterruptedException, ClassNotFoundException, TException {
if (LOG.isDebugEnabled()) {
LOG.debug("Preparing to submit job: " + Arrays.toString(args));
}
Configuration conf = getConf();
conf.set(JAR_ARGS_NAME, TempletonUtils.encodeArray(args));
String memoryMb = appConf.mapperMemoryMb();
if (memoryMb != null && memoryMb.length() != 0) {
conf.set(AppConfig.HADOOP_MAP_MEMORY_MB, memoryMb);
}
String amMemoryMB = appConf.amMemoryMb();
if (amMemoryMB != null && !amMemoryMB.isEmpty()) {
conf.set(AppConfig.HADOOP_MR_AM_MEMORY_MB, amMemoryMB);
}
String amJavaOpts = appConf.controllerAMChildOpts();
if (amJavaOpts != null && !amJavaOpts.isEmpty()) {
conf.set(AppConfig.HADOOP_MR_AM_JAVA_OPTS, amJavaOpts);
}
String user = UserGroupInformation.getCurrentUser().getShortUserName();
conf.set("user.name", user);
job = new Job(conf);
job.setJarByClass(LaunchMapper.class);
job.setJobName(TempletonControllerJob.class.getSimpleName());
job.setMapperClass(LaunchMapper.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
job.setInputFormatClass(SingleInputFormat.class);
NullOutputFormat<NullWritable, NullWritable> of = new NullOutputFormat<NullWritable, NullWritable>();
job.setOutputFormatClass(of.getClass());
job.setNumReduceTasks(0);
JobClient jc = new JobClient(new JobConf(job.getConfiguration()));
if (UserGroupInformation.isSecurityEnabled()) {
Token<DelegationTokenIdentifier> mrdt = jc.getDelegationToken(new Text("mr token"));
job.getCredentials().addToken(new Text("mr token"), mrdt);
}
LauncherDelegator.JobType jobType = LauncherDelegator.JobType.valueOf(conf.get(JOB_TYPE));
String tokenStrForm = null;
if (jobType == LauncherDelegator.JobType.HIVE) {
tokenStrForm = addToken(job, user, SecureProxySupport.HIVE_SERVICE);
} else {
tokenStrForm = addToken(job, user, SecureProxySupport.HCAT_SERVICE);
}
job.submit();
JobID submittedJobId = job.getJobID();
if (tokenStrForm != null) {
// so that it can be cancelled later from CompleteDelegator
DelegationTokenCache.getStringFormTokenCache().storeDelegationToken(submittedJobId.toString(), tokenStrForm);
LOG.debug("Added delegation token for jobId=" + submittedJobId.toString() + " user=" + user);
}
return 0;
}
Aggregations