Example #1
0
        ///<summary>
        ///Removes Directory or file in HDFS
        ///<param name="path">Directory/File path to delete</param>
        ///<returns>HttpStatusCode</returns>
        ///</summary>
        public HttpStatusCode RmDir(string path)
        {
            // Create the final url with params
            string          url_path = "http://" + this.namenodeHost + ":" + this.namenodePort + WEBHDFS_CONTEXT_ROOT + "/" + path + "?op=DELETE&user.name=" + this.hdfsUsername;
            BetterWebClient wc       = new BetterWebClient();

            wc.UploadString(url_path, "DELETE", "");
            return(wc.StatusCode());
        }
Example #2
0
        ///<summary>
        ///Copy file from HDFS to local machine
        ///<param name="sourcePath">Location of file on HDFS, including filename and extension (FullFileName)</param>
        ///<param name="targetPath">Location of file to localhost,including filename and extension (FullFileName) </param>
        ///<returns>HttpStatusCode</returns>
        ///</summary>
        public HttpStatusCode copyToLocal(string sourcePath, string targetPath)
        {
            // Create the final url with params
            string          urlPath = "http://" + this.namenodeHost + ":" + this.namenodePort + WEBHDFS_CONTEXT_ROOT + "/" + sourcePath + "?op=OPEN&overwrite=true&user.name=" + this.hdfsUsername;
            BetterWebClient wc      = new BetterWebClient();

            wc.AllowAutoRedirect = true;
            wc.DownloadFile(urlPath, targetPath);
            return(wc.StatusCode());
        }