support for /api/mysql-relay-log-index-file
This commit is contained in:
Родитель
2e71045e8b
Коммит
ca88f0d669
|
@ -71,6 +71,7 @@ func main() {
|
|||
|
||||
log.Debugf("Process token: %s", agent.ProcessToken.Hash)
|
||||
if config.Config.TokenHintFile != "" {
|
||||
log.Debugf("Writing token to TokenHintFile: %s", config.Config.TokenHintFile)
|
||||
err := ioutil.WriteFile(config.Config.TokenHintFile, []byte(agent.ProcessToken.Hash), 0644)
|
||||
log.Errore(err)
|
||||
}
|
||||
|
|
|
@ -449,6 +449,21 @@ func (this *HttpAPI) Status(params martini.Params, r render.Render, req *http.Re
|
|||
}
|
||||
}
|
||||
|
||||
// RelayLogIndexFile returns mysql relay log index file, full path
|
||||
func (this *HttpAPI) RelayLogIndexFile(params martini.Params, r render.Render, req *http.Request) {
|
||||
if err := validateToken(req.URL.Query().Get("token")); err != nil {
|
||||
r.JSON(500, &APIResponse{Code: ERROR, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
output, err := osagent.GetRelayLogIndexFileName()
|
||||
if err != nil {
|
||||
r.JSON(500, &APIResponse{Code: ERROR, Message: err.Error()})
|
||||
return
|
||||
}
|
||||
r.JSON(200, output)
|
||||
}
|
||||
|
||||
func (this *HttpAPI) RunCommand(params martini.Params, r render.Render, req *http.Request) {
|
||||
var err error
|
||||
if err = validateToken(req.URL.Query().Get("token")); err != nil {
|
||||
|
@ -502,6 +517,7 @@ func (this *HttpAPI) RegisterRequests(m *martini.ClassicMartini) {
|
|||
m.Get("/api/abort-seed/:seedId", this.AbortSeed)
|
||||
m.Get("/api/seed-command-completed/:seedId", this.SeedCommandCompleted)
|
||||
m.Get("/api/seed-command-succeeded/:seedId", this.SeedCommandSucceeded)
|
||||
m.Get("/api/mysql-relay-log-index-file", this.RelayLogIndexFile)
|
||||
m.Get("/api/custom-commands/:cmd", this.RunCommand)
|
||||
m.Get(config.Config.StatusEndpoint, this.Status)
|
||||
}
|
||||
|
|
|
@ -46,6 +46,35 @@ type LogicalVolume struct {
|
|||
SnapshotPercent float64
|
||||
}
|
||||
|
||||
func GetMySQLDataDir() (string, error) {
|
||||
command := config.Config.MySQLDatadirCommand
|
||||
output, err := commandOutput(command)
|
||||
return strings.TrimSpace(fmt.Sprintf("%s", output)), err
|
||||
}
|
||||
|
||||
func GetMySQLPort() (int64, error) {
|
||||
command := config.Config.MySQLPortCommand
|
||||
output, err := commandOutput(command)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return strconv.ParseInt(strings.TrimSpace(fmt.Sprintf("%s", output)), 10, 0)
|
||||
}
|
||||
|
||||
func GetRelayLogIndexFileName() (string, error) {
|
||||
directory, err := GetMySQLDataDir()
|
||||
if err != nil {
|
||||
return "", log.Errore(err)
|
||||
}
|
||||
|
||||
output, err := commandOutput(fmt.Sprintf("ls %s/*relay*.index", directory))
|
||||
if err != nil {
|
||||
return "", log.Errore(err)
|
||||
}
|
||||
|
||||
return strings.TrimSpace(fmt.Sprintf("%s", output)), err
|
||||
}
|
||||
|
||||
// Equals tests equality of this corrdinate and another one.
|
||||
func (this *LogicalVolume) IsSnapshotValid() bool {
|
||||
if !this.IsSnapshot {
|
||||
|
@ -360,21 +389,6 @@ func HeuristicMySQLDataPath(mountPoint string) (string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func GetMySQLDataDir() (string, error) {
|
||||
command := config.Config.MySQLDatadirCommand
|
||||
output, err := commandOutput(command)
|
||||
return strings.TrimSpace(fmt.Sprintf("%s", output)), err
|
||||
}
|
||||
|
||||
func GetMySQLPort() (int64, error) {
|
||||
command := config.Config.MySQLPortCommand
|
||||
output, err := commandOutput(command)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return strconv.ParseInt(strings.TrimSpace(fmt.Sprintf("%s", output)), 10, 0)
|
||||
}
|
||||
|
||||
func AvailableSnapshots(requireLocal bool) ([]string, error) {
|
||||
var command string
|
||||
if requireLocal {
|
||||
|
|
Загрузка…
Ссылка в новой задаче