Beispiel #1
0
        public static void test()
        {
            var hadoop_socket = new TSocket("hserver", 59256);

            hadoop_socket.Timeout = 10000;// Ten seconds

            //$hadoop_socket -> setRecvTimeout(20000); // Twenty seconds
            var hadoop_transport = new TBufferedTransport(hadoop_socket);
            var hadoop_protocol  = new TBinaryProtocol(hadoop_transport);
            var hadoopClient     = new ThriftHadoopFileSystem.Client(hadoop_protocol);

            hadoop_transport.Open();

            //if (hadoopClient.exists(new Pathname { pathname = "/user/root/input" }))
            //{
            //    System.Console.WriteLine("exists");
            //}
            //else
            //{
            //    Console.WriteLine("no exists");


            //}

            //hadoopClient.mkdirs(new Pathname { pathname = "/zbw911_user" });
            //hadoopClient.rm(new Pathname { pathname = "/zbw911_user" }, true);

            //var h = hadoopClient.createFile(new Pathname { pathname = "user_zbw911" }, 1, true, 1000, 1, 64000);


            var list = hadoopClient.listStatus(new Pathname {
                pathname = "/user/root"
            });

            foreach (var item in list)
            {
                System.Console.WriteLine(item);
                //if (item.Isdir)
                //{
                //    System.Console.WriteLine("文件夹:" + item.Path + ";权限:" + item.Permission);
                //}
                //else
                //{

                //    System.Console.WriteLine("文件:" + item.Path + ";权限:" + item.Permission);

                //}
            }

            //hadoopClient.close(h);



            //hadoopClient.open(new Pathname { pathname = "/user/root" });

            hadoop_transport.Close();
        }
Beispiel #2
0
        //列表目录
        public List <FileStatus> GetFlolderList(string path)
        {
            TBufferedTransport tsport = null;

            ThriftHadoopFileSystem.Client client = Connect(out tsport);
            List <FileStatus>             result = null; //new List<FileStatus>();

            //客户端可连接 且目录存在
            if (client != null && client.exists(new Pathname {
                pathname = path
            }))
            {
                result = client.listStatus(new Pathname()
                {
                    pathname = path
                });
                tsport.Close();
            }
            return(result);
        }