// Operate on a backup tablet. Shutdown mysqld and copy the data files aside. func (ta *TabletActor) snapshot(actionNode *ActionNode) error { args := actionNode.args.(*SnapshotArgs) tablet, err := ta.ts.GetTablet(ta.tabletAlias) if err != nil { return err } if tablet.Type != topo.TYPE_BACKUP { return fmt.Errorf("expected backup type, not %v: %v", tablet.Type, ta.tabletAlias) } filename, slaveStartRequired, readOnly, err := ta.mysqld.CreateSnapshot(tablet.DbName(), tablet.Addr, false, args.Concurrency, args.ServerMode, map[string]string{"TABLET_ALIAS": ta.tabletAlias.String()}) if err != nil { return err } sr := &SnapshotReply{ManifestPath: filename, SlaveStartRequired: slaveStartRequired, ReadOnly: readOnly} if tablet.Parent.Uid == topo.NO_TABLET { // If this is a master, this will be the new parent. // FIXME(msolomon) this doesn't work in hierarchical replication. sr.ParentAlias = tablet.Alias() sr.ZkParentPath = tablet.Path() // XXX } else { sr.ParentAlias = tablet.Parent sr.ZkParentPath = zktopo.TabletPathForAlias(tablet.Parent) // XXX } actionNode.reply = sr return nil }
func (ai *ActionInitiator) Restore(dstTabletAlias topo.TabletAlias, args *RestoreArgs) (actionPath string, err error) { args.ZkSrcTabletPath = zktopo.TabletPathForAlias(args.SrcTabletAlias) // XXX args.ZkParentPath = zktopo.TabletPathForAlias(args.ParentAlias) // XXX return ai.writeTabletAction(dstTabletAlias, &ActionNode{Action: TABLET_ACTION_RESTORE, args: args}) }