当前位置: 首页>>代码示例>>Golang>>正文


Golang Gossip.GetInfo方法代码示例

本文整理汇总了Golang中github.com/cockroachdb/cockroach/gossip.Gossip.GetInfo方法的典型用法代码示例。如果您正苦于以下问题:Golang Gossip.GetInfo方法的具体用法?Golang Gossip.GetInfo怎么用?Golang Gossip.GetInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cockroachdb/cockroach/gossip.Gossip的用法示例。


在下文中一共展示了Gossip.GetInfo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: computeSplitKeys

// computeSplitKeys returns an array of keys at which the supplied
// range should be split, as computed by intersecting the range with
// accounting and zone config map boundaries.
func computeSplitKeys(g *gossip.Gossip, rng *Range) []proto.Key {
	// Now split the range into pieces by intersecting it with the
	// boundaries of the config map.
	splitKeys := proto.KeySlice{}
	for _, configKey := range []string{gossip.KeyConfigAccounting, gossip.KeyConfigZone} {
		info, err := g.GetInfo(configKey)
		if err != nil {
			log.Errorf("unable to fetch %s config from gossip: %s", configKey, err)
			continue
		}
		configMap := info.(PrefixConfigMap)
		splits, err := configMap.SplitRangeByPrefixes(rng.Desc().StartKey, rng.Desc().EndKey)
		if err != nil {
			log.Errorf("unable to split %s by prefix map %s", rng, configMap)
			continue
		}
		// Gather new splits.
		for _, split := range splits {
			if split.end.Less(rng.Desc().EndKey) {
				splitKeys = append(splitKeys, split.end)
			}
		}
	}

	// Sort and unique the combined split keys from intersections with
	// both the accounting and zone config maps.
	sort.Sort(splitKeys)
	var unique []proto.Key
	for i, key := range splitKeys {
		if i == 0 || !key.Equal(splitKeys[i-1]) {
			unique = append(unique, key)
		}
	}
	return unique
}
开发者ID:Hellblazer,项目名称:cockroach,代码行数:38,代码来源:split_queue.go

示例2: lookupZoneConfig

// lookupZoneConfig returns the zone config matching the range.
func lookupZoneConfig(g *gossip.Gossip, rng *Range) (proto.ZoneConfig, error) {
	zoneMap, err := g.GetInfo(gossip.KeyConfigZone)
	if err != nil || zoneMap == nil {
		return proto.ZoneConfig{}, util.Errorf("unable to lookup zone config for range %s: %s", rng, err)
	}
	prefixConfig := zoneMap.(PrefixConfigMap).MatchByPrefix(rng.Desc().StartKey)
	return *prefixConfig.Config.(*proto.ZoneConfig), nil
}
开发者ID:Hellblazer,项目名称:cockroach,代码行数:9,代码来源:split_queue.go

示例3: storeDescFromGossip

// storeDescFromGossip retrieves a StoreDescriptor from the specified
// capacity gossip key. Returns an error if the gossip doesn't exist
// or is not a StoreDescriptor.
func storeDescFromGossip(key string, g *gossip.Gossip) (*proto.StoreDescriptor, error) {
	info, err := g.GetInfo(key)

	if err != nil {
		return nil, err
	}
	storeDesc, ok := info.(proto.StoreDescriptor)
	if !ok {
		return nil, fmt.Errorf("gossiped info is not a StoreDescriptor: %+v", info)
	}
	return &storeDesc, nil
}
开发者ID:huaxling,项目名称:cockroach,代码行数:15,代码来源:allocator.go


注:本文中的github.com/cockroachdb/cockroach/gossip.Gossip.GetInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。