此代码一直有效,直到创建文件夹然后无法创建文件并抛出403. am我在这里遗漏了一些用于身份验证的内容。我是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();
}
答案 0 :(得分:0)
发现这是一项需要重新启动的服务。虽然我能够创建文件夹,但无法使用403创建文件。
我重新启动机器然后再次尝试,问题就消失了,我也能够创建文件。