本文整理汇总了Golang中github.com/couchbase/indexing/secondary/common.ClusterInfoCache.GetCurrentNode方法的典型用法代码示例。如果您正苦于以下问题:Golang ClusterInfoCache.GetCurrentNode方法的具体用法?Golang ClusterInfoCache.GetCurrentNode怎么用?Golang ClusterInfoCache.GetCurrentNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/couchbase/indexing/secondary/common.ClusterInfoCache
的用法示例。
在下文中一共展示了ClusterInfoCache.GetCurrentNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addPartnInfoToProtoInst
func addPartnInfoToProtoInst(cfg c.Config, cinfo *c.ClusterInfoCache,
indexInst c.IndexInst, streamId c.StreamId, protoInst *protobuf.IndexInst) {
switch partn := indexInst.Pc.(type) {
case *c.KeyPartitionContainer:
//Right now the fill the SinglePartition as that is the only
//partition structure supported
partnDefn := partn.GetAllPartitions()
//TODO move this to indexer init. These addresses cannot change.
//Better to get these once and store.
cinfo.Lock()
defer cinfo.Unlock()
err := cinfo.Fetch()
c.CrashOnError(err)
nid := cinfo.GetCurrentNode()
streamMaintAddr, err := cinfo.GetServiceAddress(nid, "indexStreamMaint")
c.CrashOnError(err)
streamInitAddr, err := cinfo.GetServiceAddress(nid, "indexStreamInit")
c.CrashOnError(err)
streamCatchupAddr, err := cinfo.GetServiceAddress(nid, "indexStreamCatchup")
c.CrashOnError(err)
var endpoints []string
for _, p := range partnDefn {
for _, e := range p.Endpoints() {
//Set the right endpoint based on streamId
switch streamId {
case c.MAINT_STREAM:
e = c.Endpoint(streamMaintAddr)
case c.CATCHUP_STREAM:
e = c.Endpoint(streamCatchupAddr)
case c.INIT_STREAM:
e = c.Endpoint(streamInitAddr)
}
endpoints = append(endpoints, string(e))
}
}
protoInst.SinglePartn = &protobuf.SinglePartition{
Endpoints: endpoints,
}
}
}