示例#1
0
        /// <summary>Configure mapred-local dirs.</summary>
        /// <remarks>
        /// Configure mapred-local dirs. This config is used by the task for finding
        /// out an output directory.
        /// </remarks>
        /// <exception cref="System.IO.IOException"></exception>
        private static void ConfigureLocalDirs(Task task, JobConf job)
        {
            string[] localSysDirs = StringUtils.GetTrimmedStrings(Runtime.Getenv(ApplicationConstants.Environment
                                                                                 .LocalDirs.ToString()));
            job.SetStrings(MRConfig.LocalDir, localSysDirs);
            Log.Info(MRConfig.LocalDir + " for child: " + job.Get(MRConfig.LocalDir));
            LocalDirAllocator lDirAlloc = new LocalDirAllocator(MRConfig.LocalDir);
            Path workDir = null;

            // First, try to find the JOB_LOCAL_DIR on this host.
            try
            {
                workDir = lDirAlloc.GetLocalPathToRead("work", job);
            }
            catch (DiskChecker.DiskErrorException)
            {
            }
            // DiskErrorException means dir not found. If not found, it will
            // be created below.
            if (workDir == null)
            {
                // JOB_LOCAL_DIR doesn't exist on this host -- Create it.
                workDir = lDirAlloc.GetLocalPathForWrite("work", job);
                FileSystem lfs     = FileSystem.GetLocal(job).GetRaw();
                bool       madeDir = false;
                try
                {
                    madeDir = lfs.Mkdirs(workDir);
                }
                catch (FileAlreadyExistsException)
                {
                    // Since all tasks will be running in their own JVM, the race condition
                    // exists where multiple tasks could be trying to create this directory
                    // at the same time. If this task loses the race, it's okay because
                    // the directory already exists.
                    madeDir = true;
                    workDir = lDirAlloc.GetLocalPathToRead("work", job);
                }
                if (!madeDir)
                {
                    throw new IOException("Mkdirs failed to create " + workDir.ToString());
                }
            }
            job.Set(MRJobConfig.JobLocalDir, workDir.ToString());
        }
示例#2
0
        public virtual void TestProviderApi()
        {
            LocalDirAllocator mockLocalDirAllocator = Org.Mockito.Mockito.Mock <LocalDirAllocator
                                                                                >();
            JobConf mockJobConf = Org.Mockito.Mockito.Mock <JobConf>();

            try
            {
                mockLocalDirAllocator.GetLocalPathToRead(string.Empty, mockJobConf);
            }
            catch (Exception e)
            {
                NUnit.Framework.Assert.IsTrue("Threw exception:" + e, false);
            }
        }
示例#3
0
 /// <summary>Return the path to local map output file created earlier</summary>
 /// <returns>path</returns>
 /// <exception cref="System.IO.IOException"/>
 public override Path GetOutputFile()
 {
     return(lDirAlloc.GetLocalPathToRead(MRJobConfig.Output + Path.Separator + MapOutputFilenameString
                                         , GetConf()));
 }
示例#4
0
        /// <summary>Return the path to local map output file created earlier</summary>
        /// <returns>path</returns>
        /// <exception cref="System.IO.IOException"/>
        public override Path GetOutputFile()
        {
            Path attemptOutput = new Path(GetAttemptOutputDir(), MapOutputFilenameString);

            return(lDirAlloc.GetLocalPathToRead(attemptOutput.ToString(), conf));
        }