Java Code Examples for org.apache.hadoop.mapred.JobConf#setUser()
The following examples show how to use
org.apache.hadoop.mapred.JobConf#setUser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestDistCacheEmulation.java From hadoop with Apache License 2.0 | 6 votes |
/** * test method configureDistCacheFiles * */ @Test (timeout=2000) public void testDistCacheEmulator() throws Exception { Configuration conf = new Configuration(); configureDummyDistCacheFiles(conf); File ws = new File("target" + File.separator + this.getClass().getName()); Path ioPath = new Path(ws.getAbsolutePath()); DistributedCacheEmulator dce = new DistributedCacheEmulator(conf, ioPath); JobConf jobConf = new JobConf(conf); jobConf.setUser(UserGroupInformation.getCurrentUser().getShortUserName()); File fin=new File("src"+File.separator+"test"+File.separator+"resources"+File.separator+"data"+File.separator+"wordcount.json"); dce.init(fin.getAbsolutePath(), JobCreator.LOADJOB, true); dce.configureDistCacheFiles(conf, jobConf); String[] caches=conf.getStrings(MRJobConfig.CACHE_FILES); String[] tmpfiles=conf.getStrings("tmpfiles"); // this method should fill caches AND tmpfiles from MRJobConfig.CACHE_FILES property assertEquals(6, ((caches==null?0:caches.length)+(tmpfiles==null?0:tmpfiles.length))); }
Example 2
Source File: TestDistCacheEmulation.java From big-c with Apache License 2.0 | 6 votes |
/** * test method configureDistCacheFiles * */ @Test (timeout=2000) public void testDistCacheEmulator() throws Exception { Configuration conf = new Configuration(); configureDummyDistCacheFiles(conf); File ws = new File("target" + File.separator + this.getClass().getName()); Path ioPath = new Path(ws.getAbsolutePath()); DistributedCacheEmulator dce = new DistributedCacheEmulator(conf, ioPath); JobConf jobConf = new JobConf(conf); jobConf.setUser(UserGroupInformation.getCurrentUser().getShortUserName()); File fin=new File("src"+File.separator+"test"+File.separator+"resources"+File.separator+"data"+File.separator+"wordcount.json"); dce.init(fin.getAbsolutePath(), JobCreator.LOADJOB, true); dce.configureDistCacheFiles(conf, jobConf); String[] caches=conf.getStrings(MRJobConfig.CACHE_FILES); String[] tmpfiles=conf.getStrings("tmpfiles"); // this method should fill caches AND tmpfiles from MRJobConfig.CACHE_FILES property assertEquals(6, ((caches==null?0:caches.length)+(tmpfiles==null?0:tmpfiles.length))); }
Example 3
Source File: DistRaid.java From RDFS with Apache License 2.0 | 6 votes |
/** * create new job conf based on configuration passed. * * @param conf * @return */ private static JobConf createJobConf(Configuration conf) { JobConf jobconf = new JobConf(conf, DistRaid.class); jobName = NAME + " " + dateForm.format(new Date(RaidNode.now())); jobconf.setUser(RaidNode.JOBUSER); jobconf.setJobName(jobName); jobconf.setMapSpeculativeExecution(false); RaidUtils.parseAndSetOptions(jobconf, SCHEDULER_OPTION_LABEL); jobconf.setJarByClass(DistRaid.class); jobconf.setInputFormat(DistRaidInputFormat.class); jobconf.setOutputKeyClass(Text.class); jobconf.setOutputValueClass(Text.class); jobconf.setMapperClass(DistRaidMapper.class); jobconf.setNumReduceTasks(0); return jobconf; }
Example 4
Source File: TestReduceTaskFetchFail.java From RDFS with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") @Test public void testcheckAndInformJobTracker() throws Exception { //mock creation TaskUmbilicalProtocol mockUmbilical = mock(TaskUmbilicalProtocol.class); TaskReporter mockTaskReporter = mock(TaskReporter.class); JobConf conf = new JobConf(); conf.setUser("testuser"); conf.setJobName("testJob"); conf.setSessionId("testSession"); TaskAttemptID tid = new TaskAttemptID(); TestReduceTask rTask = new TestReduceTask(); rTask.setConf(conf); ReduceTask.ReduceCopier reduceCopier = rTask.new TestReduceCopier(mockUmbilical, conf, mockTaskReporter); reduceCopier.checkAndInformJobTracker(1, tid, false); verify(mockTaskReporter, never()).progress(); reduceCopier.checkAndInformJobTracker(10, tid, false); verify(mockTaskReporter, times(1)).progress(); // Test the config setting conf.setInt("mapreduce.reduce.shuffle.maxfetchfailures", 3); rTask.setConf(conf); reduceCopier = rTask.new TestReduceCopier(mockUmbilical, conf, mockTaskReporter); reduceCopier.checkAndInformJobTracker(1, tid, false); verify(mockTaskReporter, times(1)).progress(); reduceCopier.checkAndInformJobTracker(3, tid, false); verify(mockTaskReporter, times(2)).progress(); reduceCopier.checkAndInformJobTracker(5, tid, false); verify(mockTaskReporter, times(2)).progress(); reduceCopier.checkAndInformJobTracker(6, tid, false); verify(mockTaskReporter, times(3)).progress(); // test readError and its config reduceCopier.checkAndInformJobTracker(7, tid, true); verify(mockTaskReporter, times(4)).progress(); conf.setBoolean("mapreduce.reduce.shuffle.notify.readerror", false); rTask.setConf(conf); reduceCopier = rTask.new TestReduceCopier(mockUmbilical, conf, mockTaskReporter); reduceCopier.checkAndInformJobTracker(7, tid, true); verify(mockTaskReporter, times(4)).progress(); }
Example 5
Source File: HadoopTeraSortTest.java From ignite with Apache License 2.0 | 2 votes |
/** * Does actual test TeraSort job Through Ignite API * * @param gzip Whether to use GZIP. */ protected final void teraSort(boolean gzip) throws Exception { System.out.println("TeraSort ==============================================================="); getFileSystem().delete(new Path(sortOutDir), true); final JobConf jobConf = new JobConf(); jobConf.setUser(getUser()); jobConf.set("fs.defaultFS", getFsBase()); log().info("Desired number of reduces: " + numReduces()); jobConf.set("mapreduce.job.reduces", String.valueOf(numReduces())); log().info("Desired number of maps: " + numMaps()); final long splitSize = dataSizeBytes() / numMaps(); log().info("Desired split size: " + splitSize); // Force the split to be of the desired size: jobConf.set("mapred.min.split.size", String.valueOf(splitSize)); jobConf.set("mapred.max.split.size", String.valueOf(splitSize)); jobConf.setBoolean(HadoopJobProperty.SHUFFLE_MAPPER_STRIPED_OUTPUT.propertyName(), true); jobConf.setInt(HadoopJobProperty.SHUFFLE_MSG_SIZE.propertyName(), 4096); if (gzip) jobConf.setBoolean(HadoopJobProperty.SHUFFLE_MSG_GZIP.propertyName(), true); jobConf.set(HadoopJobProperty.JOB_PARTIALLY_RAW_COMPARATOR.propertyName(), TextPartiallyRawComparator.class.getName()); Job job = setupConfig(jobConf); HadoopJobId jobId = new HadoopJobId(UUID.randomUUID(), 1); IgniteInternalFuture<?> fut = grid(0).hadoop().submit(jobId, createJobInfo(job.getConfiguration(), null)); fut.get(); }
Example 6
Source File: HadoopAbstractMapReduceTest.java From ignite with Apache License 2.0 | 2 votes |
/** * Does actual test job * * @param useNewMapper flag to use new mapper API. * @param useNewCombiner flag to use new combiner API. * @param useNewReducer flag to use new reducer API. */ protected final void doTest(IgfsPath inFile, boolean useNewMapper, boolean useNewCombiner, boolean useNewReducer) throws Exception { log.info("useNewMapper=" + useNewMapper + ", useNewCombiner=" + useNewCombiner + ", useNewReducer=" + useNewReducer); igfs.delete(new IgfsPath(PATH_OUTPUT), true); JobConf jobConf = new JobConf(); jobConf.set(HadoopCommonUtils.JOB_COUNTER_WRITER_PROPERTY, IgniteHadoopFileSystemCounterWriter.class.getName()); jobConf.setUser(USER); jobConf.set(IgniteHadoopFileSystemCounterWriter.COUNTER_WRITER_DIR_PROPERTY, "/xxx/${USER}/zzz"); //To split into about 40 items for v2 jobConf.setInt(FileInputFormat.SPLIT_MAXSIZE, 65000); //For v1 jobConf.setInt("fs.local.block.size", 65000); // File system coordinates. setupFileSystems(jobConf); HadoopWordCount1.setTasksClasses(jobConf, !useNewMapper, !useNewCombiner, !useNewReducer); Job job = Job.getInstance(jobConf); HadoopWordCount2.setTasksClasses(job, useNewMapper, useNewCombiner, useNewReducer, compressOutputSnappy()); job.setOutputKeyClass(Text.class); job.setOutputValueClass(IntWritable.class); FileInputFormat.setInputPaths(job, new Path(igfsScheme() + inFile.toString())); FileOutputFormat.setOutputPath(job, new Path(igfsScheme() + PATH_OUTPUT)); job.setJarByClass(HadoopWordCount2.class); HadoopJobId jobId = new HadoopJobId(UUID.randomUUID(), 1); IgniteInternalFuture<?> fut = grid(0).hadoop().submit(jobId, createJobInfo(job.getConfiguration(), null)); fut.get(); checkJobStatistics(jobId); final String outFile = PATH_OUTPUT + "/" + (useNewReducer ? "part-r-" : "part-") + "00000"; checkOwner(new IgfsPath(PATH_OUTPUT + "/" + "_SUCCESS")); checkOwner(new IgfsPath(outFile)); String actual = readAndSortFile(outFile, job.getConfiguration()); assertEquals("Use new mapper: " + useNewMapper + ", new combiner: " + useNewCombiner + ", new reducer: " + useNewReducer, "blue\t" + blue + "\n" + "green\t" + green + "\n" + "red\t" + red + "\n" + "yellow\t" + yellow + "\n", actual ); }