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


Golang Gossip.GetNodeDescriptor方法代碼示例

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


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

示例1: newReplicaSlice

// newReplicaSlice creates a replicaSlice from the replicas listed in the range
// descriptor and using gossip to lookup node descriptors. Replicas on nodes
// that are not gossipped are omitted from the result.
func newReplicaSlice(gossip *gossip.Gossip, desc *proto.RangeDescriptor) replicaSlice {
	replicas := make(replicaSlice, 0, len(desc.Replicas))
	for _, r := range desc.Replicas {
		nd, err := gossip.GetNodeDescriptor(r.NodeID)
		if err != nil {
			if log.V(1) {
				log.Infof("node %d is not gossiped: %v", r.NodeID, err)
			}
			continue
		}
		replicas = append(replicas, replicaInfo{
			Replica:  r,
			NodeDesc: nd,
		})
	}
	return replicas
}
開發者ID:nkhuyu,項目名稱:cockroach,代碼行數:20,代碼來源:replica_slice.go

示例2: newReplicaSlice

// newReplicaSlice creates a ReplicaSlice from the replicas listed in the range
// descriptor and using gossip to lookup node descriptors. Replicas on nodes
// that are not gossipped are omitted from the result.
func newReplicaSlice(gossip *gossip.Gossip, desc *roachpb.RangeDescriptor) ReplicaSlice {
	if gossip == nil {
		return nil
	}
	replicas := make(ReplicaSlice, 0, len(desc.Replicas))
	for _, r := range desc.Replicas {
		nd, err := gossip.GetNodeDescriptor(r.NodeID)
		if err != nil {
			if log.V(1) {
				log.Infof(context.TODO(), "node %d is not gossiped: %v", r.NodeID, err)
			}
			continue
		}
		replicas = append(replicas, ReplicaInfo{
			ReplicaDescriptor: r,
			NodeDesc:          nd,
		})
	}
	return replicas
}
開發者ID:yangxuanjia,項目名稱:cockroach,代碼行數:23,代碼來源:replica_slice.go


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