Beispiel #1
0
        private HdfsCommandRunner([Parameter(typeof(NumberOfRetries))] int numberOfRetries,
                                  [Parameter(typeof(CommandTimeOut))] int timeOutInMilliSeconds,
                                  [Parameter(typeof(HadoopHome))] string hadoopHome)
        {
            _numberOfRetries       = numberOfRetries;
            _timeOutInMilliSeconds = timeOutInMilliSeconds;

            if (!PathUtilities.AreNormalizedEquals(hadoopHome, HadoopHome.DefaultValue))
            {
                // The user provided a Hadoop Home folder.
                if (Directory.Exists(hadoopHome))
                {
                    // The user provided folder does exist.
                    _hdfsCommandPath = GetFullPathToHdfsCommand(hadoopHome);
                }
                else
                {
                    // The user provided folder does not exist. Try the environment variable.
                    Logger.Log(Level.Warning,
                               "The provided hadoop home folder {0} doesn't exist, trying environment variable {1} instead",
                               hadoopHome, HadoopHomeEnvironmentVariableName);
                    _hdfsCommandPath = GetFullPathToHdfsCommandBasedOnEnvironmentVariable();
                }
            }
            else
            {
                // The user did not provide a Hadoop Home folder. Use the Environment variable.
                _hdfsCommandPath = GetFullPathToHdfsCommandBasedOnEnvironmentVariable();
            }

            // Make sure we found the command.
            if (!File.Exists(_hdfsCommandPath))
            {
                throw new FileNotFoundException("HDFS Command not found", _hdfsCommandPath);
            }
        }