C# HDInsight与Azure Blob存储
我一直在努力让这个工作了一段时间,现在,所以会感谢一些帮助。我正在使用以下工具:C# HDInsight与Azure Blob存储,c#,azure,azure-storage-blobs,azure-hdinsight,cortana-intelligence,C#,Azure,Azure Storage Blobs,Azure Hdinsight,Cortana Intelligence,我一直在努力让这个工作了一段时间,现在,所以会感谢一些帮助。我正在使用以下工具: HDInsight仿真器 已在core-site.xml中将emulator的默认文件系统设置为指向我的Azure存储帐户 当我部署到HDInsight cluter时,问题就开始了。它完美地上传了映射程序,然后出于某种原因返回一个HTTP404,但我不知道为什么。为了调试,我决定使用wasb将我的HDInsight emulator指向我的Azure存储帐户,希望得到一个更具描述性的错误。我这样做了,得到的错误
- HDInsight仿真器
- 已在core-site.xml中将emulator的默认文件系统设置为指向我的Azure存储帐户
- 当我部署到HDInsight cluter时,问题就开始了。它完美地上传了映射程序,然后出于某种原因返回一个HTTP404,但我不知道为什么。为了调试,我决定使用wasb将我的HDInsight emulator指向我的Azure存储帐户,希望得到一个更具描述性的错误。我这样做了,得到的错误如下:java.io.exception:不完整的HDFS URI,没有主机:dhfs“///user/faheem/dotnetcli。。。我知道我的默认文件系统正在连接azure,因为当我浏览azure存储时,我看到我的本地计算机已上载映射程序代码。在那之后就爆炸了。另外,当连接到没有azure blob存储(即本机HDFS文件系统)的模拟器时,我的map reduce代码也能正常工作。请帮忙李>
- 我的代码是一个hello world应用程序,如下所示
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Microsoft.Hadoop.MapReduce; namespace ZA_Provinces_Vertices_Test { internal class Program { private static Uri _azureCluster = new Uri(""); private static string _clusterUserName = ""; private static string _clusterPassword = ""; private static string _hadoopUserName = ""; // Azure Storage Information. private static string _azureStorageAccount = "storage.blob.core.windows.net"; private static string _azureStorageKey = "{Key}"; private static string _azureStorageContainer = "storagecontainer"; private static bool _createContinerIfNotExist = false; private static bool _cloudIndicator = false; private static void Main(string[] args) { //var result = ProvinceShapeFile.PointInProvince(26.6337895, -27.7573934);//Longitude, Latitude //Console.WriteLine(result); //Console.ReadLine(); //var inputArray = new[] //{ // "200000000|23.168|-27.504", // "200000001|23.169|-27.504" //}; IHadoop hadoop; hadoop = _cloudIndicator ? ConnectAzure() : ConnectLocal(); var result = hadoop.MapReduceJob.ExecuteJob<MyCustomHadoopJob>(); //var output = StreamingUnit.Execute<MyCustomMapper>(inputArray); //foreach (var mapperResult in output.MapperResult) //{ // Console.WriteLine(mapperResult); //} } private static IHadoop ConnectLocal() { return Hadoop.Connect(); } private static IHadoop ConnectAzure() { return Hadoop.Connect(_azureCluster, _clusterUserName, _hadoopUserName, _clusterPassword, _azureStorageAccount, _azureStorageKey, _azureStorageContainer, _createContinerIfNotExist); } private static HadoopJobConfiguration LocalConfig() { HadoopJobConfiguration config = new HadoopJobConfiguration(); config.InputPath = "Input/sqrt"; config.OutputFolder = "Output/sqrt"; config.DeleteOutputFolder = true; return config; } private static HadoopJobConfiguration AzureConfig() { HadoopJobConfiguration config = new HadoopJobConfiguration(); config.InputPath = "wasb://{container}@{storage}.blob.core.windows.net/user/faheem/ZAProvinceFromPoint/Input"; config.OutputFolder = "wasb://{container}@{storage}.blob.core.windows.net/user/faheem/ZAProvinceFromPoint/Output"; config.DeleteOutputFolder = false; config.DeleteOutputFolder = false; return config; } public class MyCustomHadoopJob : HadoopJob<MyCustomMapper> { public override HadoopJobConfiguration Configure(ExecutorContext context) { //return _cloudIndicator ? AzureConfig() : LocalConfig(); return AzureConfig(); } } public class MyCustomMapper : MapperBase { public override void Map(string inputLine, MapperContext context) { var fields = inputLine.Split(new[] {"|"}, StringSplitOptions.None).ToList(); double longitude = double.Parse(fields[1]); double latitude = double.Parse(fields[2]); string label = "Dummy"; //ProvinceShapeFile.PointInProvince(longitude, latitude); string processedLine = String.Format("{0}|{1}", inputLine, label); context.EmitKeyValue(processedLine, null); //throw new NotImplementedException(); } } } }
使用系统; 使用System.Collections.Generic; 使用System.Linq; 使用系统文本; 使用System.Threading.Tasks; 使用Microsoft.Hadoop.MapReduce; 名称空间ZA_省\u顶点\u测试 { 内部课程计划 { 私有静态Uri_azureCluster=新Uri(“”); 私有静态字符串_clusterUserName=“”; 私有静态字符串_clusterPassword=“”; 私有静态字符串_hadoopUserName=“”; //Azure存储信息。 私有静态字符串\u azureStorageAccount=“storage.blob.core.windows.net”; 私有静态字符串\u azureStorageKey= “{Key}”; 私有静态字符串\u azureStorageContainer=“storagecontainer”; 私有静态bool_createContinerIfNotExist=false; 私有静态bool_cloudIndicator=false; 私有静态void Main(字符串[]args) { //var result=ProvinceShapeFile.PointInProvince(26.6337895,-27.7573934);//经度,纬度 //控制台写入线(结果); //Console.ReadLine(); //var inputArray=new[] //{ // "200000000|23.168|-27.504", // "200000001|23.169|-27.504" //}; IHadoop-hadoop; hadoop=_cloudIndicator?ConnectAzure():ConnectLocal(); var result=hadoop.MapReduceJob.ExecuteJob(); //var输出=StreamingUnit.Execute(inputArray); //foreach(output.mapperResult中的var mapperResult) //{ //Console.WriteLine(mapperResult); //} } 私有静态IHadoop ConnectLocal() { 返回Hadoop.Connect(); } 私有静态IHadoop ConnectAzure() { 返回Hadoop.Connect(_azureCluster, _clusterUserName, _Hadoop用户名, _clusterPassword, _azureStorageAccount, _azureStorageKey, _azureStorageContainer, _createContinerIfNotExist); } 私有静态HadoopJobConfiguration LocalConfig() { HadoopJobConfiguration=新的HadoopJobConfiguration(); config.InputPath=“输入/sqrt”; config.OutputFolder=“Output/sqrt”; config.DeleteOutputFolder=true; 返回配置; } 私有静态HadoopJobConfiguration AzureConfig() { HadoopJobConfiguration=新的HadoopJobConfiguration(); config.InputPath= “wasb://{container}@{storage}.blob.core.windows.net/user/faheem/ZAProvinceFromPoint/Input”; config.OutputFolder= “wasb://{container}@{storage}.blob.core.windows.net/user/faheem/ZAProvinceFromPoint/Output”; config.DeleteOutputFolder=false; config.DeleteOutputFolder=false; 返回配置; } 公共类MyCustomHadoopJob:HadoopJob { 公共覆盖HadoopJobConfiguration配置(ExecutorContext上下文) { //返回_cloudIndicator?AzureConfig():LocalConfig(); 返回AzureConfig(); } } 公共类MyCustomMapper:MapperBase { 公共覆盖无效映射(字符串输入行,MapperContext上下文) { var fields=inputLine.Split(new[]{“|”},StringSplitOptions.None).ToList(); double longitude=double.Parse(字段[1]); 双纬度=double.Parse(字段[2]); string label=“Dummy”//ProvinceShapeFile.PointInProvince(经度、纬度); string processedLine=string.Format(“{0}{1}”,inputLine,label); EmitKeyValue(processedLine,null); //抛出新的NotImplementedException(); } } } }