本文整理汇总了Golang中github.com/youtube/vitess/go/vt/topo.TabletInfo.Alias方法的典型用法代码示例。如果您正苦于以下问题:Golang TabletInfo.Alias方法的具体用法?Golang TabletInfo.Alias怎么用?Golang TabletInfo.Alias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/youtube/vitess/go/vt/topo.TabletInfo
的用法示例。
在下文中一共展示了TabletInfo.Alias方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: restartSlavesExternal
func (wr *Wrangler) restartSlavesExternal(slaveTabletMap map[topo.TabletAlias]*topo.TabletInfo, masterTablet, masterElectTablet *topo.TabletInfo, scrapStragglers bool) error {
recorder := concurrency.AllErrorRecorder{}
wg := sync.WaitGroup{}
swrd := tm.SlaveWasRestartedData{
Parent: masterElectTablet.Alias(),
ExpectedMasterAddr: masterElectTablet.MysqlAddr,
ExpectedMasterIpAddr: masterElectTablet.MysqlIpAddr,
ScrapStragglers: scrapStragglers,
}
// do all the slaves
for _, ti := range slaveTabletMap {
wg.Add(1)
go func(ti *topo.TabletInfo) {
recorder.RecordError(wr.slaveWasRestarted(ti, &swrd))
wg.Done()
}(ti)
}
wg.Wait()
// then do the master
recorder.RecordError(wr.slaveWasRestarted(masterTablet, &swrd))
return recorder.Error()
}
示例2: SnapshotSourceEnd
func (wr *Wrangler) SnapshotSourceEnd(tabletAlias topo.TabletAlias, slaveStartRequired, readWrite bool, originalType topo.TabletType) (err error) {
var ti *topo.TabletInfo
ti, err = wr.ts.GetTablet(tabletAlias)
if err != nil {
return
}
var actionPath string
actionPath, err = wr.ai.SnapshotSourceEnd(tabletAlias, &tm.SnapshotSourceEndArgs{slaveStartRequired, !readWrite})
if err != nil {
return
}
// wait for completion, and save the error
err = wr.ai.WaitForCompletion(actionPath, wr.actionTimeout())
if err != nil {
log.Errorf("SnapshotSourceEnd failed (%v), leaving tablet type alone", err)
return
}
if ti.Tablet.Parent.Uid == topo.NO_TABLET {
ti.Tablet.Type = topo.TYPE_MASTER
err = topo.UpdateTablet(wr.ts, ti)
} else {
err = wr.ChangeType(ti.Alias(), originalType, false)
}
return err
}
示例3: slaveWasRestarted
func (wr *Wrangler) slaveWasRestarted(ti *topo.TabletInfo, swrd *tm.SlaveWasRestartedData) (err error) {
log.Infof("slaveWasRestarted(%v)", ti.Alias())
actionPath, err := wr.ai.SlaveWasRestarted(ti.Alias(), swrd)
if err != nil {
return err
}
return wr.ai.WaitForCompletion(actionPath, wr.actionTimeout())
}
示例4: restartSlave
func (wr *Wrangler) restartSlave(ti *topo.TabletInfo, rsd *tm.RestartSlaveData) (err error) {
log.Infof("restart slave %v", ti.Alias())
actionPath, err := wr.ai.RestartSlave(ti.Alias(), rsd)
if err != nil {
return err
}
return wr.ai.WaitForCompletion(actionPath, wr.actionTimeout())
}
示例5: getMasterPosition
func (wr *Wrangler) getMasterPosition(ti *topo.TabletInfo) (*mysqlctl.ReplicationPosition, error) {
actionPath, err := wr.ai.MasterPosition(ti.Alias())
if err != nil {
return nil, err
}
result, err := wr.ai.WaitForCompletionReply(actionPath, wr.actionTimeout())
if err != nil {
return nil, err
}
return result.(*mysqlctl.ReplicationPosition), nil
}
示例6: UpdateTablet
func (tee *Tee) UpdateTablet(tablet *topo.TabletInfo, existingVersion int) (newVersion int, err error) {
if newVersion, err = tee.primary.UpdateTablet(tablet, existingVersion); err != nil {
// failed on primary, not updating secondary
return
}
if _, err := tee.secondary.UpdateTablet(tablet, existingVersion); err != nil {
// not critical enough to fail
relog.Warning("secondary.UpdateTablet(%v) failed: %v", tablet.Alias(), err)
}
return
}
示例7: slaveWasPromoted
func (wr *Wrangler) slaveWasPromoted(ti *topo.TabletInfo) error {
log.Infof("slave was promoted %v", ti.Alias())
actionPath, err := wr.ai.SlaveWasPromoted(ti.Alias())
if err != nil {
return err
}
err = wr.ai.WaitForCompletion(actionPath, wr.actionTimeout())
if err != nil {
return err
}
return nil
}
示例8: demoteMaster
func (wr *Wrangler) demoteMaster(ti *topo.TabletInfo) (*mysqlctl.ReplicationPosition, error) {
log.Infof("demote master %v", ti.Alias())
actionPath, err := wr.ai.DemoteMaster(ti.Alias())
if err != nil {
return nil, err
}
err = wr.ai.WaitForCompletion(actionPath, wr.actionTimeout())
if err != nil {
return nil, err
}
return wr.getMasterPosition(ti)
}
示例9: promoteSlave
func (wr *Wrangler) promoteSlave(ti *topo.TabletInfo) (rsd *tm.RestartSlaveData, err error) {
log.Infof("promote slave %v", ti.Alias())
actionPath, err := wr.ai.PromoteSlave(ti.Alias())
if err != nil {
return
}
result, err := wr.ai.WaitForCompletionReply(actionPath, wr.actionTimeout())
if err != nil {
return
}
rsd = result.(*tm.RestartSlaveData)
return
}
示例10: ExecuteTabletInfoHook
func (wr *Wrangler) ExecuteTabletInfoHook(ti *topo.TabletInfo, hook *hk.Hook) (hookResult *hk.HookResult, err error) {
actionPath, err := wr.ai.ExecuteHook(ti.Alias(), hook)
if err != nil {
return nil, err
}
var hr interface{}
if hr, err = wr.ai.WaitForCompletionReply(actionPath, 10*time.Minute); err != nil {
return nil, err
}
return hr.(*hk.HookResult), nil
}
示例11: UpdateTablet
func (zkts *Server) UpdateTablet(tablet *topo.TabletInfo, existingVersion int) (int, error) {
zkTabletPath := TabletPathForAlias(tablet.Alias())
stat, err := zkts.zconn.Set(zkTabletPath, tablet.Json(), existingVersion)
if err != nil {
if zookeeper.IsError(err, zookeeper.ZBADVERSION) {
err = topo.ErrBadVersion
} else if zookeeper.IsError(err, zookeeper.ZNONODE) {
err = topo.ErrNoNode
}
return 0, err
}
return stat.Version(), nil
}
示例12: reparentShardExternal
func (wr *Wrangler) reparentShardExternal(slaveTabletMap, masterTabletMap map[topo.TabletAlias]*topo.TabletInfo, masterElectTablet *topo.TabletInfo, scrapStragglers bool, acceptSuccessPercents int) error {
// we fix the new master in the replication graph
err := wr.slaveWasPromoted(masterElectTablet)
if err != nil {
// This suggests that the master-elect is dead. This is bad.
return fmt.Errorf("slaveWasPromoted(%v) failed: %v", masterElectTablet, err)
}
// Once the slave is promoted, remove it from our maps
delete(slaveTabletMap, masterElectTablet.Alias())
delete(masterTabletMap, masterElectTablet.Alias())
// then fix all the slaves, including the old master
return wr.restartSlavesExternal(slaveTabletMap, masterTabletMap, masterElectTablet, scrapStragglers, acceptSuccessPercents)
}
示例13: ExecuteOptionalTabletInfoHook
// Execute a hook and returns an error only if the hook failed, not if
// the hook doesn't exist.
func (wr *Wrangler) ExecuteOptionalTabletInfoHook(ti *topo.TabletInfo, hook *hk.Hook) (err error) {
hr, err := wr.ExecuteTabletInfoHook(ti, hook)
if err != nil {
return err
}
if hr.ExitStatus == hk.HOOK_DOES_NOT_EXIST {
log.Infof("Hook %v doesn't exist on tablet %v", hook.Name, ti.Alias())
return nil
}
if hr.ExitStatus != hk.HOOK_SUCCESS {
return fmt.Errorf("Hook %v failed(%v): %v", hook.Name, hr.ExitStatus, hr.Stderr)
}
return nil
}
示例14: finishReparent
func (wr *Wrangler) finishReparent(si *topo.ShardInfo, masterElect *topo.TabletInfo, majorityRestart, leaveMasterReadOnly bool) error {
// If the majority of slaves restarted, move ahead.
if majorityRestart {
if leaveMasterReadOnly {
log.Warningf("leaving master-elect read-only, change with: vtctl SetReadWrite %v", masterElect.Alias())
} else {
log.Infof("marking master-elect read-write %v", masterElect.Alias())
actionPath, err := wr.ai.SetReadWrite(masterElect.Alias())
if err == nil {
err = wr.ai.WaitForCompletion(actionPath, wr.actionTimeout())
}
if err != nil {
log.Warningf("master master-elect read-write failed, leaving master-elect read-only, change with: vtctl SetReadWrite %v", masterElect.Alias())
}
}
} else {
log.Warningf("minority reparent, manual fixes are needed, leaving master-elect read-only, change with: vtctl SetReadWrite %v", masterElect.Alias())
}
// save the new master in the shard info
si.MasterAlias = masterElect.Alias()
if err := wr.ts.UpdateShard(si); err != nil {
log.Errorf("Failed to save new master into shard: %v", err)
return err
}
// We rebuild all the cells, as we may have taken tablets in and
// out of the graph.
log.Infof("rebuilding shard serving graph data")
return wr.rebuildShard(masterElect.Keyspace, masterElect.Shard, nil)
}
示例15: reparentShardExternal
func (wr *Wrangler) reparentShardExternal(slaveTabletMap map[topo.TabletAlias]*topo.TabletInfo, masterTablet, masterElectTablet *topo.TabletInfo, scrapStragglers bool, acceptSuccessPercents int) error {
// we fix the new master in the replication graph
err := wr.slaveWasPromoted(masterElectTablet)
if err != nil {
// This suggests that the master-elect is dead. This is bad.
return fmt.Errorf("slaveWasPromoted(%v) failed: %v", masterElectTablet, err)
}
// Once the slave is promoted, remove it from our map
delete(slaveTabletMap, masterElectTablet.Alias())
// then fix all the slaves, including the old master
err = wr.restartSlavesExternal(slaveTabletMap, masterTablet, masterElectTablet, scrapStragglers, acceptSuccessPercents)
if err != nil {
return err
}
// and rebuild the shard graph. We rebuild all the cells, as
// we may have taken tablets in and out of the graph.
log.Infof("rebuilding shard serving graph data")
return wr.rebuildShard(masterElectTablet.Keyspace, masterElectTablet.Shard, nil)
}