Exemplo n.º 1
0
 public static void WriteHdfs(string jsoncontent, string filepath)
 {
     if (string.IsNullOrEmpty(filepath))
     {
         return;
     }
     try
     {
         IWebHdfsHttpClient hdfsClient = new WebHdfsHttpClient(WebHdfsConfig.WebHdfsUri);
         var create = hdfsClient.Create(filepath, jsoncontent, true).Result;
         _logger.Info("Write Json to HDFS,Path:", create);
     }
     catch (Exception ex)
     {
         _logger.Error("Write Json to HDFS,Error:", ex);
     }
 }
Exemplo n.º 2
0
        private void Test()
        {
            IWebHdfsHttpClient c    = new WebHdfsHttpClient(webHdfsUri);
            string             path = "/tmp/WebHdfsHttpClient/test.txt";
            var create = c.Create(path, testContent, true).Result;

            Console.WriteLine("create:" + create);

            var open = c.Open(path).Result;

            Console.WriteLine("open:" + open);

            c.Append(path, " this is append content").Wait();

            var append = c.Open(path).Result;

            Console.WriteLine("append:" + append);

            var fileStatus = c.GetFileStatus(path).Result;

            Console.WriteLine("GetFileStatus:" + fileStatus.ToString());

            Console.WriteLine("MkDirs:");
            string dir = "/tmp/WebHdfsHttpClient/mk";

            c.MkDirs(dir);

            c.Create(dir + "/test2.txt", testContent, true).Wait();
            c.Create(dir + "/test3.txt", testContent, true).Wait();
            var lst = c.ListStatus(dir);


            c.Delete(path, true);

            Console.ReadLine();
        }