public static void LogToHadoop() { try { //set variables string srcFileName = "C:\\Users\\deepakk\\Desktop\\Log.txt"; string destFolderName = "/log_error"; string destFileName = "err2.txt"; //connect to hadoop cluster Uri myUri = new Uri("http://localhost:50070/"); string userName = "******"; WebHDFSClient myClient = new WebHDFSClient(myUri, userName); //drop destination directory (if exists) myClient.DeleteDirectory(destFolderName, true).Wait(); //create destination directory myClient.CreateDirectory(destFolderName).Wait(); //load file to destination directory myClient.CreateFile(srcFileName, destFolderName + "/" + destFileName).Wait(); //Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("Custom HADOOP " + ex.Message); } }
public static void SaveFile(string srcFileName, string destFolderName, string destFileName, string uri) { try { //connect to hadoop cluster Uri myUri = new Uri(uri); string userName = "******"; WebHDFSClient myClient = new WebHDFSClient(myUri, userName); //drop destination directory (if exists) myClient.DeleteDirectory(destFolderName, true); //create destination directory myClient.CreateDirectory(destFolderName); string newpathfile = destFolderName + "/" + destFileName; //load file to destination directory var s = myClient.CreateFile(srcFileName, newpathfile); Console.WriteLine(s.Result); //keep command window open until user presses enter Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.ToString()); } }
public static void LogToHadoop() { try { //set variables string srcFileName = "C:\\Users\\deepakk\\Desktop\\Log.txt"; string destFolderName = "/log_error"; string destFileName = "err2.txt"; //connect to hadoop cluster Uri myUri = new Uri("http://*****:*****@"C:\Users\Administrator\Desktop\integer.txt", "/user/hadoop/integer.txt") //.ContinueWith(t => Console.WriteLine("new file located at " + t.Result)) //.ContinueWith(t => myClient.OpenFile("/user/hadoop/integer.txt") //.ContinueWith(resp => resp.Result.Content.ReadAsStringAsync() //.ContinueWith(bigString => Console.WriteLine("new file is " + bigString.Result.Length + " bytes long")) //.ContinueWith(t2 => myClient.DeleteDirectory("/user/Administrator/'demosimplenewin'") // .ContinueWith(b => Console.WriteLine("Successfully deleted file.")) // ) // ) // ) // ); //----------------------------------------------------- //keep command window open until user presses enter Console.ReadLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <summary> /// Delete file /// </summary> /// <param name="filePath">filePath</param> /// <returns></returns> public bool DeleteFile(string filePath) { return(_con.DeleteDirectory(filePath).Result); }