Пример #1
0
 /**
  * Prepare the mapred.local.dir for the child. The child is sand-boxed now. Whenever it uses
  * LocalDirAllocator from now on inside the child, it will only see files inside the
  * attempt-directory. This is done in the Child's process space.
  */
 static void setupChildMapredLocalDirs(Task t, JobConf conf) {
   String[] localDirs = conf.getStrings(JobConf.MAPRED_LOCAL_DIR_PROPERTY);
   String jobId = t.getJobID().toString();
   String taskId = t.getTaskID().toString();
   boolean isCleanup = t.isTaskCleanupTask();
   String user = t.getUser();
   StringBuffer childMapredLocalDir =
       new StringBuffer(
           localDirs[0]
               + Path.SEPARATOR
               + TaskTracker.getLocalTaskDir(user, jobId, taskId, isCleanup));
   for (int i = 1; i < localDirs.length; i++) {
     childMapredLocalDir.append(
         ","
             + localDirs[i]
             + Path.SEPARATOR
             + TaskTracker.getLocalTaskDir(user, jobId, taskId, isCleanup));
   }
   LOG.debug("mapred.local.dir for child : " + childMapredLocalDir);
   conf.set("mapred.local.dir", childMapredLocalDir.toString());
 }
 private void startTT(JobConf conf) throws IOException, InterruptedException {
   myClock = new FakeClock(); // clock is reset.
   String localdirs = TEST_ROOT_DIR + "/userlogs/local/0," + TEST_ROOT_DIR + "/userlogs/local/1";
   conf.set(JobConf.MAPRED_LOCAL_DIR_PROPERTY, localdirs);
   tt = new TaskTracker();
   tt.setConf(new JobConf(conf));
   LocalDirAllocator localDirAllocator = new LocalDirAllocator("mapred.local.dir");
   tt.setLocalDirAllocator(localDirAllocator);
   LocalStorage localStorage = new LocalStorage(conf.getLocalDirs());
   localStorage.checkLocalDirs();
   tt.setLocalStorage(localStorage);
   localizer =
       new Localizer(FileSystem.get(conf), conf.getStrings(JobConf.MAPRED_LOCAL_DIR_PROPERTY));
   tt.setLocalizer(localizer);
   userLogManager = new UtilsForTests.InLineUserLogManager(conf);
   TaskController taskController = userLogManager.getTaskController();
   taskController.setup(localDirAllocator, localStorage);
   tt.setTaskController(taskController);
   userLogCleaner = userLogManager.getUserLogCleaner();
   userLogCleaner.setClock(myClock);
   tt.setUserLogManager(userLogManager);
   userLogManager.clearOldUserLogs(conf);
 }