本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.Validate函数的典型用法代码示例。如果您正苦于以下问题:Golang Validate函数的具体用法?Golang Validate怎么用?Golang Validate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Validate函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: validateShard
// FIXME(msolomon) This validate presumes the master is up and running.
// Even when that isn't true, there are validation processes that might be valuable.
func (wr *Wrangler) validateShard(ctx context.Context, keyspace, shard string, pingTablets bool, wg *sync.WaitGroup, results chan<- error) {
shardInfo, err := wr.ts.GetShard(ctx, keyspace, shard)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetShard(%v, %v) failed: %v", keyspace, shard, err)
return
}
aliases, err := topo.FindAllTabletAliasesInShard(ctx, wr.ts, keyspace, shard)
if err != nil {
results <- fmt.Errorf("TopologyServer.FindAllTabletAliasesInShard(%v, %v) failed: %v", keyspace, shard, err)
return
}
tabletMap, _ := topo.GetTabletMap(ctx, wr.ts, aliases)
var masterAlias *pb.TabletAlias
for _, alias := range aliases {
tabletInfo, ok := tabletMap[*alias]
if !ok {
results <- fmt.Errorf("tablet %v not found in map", alias)
continue
}
if tabletInfo.Type == pb.TabletType_MASTER {
if masterAlias != nil {
results <- fmt.Errorf("shard %v/%v already has master %v but found other master %v", keyspace, shard, masterAlias, alias)
} else {
masterAlias = alias
}
}
}
if masterAlias == nil {
results <- fmt.Errorf("no master for shard %v/%v", keyspace, shard)
} else if !topo.TabletAliasEqual(shardInfo.MasterAlias, masterAlias) {
results <- fmt.Errorf("master mismatch for shard %v/%v: found %v, expected %v", keyspace, shard, masterAlias, shardInfo.MasterAlias)
}
for _, alias := range aliases {
wg.Add(1)
go func(alias *pb.TabletAlias) {
defer wg.Done()
if err := topo.Validate(ctx, wr.ts, alias); err != nil {
results <- fmt.Errorf("Validate(%v) failed: %v", alias, err)
} else {
wr.Logger().Infof("tablet %v is valid", alias)
}
}(alias)
}
if pingTablets {
wr.validateReplication(ctx, shardInfo, tabletMap, results)
wr.pingTablets(ctx, tabletMap, wg, results)
}
return
}
开发者ID:anusornc,项目名称:vitess,代码行数:58,代码来源:validator.go
示例2: validateShard
// FIXME(msolomon) This validate presumes the master is up and running.
// Even when that isn't true, there are validation processes that might be valuable.
func (wr *Wrangler) validateShard(keyspace, shard string, pingTablets bool, wg *sync.WaitGroup, results chan<- vresult) {
shardInfo, err := wr.ts.GetShard(keyspace, shard)
if err != nil {
results <- vresult{keyspace + "/" + shard, err}
return
}
aliases, err := topo.FindAllTabletAliasesInShard(wr.ts, keyspace, shard)
if err != nil {
results <- vresult{keyspace + "/" + shard, err}
}
tabletMap, _ := GetTabletMap(wr.ts, aliases)
var masterAlias topo.TabletAlias
for _, alias := range aliases {
tabletInfo, ok := tabletMap[alias]
if !ok {
results <- vresult{alias.String(), fmt.Errorf("tablet not found in map")}
continue
}
if tabletInfo.Parent.Uid == topo.NO_TABLET {
if masterAlias.Cell != "" {
results <- vresult{alias.String(), fmt.Errorf("tablet already has a master %v", masterAlias)}
} else {
masterAlias = alias
}
}
}
if masterAlias.Cell == "" {
results <- vresult{keyspace + "/" + shard, fmt.Errorf("no master for shard")}
} else if shardInfo.MasterAlias != masterAlias {
results <- vresult{keyspace + "/" + shard, fmt.Errorf("master mismatch for shard: found %v, expected %v", masterAlias, shardInfo.MasterAlias)}
}
for _, alias := range aliases {
tabletReplicationPath := masterAlias.String()
if alias != masterAlias {
tabletReplicationPath += "/" + alias.String()
}
wg.Add(1)
go func(alias topo.TabletAlias) {
results <- vresult{tabletReplicationPath, topo.Validate(wr.ts, alias, tabletReplicationPath)}
wg.Done()
}(alias)
}
if pingTablets {
wr.validateReplication(shardInfo, tabletMap, results)
wr.pingTablets(tabletMap, wg, results)
}
return
}
开发者ID:Eric-Chen,项目名称:vitess,代码行数:57,代码来源:validator.go
示例3: validateAllTablets
// Validate all tablets in all discoverable cells, even if they are
// not in the replication graph.
func (wr *Wrangler) validateAllTablets(ctx context.Context, wg *sync.WaitGroup, results chan<- error) {
cellSet := make(map[string]bool, 16)
keyspaces, err := wr.ts.GetKeyspaces(ctx)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetKeyspaces failed: %v", err)
return
}
for _, keyspace := range keyspaces {
shards, err := wr.ts.GetShardNames(ctx, keyspace)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetShardNames(%v) failed: %v", keyspace, err)
return
}
for _, shard := range shards {
aliases, err := topo.FindAllTabletAliasesInShard(ctx, wr.ts, keyspace, shard)
if err != nil {
results <- fmt.Errorf("TopologyServer.FindAllTabletAliasesInShard(%v, %v) failed: %v", keyspace, shard, err)
return
}
for _, alias := range aliases {
cellSet[alias.Cell] = true
}
}
}
for cell := range cellSet {
aliases, err := wr.ts.GetTabletsByCell(ctx, cell)
if err != nil {
results <- fmt.Errorf("TopologyServer.GetTabletsByCell(%v) failed: %v", cell, err)
continue
}
for _, alias := range aliases {
wg.Add(1)
go func(alias *pb.TabletAlias) {
defer wg.Done()
if err := topo.Validate(ctx, wr.ts, alias); err != nil {
results <- fmt.Errorf("Validate(%v) failed: %v", alias, err)
} else {
wr.Logger().Infof("tablet %v is valid", alias)
}
}(alias)
}
}
}
开发者ID:anusornc,项目名称:vitess,代码行数:49,代码来源:validator.go
示例4: validateAllTablets
// Validate all tablets in all discoverable cells, even if they are
// not in the replication graph.
func (wr *Wrangler) validateAllTablets(wg *sync.WaitGroup, results chan<- vresult) {
cellSet := make(map[string]bool, 16)
keyspaces, err := wr.ts.GetKeyspaces()
if err != nil {
results <- vresult{"TopologyServer.GetKeyspaces", err}
return
}
for _, keyspace := range keyspaces {
shards, err := wr.ts.GetShardNames(keyspace)
if err != nil {
results <- vresult{"TopologyServer.GetShardNames(" + keyspace + ")", err}
return
}
for _, shard := range shards {
aliases, err := topo.FindAllTabletAliasesInShard(wr.ts, keyspace, shard)
if err != nil {
results <- vresult{"TopologyServer.FindAllTabletAliasesInShard(" + keyspace + "," + shard + ")", err}
return
}
for _, alias := range aliases {
cellSet[alias.Cell] = true
}
}
}
for cell := range cellSet {
aliases, err := wr.ts.GetTabletsByCell(cell)
if err != nil {
results <- vresult{"GetTabletsByCell(" + cell + ")", err}
} else {
for _, alias := range aliases {
wg.Add(1)
go func(alias topo.TabletAlias) {
results <- vresult{alias.String(), topo.Validate(wr.ts, alias)}
wg.Done()
}(alias)
}
}
}
}
开发者ID:ZhuoRoger,项目名称:vitess,代码行数:45,代码来源:validator.go
示例5: verifyTopology
func (agent *ActionAgent) verifyTopology(ctx context.Context) {
if err := topo.Validate(ctx, agent.TopoServer, agent.TabletAlias); err != nil {
// Don't stop, it's not serious enough, this is likely transient.
log.Warningf("tablet validate failed: %v %v", agent.TabletAlias, err)
}
}
开发者ID:dumbunny,项目名称:vitess,代码行数:6,代码来源:action_agent.go
注:本文中的github.com/youtube/vitess/go/vt/topo.Validate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论