c# - 关于使用Hadoop.WebHDFSClient时文件创建的403,尽管能够在HDFS中创建文件夹

标签 c# hadoop azure-hdinsight webhdfs

此代码将一直工作到创建文件夹然后无法创建文件并抛出403为止。我是否在此处缺少用于身份验证的内容。我是Hadoop的新手,正在尝试学习hdInsight。

    private static void uploadFile()
    {
        //set variables
        string srcFileName = @"./prime/in/integers.txt";
        string destFolderName = @"/prime/in";
        string destFileName = @"integers.txt";
        string outputFolderName= @"/prime/out";
        //connect to hadoop cluster
        Uri myUri = new Uri("http://DXPZN72-LP:50070");
        string userName = "hadoop";
        WebHDFSClient myClient = new WebHDFSClient(myUri, userName);

        //drop destination directory (if exists)
        myClient.DeleteDirectory(destFolderName, true).Wait();

        //create destination directory
        myClient.CreateDirectory(destFolderName).Wait();

        //create outputFolderName directory
        myClient.CreateDirectory(outputFolderName).Wait();

        //load file to destination directory
        var res= myClient.CreateFile(srcFileName,  "/" +destFileName);
        res.Wait();
        //list file contents of destination directory
        Console.WriteLine();
        Console.WriteLine("Contents of " +destFolderName);

        myClient.GetDirectoryStatus(destFolderName).ContinueWith(
             ds => ds.Result.Files.ToList().ForEach(
             f => Console.WriteLine("t" +f.PathSuffix)
             ));

        //keep command window open until user presses enter
        Console.ReadLine();
    }

最佳答案

发现这是需要重新启动的服务。虽然我可以创建文件夹,但无法使用403创建文件。

我重新启动计算机,然后再次尝试,问题消失了,我也能够创建文件。

关于c# - 关于使用Hadoop.WebHDFSClient时文件创建的403,尽管能够在HDFS中创建文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38081934/

相关文章:

azure - HDInsight 和 Azure 表存储

c# - 奇怪的错误! HdInsight Hadoop MapReduce失败,代码为255

javascript - 将 C# 字符串分配给 Javascript 变量

hadoop - Pyspark Mac NativeCodeLoader : Unable to load native-hadoop library for your platform. .. 在适用的情况下使用内置 java 类

android - 如何从android调用服务器IP地址

hadoop - 启动节点管理器时出错

c# - 如何使用 C# Asp.net 将 Crystal Report 直接打印到客户端机器

c# - 非静态类中私有(private)静态变量的范围

C# Generics - 根据对象类型找到正确的具体类

azure - 如何将spark-csv包添加到Azure上的jupyter服务器以与iPython一起使用