首页 文章

C#Map使用“{”减少失败响应状态代码不表示成功:403(禁止) . “}有时401:需要凭据

提问于
浏览
0

mscorlib.dll 中发生 System.AggregateException 类型的未处理异常

内部异常: {"Response status code does not indicate success: 403 (Forbidden)."} 有时会得到: {"Response status code does not indicate success: 401 (Credentials required)."}

所有登录都是正确的 . Hadoop.Connect()正确连接 .

堆栈跟踪:

在System.Threading.Tasks.Task.ThrowIfExceptional(布尔includeTaskCanceledExceptions)在System.Threading.Tasks.Task.Wait(的Int32 millisecondsTimeout,的CancellationToken的CancellationToken)在System.Threading.Tasks.Task.Wait()在Microsoft.Hadoop.WebClient .WebHCatClient.WebHcatMapReduceStreamingExecutor.Execute(Boolean throwOnError)在Microsoft.Hadoop.MapReduce.Execution.Hadoop.StreamingJobExecutorBase的Microsoft.Hadoop.MapReduce.Execution.Hadoop.StreamingJobExecutorBase.ExecuteCore(Type mapper,Type reducer,Type combiner,HadoopJobConfiguration config) . 在Microsoft.Hadoop.MapReduce.Execution.Hadoop.StreamingJobExecutorBase.Execute [TMapper,TReducer](HadoopJobConfiguration配置)在Pwc.Demo.HDPClient.Program.Main(字符串[执行(类型mapperType,类型reducerType,类型combinerType,HadoopJobConfiguration配置) ] args)在C:\ ASC项目信息\ TalentExchange \演示项目\ Pwc.Demo.HDPClient \ Pwc.Demo.HDPClient \ Program.cs:第49行在System.AppDomain._nExecuteAssembly(RuntimeAssembly)组件,字串[] args)在System.AppDomain.ExecuteAssembly(字符串assemblyFile,证据assemblySecurity,字串[] args)在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()在System.Threading.ThreadHelper.ThreadStart_Context(对象状态)在System.Threading.ExecutionContext.RunInternal(的ExecutionContext的ExecutionContext,ContextCallback回调,对象的状态,布尔preserveSyncCtx)在System.Threading.ExecutionContext.Run(的ExecutionContext的ExecutionContext,ContextCallback回调,对象的状态,布尔preserveSyncCtx)在System.Threading.ExecutionContext.Run( System.Threading.ThreadHelper.ThreadStart()中的ExecutionContext executionContext,ContextCallback回调,Object状态)

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);

        }
    }

错误快照:
enter image description here

1 回答

  • 0

    您的输入路径不应该是特定文件,而是目录 . 该目录应该只包含文件而不包含文件夹 .

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

相关问题