Moving a few things to MysqlDaemon.

This commit is contained in:
Alain Jobart 2015-05-19 15:04:04 -07:00
Родитель b047c8c87f
Коммит b342856305
7 изменённых файлов: 16 добавлений и 7 удалений

Просмотреть файл

@ -70,6 +70,10 @@ type MysqlDaemon interface {
// FetchSuperQuery executes one query, returns the result
FetchSuperQuery(query string) (*mproto.QueryResult, error)
// Close will close this instance of Mysqld. It will wait for all dba
// queries to be finished.
Close()
}
// FakeMysqlDaemon implements MysqlDaemon and allows the user to fake
@ -337,6 +341,10 @@ func (fmd *FakeMysqlDaemon) FetchSuperQuery(query string) (*mproto.QueryResult,
return qr, nil
}
// Close is part of the MysqlDaemon interface
func (fmd *FakeMysqlDaemon) Close() {
}
// CheckSuperQueryList returns an error if all the queries we expected
// haven't been seen.
func (fmd *FakeMysqlDaemon) CheckSuperQueryList() error {

Просмотреть файл

@ -114,7 +114,7 @@ func (mysqld *Mysqld) GetSchema(dbName string, tables, excludeTables []string, i
// ResolveTables returns a list of actual tables+views matching a list
// of regexps
func (mysqld *Mysqld) ResolveTables(dbName string, tables []string) ([]string, error) {
func ResolveTables(mysqld MysqlDaemon, dbName string, tables []string) ([]string, error) {
sd, err := mysqld.GetSchema(dbName, tables, nil, true)
if err != nil {
return nil, err

Просмотреть файл

@ -17,6 +17,7 @@ import (
"github.com/youtube/vitess/go/stats"
"github.com/youtube/vitess/go/trace"
"github.com/youtube/vitess/go/vt/binlog"
"github.com/youtube/vitess/go/vt/mysqlctl"
"github.com/youtube/vitess/go/vt/tabletserver"
"github.com/youtube/vitess/go/vt/tabletserver/planbuilder"
"github.com/youtube/vitess/go/vt/topo"
@ -106,7 +107,7 @@ func (agent *ActionAgent) loadKeyspaceAndBlacklistRules(tablet *topo.Tablet, bla
blacklistRules := tabletserver.NewQueryRules()
if len(blacklistedTables) > 0 {
// tables, first resolve wildcards
tables, err := agent.Mysqld.ResolveTables(tablet.DbName(), blacklistedTables)
tables, err := mysqlctl.ResolveTables(agent.MysqlDaemon, tablet.DbName(), blacklistedTables)
if err != nil {
return err
}

Просмотреть файл

@ -457,8 +457,8 @@ func (agent *ActionAgent) Stop() {
if agent.BinlogPlayerMap != nil {
agent.BinlogPlayerMap.StopAllPlayersAndReset()
}
if agent.Mysqld != nil {
agent.Mysqld.Close()
if agent.MysqlDaemon != nil {
agent.MysqlDaemon.Close()
}
}

Просмотреть файл

@ -743,7 +743,7 @@ func (agent *ActionAgent) Backup(ctx context.Context, concurrency int, logger lo
// now we can run the backup
bucket := fmt.Sprintf("%v/%v", tablet.Keyspace, tablet.Shard)
name := fmt.Sprintf("%v-%v", tablet.Alias, time.Now().Unix())
returnErr := mysqlctl.Backup(agent.Mysqld, l, bucket, name, concurrency, agent.hookExtraEnv())
returnErr := mysqlctl.Backup(agent.MysqlDaemon, l, bucket, name, concurrency, agent.hookExtraEnv())
// and change our type back to the appropriate value:
// - if healthcheck is enabled, go to spare

Просмотреть файл

@ -259,7 +259,7 @@ func (bpc *BinlogPlayerController) Iteration() (err error) {
// check which kind of replication we're doing, tables or keyrange
if len(bpc.sourceShard.Tables) > 0 {
// tables, first resolve wildcards
tables, err := bpc.mysqld.ResolveTables(bpc.dbName, bpc.sourceShard.Tables)
tables, err := mysqlctl.ResolveTables(bpc.mysqld, bpc.dbName, bpc.sourceShard.Tables)
if err != nil {
return fmt.Errorf("failed to resolve table names: %v", err)
}

Просмотреть файл

@ -44,7 +44,7 @@ func (agent *ActionAgent) restoreFromBackup() {
// do the optional restore, if that fails we are in a bad state,
// just log.Fatalf out.
bucket := fmt.Sprintf("%v/%v", tablet.Keyspace, tablet.Shard)
pos, err := mysqlctl.Restore(agent.Mysqld, bucket, *restoreConcurrency, agent.hookExtraEnv())
pos, err := mysqlctl.Restore(agent.MysqlDaemon, bucket, *restoreConcurrency, agent.hookExtraEnv())
if err != nil && err != mysqlctl.ErrNoBackup {
log.Fatalf("Cannot restore original backup: %v", err)
}