NAS
NAS

Reputation: 145

C# Map Reduce failing with "{"Response status code does not indicate success: 403 (Forbidden)."} sometimes 401: credentials required

An unhandled exception of type System.AggregateException occurred in mscorlib.dll

Inner Exception: {"Response status code does not indicate success: 403 (Forbidden)."} sometime get: {"Response status code does not indicate success: 401 (Credentials required)."}

All the logins are correct. Hadoop.Connect() connect properly.

Stack trace:

at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Microsoft.Hadoop.WebClient.WebHCatClient.WebHcatMapReduceStreamingExecutor.Execute(Boolean throwOnError) at Microsoft.Hadoop.MapReduce.Execution.Hadoop.StreamingJobExecutorBase.ExecuteCore(Type mapper, Type reducer, Type combiner, HadoopJobConfiguration config)
at Microsoft.Hadoop.MapReduce.Execution.Hadoop.StreamingJobExecutorBase.Execute(Type mapperType, Type reducerType, Type combinerType, HadoopJobConfiguration config) at Microsoft.Hadoop.MapReduce.Execution.Hadoop.StreamingJobExecutorBase.Execute[TMapper,TReducer](HadoopJobConfiguration config) at Pwc.Demo.HDPClient.Program.Main(String[] args) in C:\ASC Project Info\TalentExchange\Demo project\Pwc.Demo.HDPClient\Pwc.Demo.HDPClient\Program.cs:line 49 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

class Program
       {
            static void Main(string[] args)
           {
              HadoopJobConfiguration myConfig = new   HadoopJobConfiguration();

            myConfig.InputPath = "asv://hdsto-something-.net/data/in/reviews.txt";
            myConfig.OutputFolder = "asv://hd-something-.blob.core.windows.net/data/out/";
            Environment.SetEnvironmentVariable("HADOOP_HOME", @"C:\apps\dist\hadoop-2.7.1.2.3.3.1-25\bin");
            Environment.SetEnvironmentVariable("JAVA_HOME", @"C:\Program Files\Java\jre1.8.0_101\bin\javaw.exe");

            Uri azureCluster = new Uri("https://somename--Demo.azurehdinsight.net");
            string clusterUserName = "***";
            string clusterPassword = "****";

            // This is the name of the account under which Hadoop will execute jobs.
            // Normally this is just "Hadoop".
            string hadoopUserName = "Hadoop";

            // Azure Storage Information.
            string azureStorageAccount = "somestore.blob.core.windows.net";
            string azureStorageKey = "***==";
            string azureStorageContainer = "**";
            bool createContinerIfNotExist = false;

            IHadoop myCluster = Hadoop.Connect(azureCluster,
                                        clusterUserName,
                                        hadoopUserName,
                                        clusterPassword,
                                        azureStorageAccount,
                                        azureStorageKey,
                                        azureStorageContainer,
                                        createContinerIfNotExist);

            //execute mapreduce job

            MapReduceResult jobResult =

                myCluster.MapReduceJob.Execute<MySimpleMapper, MySimpleReducer>(myConfig);

            int exitCode = jobResult.Info.ExitCode;
            string exitStatus = "Failure";
            if (exitCode == 0) exitStatus = "Success";
            exitStatus = exitCode + " (" + exitStatus + ")";
            Console.WriteLine();
            Console.Write("Exit Code = " + exitStatus);
            Console.Read();
        }
    }

    public class MySimpleMapper : MapperBase
    {
        public override void Map(string inputLine, MapperContext context)
        {
            int value = int.Parse(inputLine);
            string key = (value % 2 == 0) ? "even" : "odd";
            context.EmitKeyValue(key, value.ToString());
        }
    }

    public class MySimpleReducer : ReducerCombinerBase
    {
        public override void Reduce(string key, IEnumerable<string> values, ReducerCombinerContext context)
        {
            //initialize counters
            int myCount = 0;
            int mySum = 0;
            //count and sum incoming values
            foreach (string value in values)
            {
                mySum += int.Parse(value);
                myCount++;
            }
            context.EmitKeyValue(key, myCount + "t" + mySum);

        }
    }

Error snapshot: enter image description here

Upvotes: 0

Views: 1592

Answers (1)

Andrew Moll
Andrew Moll

Reputation: 5033

Your input path should not be to a specific file, but a directory. That directory should only contain files and not folders.

myConfig.InputPath = "asv://hdsto-something-.net/data/in/";

Upvotes: 0

Related Questions