• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang topo.EndPointEquality函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.EndPointEquality函数的典型用法代码示例。如果您正苦于以下问题:Golang EndPointEquality函数的具体用法?Golang EndPointEquality怎么用?Golang EndPointEquality使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: TestDiscoveryGatewayGetEndPoints

func TestDiscoveryGatewayGetEndPoints(t *testing.T) {
	keyspace := "ks"
	shard := "0"
	hc := newFakeHealthCheck()
	dg := createDiscoveryGateway(hc, topo.Server{}, nil, "local", time.Millisecond, 2, time.Second, time.Second, time.Second, nil).(*discoveryGateway)

	// replica should only use local ones
	hc.addTestEndPoint("remote", "1.1.1.1", 1001, keyspace, shard, pbt.TabletType_REPLICA, 10, nil, nil)
	ep1 := hc.addTestEndPoint("local", "2.2.2.2", 1001, keyspace, shard, pbt.TabletType_REPLICA, 10, nil, nil)
	eps := dg.getEndPoints(keyspace, shard, pbt.TabletType_REPLICA)
	if len(eps) != 1 || !topo.EndPointEquality(eps[0], ep1) {
		t.Errorf("want %+v, got %+v", ep1, eps[0])
	}

	// master should use the one with newer timestamp regardless of cell
	hc.addTestEndPoint("remote", "1.1.1.1", 1001, keyspace, shard, pbt.TabletType_MASTER, 5, nil, nil)
	ep1 = hc.addTestEndPoint("remote", "2.2.2.2", 1001, keyspace, shard, pbt.TabletType_MASTER, 10, nil, nil)
	eps = dg.getEndPoints(keyspace, shard, pbt.TabletType_MASTER)
	if len(eps) != 1 || !topo.EndPointEquality(eps[0], ep1) {
		t.Errorf("want %+v, got %+v", ep1, eps[0])
	}
}
开发者ID:zhaoyta,项目名称:vitess,代码行数:22,代码来源:discoverygateway_test.go


示例2: updateEndpoint

func updateEndpoint(ctx context.Context, ts topo.Server, cell, keyspace, shard string, tabletType pb.TabletType, endpoint *pb.EndPoint) error {
	return retryUpdateEndpoints(ctx, ts, cell, keyspace, shard, tabletType, true, /* create */
		func(endpoints *pb.EndPoints) bool {
			// Look for an existing entry to update.
			for i := range endpoints.Entries {
				if endpoints.Entries[i].Uid == endpoint.Uid {
					if topo.EndPointEquality(endpoints.Entries[i], endpoint) {
						// The entry already exists and is the same.
						return false
					}
					// Update an existing entry.
					endpoints.Entries[i] = endpoint
					return true
				}
			}
			// The entry doesn't exist, so add it.
			endpoints.Entries = append(endpoints.Entries, endpoint)
			return true
		})
}
开发者ID:khanchan,项目名称:vitess,代码行数:20,代码来源:rebuild.go


示例3: updateTabletEndpoint

func (zkts *Server) updateTabletEndpoint(oldValue string, oldStat zk.Stat, addr *topodatapb.EndPoint) (newValue string, err error) {
	if oldStat == nil {
		// The incoming object doesn't exist - we haven't been placed in the serving
		// graph yet, so don't update. Assume the next process that rebuilds the graph
		// will get the updated tablet location.
		return "", errSkipUpdate
	}

	var addrs *topodatapb.EndPoints
	if oldValue != "" {
		addrs = &topodatapb.EndPoints{}
		if len(oldValue) > 0 {
			if err := json.Unmarshal([]byte(oldValue), addrs); err != nil {
				return "", fmt.Errorf("EndPoints unmarshal failed: %v %v", oldValue, err)
			}
		}

		foundTablet := false
		for i, entry := range addrs.Entries {
			if entry.Uid == addr.Uid {
				foundTablet = true
				if !topo.EndPointEquality(entry, addr) {
					addrs.Entries[i] = addr
				}
				break
			}
		}

		if !foundTablet {
			addrs.Entries = append(addrs.Entries, addr)
		}
	} else {
		addrs = topo.NewEndPoints()
		addrs.Entries = append(addrs.Entries, addr)
	}
	data, err := json.MarshalIndent(addrs, "", "  ")
	if err != nil {
		return "", err
	}
	return string(data), nil
}
开发者ID:aaijazi,项目名称:vitess,代码行数:41,代码来源:serving_graph.go


示例4: deleteEndPointFromTargetProtected

