/// <summary> /// HBase表 /// </summary> public HTable(string tableName, HBaseClient client, IHostMappingManager hostMappingManager) { _client = client; _hostMappingManager = hostMappingManager; TableName = tableName; EnsureHTableRegions(); }
/// <summary> /// HBase表区域分布管理器 /// </summary> /// <param name="regions">表原始的Region分布范围</param> /// <param name="hostMappingManager">主机名/IP映射管理器</param> /// <exception cref="IPMappingFailException">主机名找不到IP</exception> public HTableRegionManager(Region[] regions, IHostMappingManager hostMappingManager) { _hostMappingManager = hostMappingManager; for (int i = 0; i < regions.Length; i++) { Region region = regions[i]; RegionInfo regionInfo = new RegionInfo { StartKey = region.StartKey, EndKey = region.EndKey, Id = region.Id, Name = region.Name, Version = region.Version, Comparator = _comparator }; string ip = _hostMappingManager.GetIPAddressByHostName(region.ServerName); if (string.IsNullOrEmpty(ip)) { throw new IPMappingFailException("#Couldn't found any IP address can match this host: " + region.ServerName); } regionInfo.Address = new IPEndPoint(IPAddress.Parse(ip), region.Port); _regions.Add(regionInfo); } }