當前位置: 首頁>>代碼示例>>Golang>>正文


Golang RegionInfo.Table方法代碼示例

本文整理匯總了Golang中github.com/tsuna/gohbase/hrpc.RegionInfo.Table方法的典型用法代碼示例。如果您正苦於以下問題:Golang RegionInfo.Table方法的具體用法?Golang RegionInfo.Table怎麽用?Golang RegionInfo.Table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/tsuna/gohbase/hrpc.RegionInfo的用法示例。


在下文中一共展示了RegionInfo.Table方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: establishRegion

func (c *client) establishRegion(originalReg hrpc.RegionInfo, host string, port uint16) {
    var err error
    reg := originalReg
    backoff := backoffStart

    for {
        ctx, _ := context.WithTimeout(context.Background(), regionLookupTimeout)
        if port != 0 && err == nil {
            // If this isn't the admin or meta region, check if a client
            // for this host/port already exists
            if c.clientType != adminClient && reg != c.metaRegionInfo {
                client := c.clients.checkForClient(host, port)
                if client != nil {
                    // There's already a client, add it to the
                    // region and mark it as available.
                    reg.SetClient(client)
                    c.clients.put(client, reg)
                    originalReg.MarkAvailable()
                    return
                }
            }
            // Make this channel buffered so that if we time out we don't
            // block the newRegion goroutine forever.
            ch := make(chan newRegResult, 1)
            var clientType region.ClientType
            if c.clientType == standardClient {
                clientType = region.RegionClient
            } else {
                clientType = region.MasterClient
            }
            go newRegionClient(ctx, ch, clientType, host, port, c.rpcQueueSize, c.flushInterval)

            select {
            case res := <-ch:
                if res.Err == nil {
                    reg.SetClient(res.Client)
                    if c.clientType != adminClient && reg != c.metaRegionInfo {
                        // put will set region client so that as soon as we add
                        // it to the key->region mapping, concurrent readers are
                        // able to find the client
                        c.clients.put(res.Client, reg)
                        if reg != originalReg {
                            removed := c.regions.put(reg)
                            for _, r := range removed {
                                c.clients.del(r)
                            }
                        }
                    }
                    originalReg.MarkAvailable()
                    return
                } else {
                    err = res.Err
                }
            case <-ctx.Done():
                err = ErrDeadline
            }
        }
        if err != nil {
            if err == TableNotFound {
                c.regions.del(originalReg.Name())
                originalReg.MarkAvailable()
                return
            }
            // This will be hit if either there was an error locating the
            // region, or the region was located but there was an error
            // connecting to it.
            backoff, err = sleepAndIncreaseBackoff(ctx, backoff)
            if err != nil {
                continue
            }
        }
        if c.clientType == adminClient {
            host, port, err = c.zkLookup(ctx, c.master)
        } else if reg == c.metaRegionInfo {
            host, port, err = c.zkLookup(ctx, c.meta)
        } else {
            reg, host, port, err = c.locateRegion(ctx, originalReg.Table(),
                originalReg.StartKey())
        }
    }
}
開發者ID:cloudflare,項目名稱:gohbase,代碼行數:81,代碼來源:client.go

示例2: isRegionOverlap

func isRegionOverlap(regA, regB hrpc.RegionInfo) bool {
    return bytes.Equal(regA.Table(), regB.Table()) &&
        bytes.Compare(regA.StartKey(), regB.StopKey()) < 0 &&
        bytes.Compare(regA.StopKey(), regB.StartKey()) > 0
}
開發者ID:cloudflare,項目名稱:gohbase,代碼行數:5,代碼來源:client.go


注:本文中的github.com/tsuna/gohbase/hrpc.RegionInfo.Table方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。