Beispiel #1
0
        private async Task <RegionInfo> FindRegionInfoForRPC(byte[] table, byte[] key, CancellationToken token)
        {
            var result    = default(RegionInfo);
            var searchKey = RegionInfo.CreateRegionSearchKey(table, key);
            var rpc       = new ScanCall(_metaTableName, searchKey, table)
            {
                Families     = _infoFamily,
                CloseScanner = true,
                Reversed     = true,
                NumberOfRows = 1,
                Info         = _metaRegionInfo
            };

            await _metaClient.QueueRPC(rpc);

            var res = await _metaClient.GetRPCResult(rpc.CallId);

            if (res?.Msg is ScanResponse scanResponse)
            {
                result = RegionInfo.ParseFromScanResponse(scanResponse);
            }

            if (result != null)
            {
                _logger.LogInformation($"Find region info :{result.Name.ToUtf8String()}, at {result.Host}:{result.Port}");
            }
            return(result);
        }
Beispiel #2
0
        private RegionInfo GetInfoFromCache(byte[] table, byte[] key)
        {
            if (BinaryComparer.Compare(table, _metaTableName) == 0)
            {
                return(_metaRegionInfo);
            }
            var search = RegionInfo.CreateRegionSearchKey(table, key);
            var info   = _cache.GetInfo(search);

            if (info == null || false == BinaryComparer.Equals(table, info.Table))
            {
                return(null);
            }
            if (info.StopKey.Length > 0 && BinaryComparer.Compare(key, info.StopKey) >= 0)
            {
                return(null);
            }
            return(info);
        }
Beispiel #3
0
        public RegionInfo GetInfo(byte[] table, byte[] key)
        {
            var search = RegionInfo.CreateRegionSearchKey(table, key);

            return(GetInfo(search));
        }