зеркало из https://github.com/github/vitess-gh.git
Removing couple unused methods.
This commit is contained in:
Родитель
a4bb4d36ad
Коммит
9776e112ce
|
@ -12,8 +12,6 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -89,8 +87,8 @@ func parseSlaveStatus(fields map[string]string) proto.ReplicationStatus {
|
||||||
return status
|
return status
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForSlaveStart waits for MySQL replication to start until given
|
// WaitForSlaveStart waits until the deadline for replication to start.
|
||||||
// deadline (in seconds) passed.
|
// This validates the current master is correct and can be connected to.
|
||||||
func WaitForSlaveStart(mysqld MysqlDaemon, slaveStartDeadline int) error {
|
func WaitForSlaveStart(mysqld MysqlDaemon, slaveStartDeadline int) error {
|
||||||
var rowMap map[string]string
|
var rowMap map[string]string
|
||||||
for slaveWait := 0; slaveWait < slaveStartDeadline; slaveWait++ {
|
for slaveWait := 0; slaveWait < slaveStartDeadline; slaveWait++ {
|
||||||
|
@ -247,43 +245,6 @@ func (mysqld *Mysqld) SetMasterCommands(masterHost string, masterPort int) ([]st
|
||||||
return flavor.SetMasterCommands(¶ms, masterHost, masterPort, int(masterConnectRetry.Seconds()))
|
return flavor.SetMasterCommands(¶ms, masterHost, masterPort, int(masterConnectRetry.Seconds()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// WaitForSlave waits for a slave if its lag is larger than given maxLag
|
|
||||||
func (mysqld *Mysqld) WaitForSlave(maxLag int) (err error) {
|
|
||||||
// FIXME(msolomon) verify that slave started based on show slave status;
|
|
||||||
var rowMap map[string]string
|
|
||||||
for {
|
|
||||||
rowMap, err = mysqld.fetchSuperQueryMap("SHOW SLAVE STATUS")
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if rowMap["Seconds_Behind_Master"] == "NULL" {
|
|
||||||
break
|
|
||||||
} else {
|
|
||||||
lag, err := strconv.Atoi(rowMap["Seconds_Behind_Master"])
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if lag < maxLag {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
time.Sleep(time.Second)
|
|
||||||
}
|
|
||||||
|
|
||||||
errorKeys := []string{"Last_Error", "Last_IO_Error", "Last_SQL_Error"}
|
|
||||||
errs := make([]string, 0, len(errorKeys))
|
|
||||||
for _, key := range errorKeys {
|
|
||||||
if rowMap[key] != "" {
|
|
||||||
errs = append(errs, key+": "+rowMap[key])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(errs) != 0 {
|
|
||||||
return errors.New(strings.Join(errs, ", "))
|
|
||||||
}
|
|
||||||
return errors.New("replication stopped, it will never catch up")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetReplicationCommands returns the commands to run to reset all
|
// ResetReplicationCommands returns the commands to run to reset all
|
||||||
// replication for this host.
|
// replication for this host.
|
||||||
func (mysqld *Mysqld) ResetReplicationCommands() ([]string, error) {
|
func (mysqld *Mysqld) ResetReplicationCommands() ([]string, error) {
|
||||||
|
@ -336,22 +297,6 @@ func (mysqld *Mysqld) FindSlaves() ([]string, error) {
|
||||||
return addrs, nil
|
return addrs, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValidateSnapshotPath is a helper function to make sure we can write to the local snapshot area, before we actually do any action
|
|
||||||
// (can be used for both partial and full snapshots)
|
|
||||||
func (mysqld *Mysqld) ValidateSnapshotPath() error {
|
|
||||||
_path := path.Join(mysqld.SnapshotDir, "validate_test")
|
|
||||||
if err := os.RemoveAll(_path); err != nil {
|
|
||||||
return fmt.Errorf("ValidateSnapshotPath: Cannot validate snapshot directory: %v", err)
|
|
||||||
}
|
|
||||||
if err := os.MkdirAll(_path, 0775); err != nil {
|
|
||||||
return fmt.Errorf("ValidateSnapshotPath: Cannot validate snapshot directory: %v", err)
|
|
||||||
}
|
|
||||||
if err := os.RemoveAll(_path); err != nil {
|
|
||||||
return fmt.Errorf("ValidateSnapshotPath: Cannot validate snapshot directory: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// WaitBlpPosition will wait for the filtered replication to reach at least
|
// WaitBlpPosition will wait for the filtered replication to reach at least
|
||||||
// the provided position.
|
// the provided position.
|
||||||
func (mysqld *Mysqld) WaitBlpPosition(bp *blproto.BlpPosition, waitTimeout time.Duration) error {
|
func (mysqld *Mysqld) WaitBlpPosition(bp *blproto.BlpPosition, waitTimeout time.Duration) error {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче