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


Golang Wrangler.PlannedReparentShard方法代码示例

本文整理汇总了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)
}
开发者ID:jmptrader,项目名称:vitess,代码行数:19,代码来源:reparent.go

示例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)
}
开发者ID:dumbunny,项目名称:vitess,代码行数:38,代码来源:reparent.go


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