此代码一直工作到文件夹创建无法创建文件并抛出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();
}
1条答案
按热度按时间vnzz0bqm1#
发现这是一个需要重新启动的服务。虽然我可以创建文件夹,但无法使用403创建文件。
我重新启动了我的机器,然后再试一次,问题消失了,我也可以创建文件。