// deleteEndPointFromTargetProtected deletes the endpoint for the given target.
// LOCK_REQUIRED hc.mu
func (hc *HealthCheckImpl) deleteEndPointFromTargetProtected(target *querypb.Target, endPoint *topodatapb.EndPoint) {
	shardMap, ok := hc.targetToEPs[target.Keyspace]
	if !ok {
		return
	}
	ttMap, ok := shardMap[target.Shard]
	if !ok {
		return
	}
	epList, ok := ttMap[target.TabletType]
	if !ok {
		return
	}
	for i, ep := range epList {
		if topo.EndPointEquality(ep, endPoint) {
			epList = append(epList[:i], epList[i+1:]...)
			ttMap[target.TabletType] = epList
			return
		}
	}
}
开发者ID:aaijazi,项目名称:vitess,代码行数:23,代码来源:healthcheck.go


示例5: deleteEndPointFromTargetProtected

// deleteEndPointFromTargetProtected deletes the endpoint for the given target.
// LOCK_REQUIRED hc.mu
func (hc *HealthCheckImpl) deleteEndPointFromTargetProtected(target *pbq.Target, endPoint *pbt.EndPoint) {
	shardMap, ok := hc.targetToEPs[target.Keyspace]
	if !ok {
		return
	}
	ttMap, ok := shardMap[target.Shard]
	if !ok {
		return
	}
	epList, ok := ttMap[target.TabletType]
	if !ok {
		return
	}
	for i, ep := range epList {
		if topo.EndPointEquality(ep, endPoint) {
			epList = append(epList[:i], epList[i+1:]...)
			ttMap[target.TabletType] = epList
			hcConnCounters.Add([]string{target.Keyspace, target.Shard, strings.ToLower(target.TabletType.String())}, -1)
			return
		}
	}
}
开发者ID:zhaoyta,项目名称:vitess,代码行数:24,代码来源:healthcheck.go


示例6: addEndPointToTargetProtected

// addEndPointToTargetProtected adds the endpoint to the given target.
// LOCK_REQUIRED hc.mu
func (hc *HealthCheckImpl) addEndPointToTargetProtected(target *querypb.Target, endPoint *topodatapb.EndPoint) {
	shardMap, ok := hc.targetToEPs[target.Keyspace]
	if !ok {
		shardMap = make(map[string]map[topodatapb.TabletType][]*topodatapb.EndPoint)
		hc.targetToEPs[target.Keyspace] = shardMap
	}
	ttMap, ok := shardMap[target.Shard]
	if !ok {
		ttMap = make(map[topodatapb.TabletType][]*topodatapb.EndPoint)
		shardMap[target.Shard] = ttMap
	}
	epList, ok := ttMap[target.TabletType]
	if !ok {
		epList = make([]*topodatapb.EndPoint, 0, 1)
	}
	for _, ep := range epList {
		if topo.EndPointEquality(ep, endPoint) {
			log.Warningf("endpoint is already added: %+v", endPoint)
			return
		}
	}
	ttMap[target.TabletType] = append(epList, endPoint)
}
开发者ID:aaijazi,项目名称:vitess,代码行数:25,代码来源:healthcheck.go


示例7: addEndPointToTargetProtected

// addEndPointToTargetProtected adds the endpoint to the given target.
// LOCK_REQUIRED hc.mu
func (hc *HealthCheckImpl) addEndPointToTargetProtected(target *pbq.Target, endPoint *pbt.EndPoint) {
	shardMap, ok := hc.targetToEPs[target.Keyspace]
	if !ok {
		shardMap = make(map[string]map[pbt.TabletType][]*pbt.EndPoint)
		hc.targetToEPs[target.Keyspace] = shardMap
	}
	ttMap, ok := shardMap[target.Shard]
	if !ok {
		ttMap = make(map[pbt.TabletType][]*pbt.EndPoint)
		shardMap[target.Shard] = ttMap
	}
	epList, ok := ttMap[target.TabletType]
	if !ok {
		epList = make([]*pbt.EndPoint, 0, 1)
	}
	for _, ep := range epList {
		if topo.EndPointEquality(ep, endPoint) {
			log.Warningf("endpoint is already added: %+v", endPoint)
			return
		}
	}
	ttMap[target.TabletType] = append(epList, endPoint)
	hcConnCounters.Add([]string{target.Keyspace, target.Shard, strings.ToLower(target.TabletType.String())}, 1)
}
开发者ID:zhaoyta,项目名称:vitess,代码行数:26,代码来源:healthcheck.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang topo.FindAllTabletAliasesInShard函数代码示例发布时间:2022-05-28
下一篇:
Golang topo.DeleteTabletReplicationData函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap