本文整理汇总了Golang中github.com/youtube/vitess/go/vt/wrangler.Wrangler.PlannedReparentShard方法的典型用法代码示例。如果您正苦于以下问题:Golang Wrangler.PlannedReparentShard方法的具体用法?Golang Wrangler.PlannedReparentShard怎么用?Golang Wrangler.PlannedReparentShard使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/wrangler.Wrangler
的用法示例。
在下文中一共展示了Wrangler.PlannedReparentShard方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: commandPlannedReparentShard
func commandPlannedReparentShard(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
waitSlaveTimeout := subFlags.Duration("wait_slave_timeout", 30*time.Second, "time to wait for slaves to catch up in reparenting")
if err := subFlags.Parse(args); err != nil {
return err
}
if subFlags.NArg() != 2 {
return fmt.Errorf("action PlannedReparentShard requires <keyspace/shard> <tablet alias>")
}
keyspace, shard, err := topoproto.ParseKeyspaceShard(subFlags.Arg(0))
if err != nil {
return err
}
tabletAlias, err := topoproto.ParseTabletAlias(subFlags.Arg(1))
if err != nil {
return err
}
return wr.PlannedReparentShard(ctx, keyspace, shard, tabletAlias, *waitSlaveTimeout)
}
示例2: commandPlannedReparentShard
func commandPlannedReparentShard(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error {
waitSlaveTimeout := subFlags.Duration("wait_slave_timeout", 30*time.Second, "time to wait for slaves to catch up in reparenting")
keyspaceShard := subFlags.String("keyspace_shard", "", "keyspace/shard of the shard that needs to be reparented")
newMaster := subFlags.String("new_master", "", "alias of a tablet that should be the new master")
avoidMaster := subFlags.String("avoid_master", "", "alias of a tablet that should not be the master, i.e. reparent to any other tablet if this one is the master")
if err := subFlags.Parse(args); err != nil {
return err
}
if subFlags.NArg() == 2 {
// Legacy syntax: "<keyspace/shard> <tablet alias>".
if *keyspaceShard != "" || *newMaster != "" {
return fmt.Errorf("cannot use legacy syntax and flags -keyspace_shard and -new_master for action PlannedReparentShard at the same time")
}
*keyspaceShard = subFlags.Arg(0)
*newMaster = subFlags.Arg(1)
} else if subFlags.NArg() != 0 {
return fmt.Errorf("action PlannedReparentShard requires -keyspace_shard=<keyspace/shard> [-new_master=<tablet alias>] [-avoid_master=<tablet alias>]")
}
keyspace, shard, err := topoproto.ParseKeyspaceShard(*keyspaceShard)
if err != nil {
return err
}
var newMasterAlias, avoidMasterAlias *topodatapb.TabletAlias
if *newMaster != "" {
newMasterAlias, err = topoproto.ParseTabletAlias(*newMaster)
if err != nil {
return err
}
}
if *avoidMaster != "" {
avoidMasterAlias, err = topoproto.ParseTabletAlias(*avoidMaster)
if err != nil {
return err
}
}
return wr.PlannedReparentShard(ctx, keyspace, shard, newMasterAlias, avoidMasterAlias, *waitSlaveTimeout)
}