-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pd-ctl: add config replicate and show all config #573
Changes from 11 commits
22dd34d
c930dc8
dfc6089
42bd63b
44bf81c
85a93a1
956e1b1
c0ff6f5
66abfb5
55de956
0f38dfe
585673e
a97ec1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ | |
package api | ||
|
||
import ( | ||
"encoding/json" | ||
"io/ioutil" | ||
"net/http" | ||
|
||
"github.com/pingcap/pd/server" | ||
|
@@ -36,6 +38,29 @@ func (h *confHandler) Get(w http.ResponseWriter, r *http.Request) { | |
h.rd.JSON(w, http.StatusOK, h.svr.GetConfig()) | ||
} | ||
|
||
func (h *confHandler) Post(w http.ResponseWriter, r *http.Request) { | ||
config := h.svr.GetConfig() | ||
data, err := ioutil.ReadAll(r.Body) | ||
r.Body.Close() | ||
if err != nil { | ||
h.rd.JSON(w, http.StatusInternalServerError, err.Error()) | ||
return | ||
} | ||
err = json.Unmarshal(data, &config.Schedule) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we support IMO, I prefer check key-value one by one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a more easy way :). the other config no need to dynamic adjust. |
||
if err != nil { | ||
h.rd.JSON(w, http.StatusInternalServerError, err.Error()) | ||
return | ||
} | ||
err = json.Unmarshal(data, &config.Replication) | ||
if err != nil { | ||
h.rd.JSON(w, http.StatusInternalServerError, err.Error()) | ||
return | ||
} | ||
h.svr.SetScheduleConfig(config.Schedule) | ||
h.svr.SetReplicationConfig(config.Replication) | ||
h.rd.JSON(w, http.StatusOK, nil) | ||
} | ||
|
||
func (h *confHandler) GetSchedule(w http.ResponseWriter, r *http.Request) { | ||
h.rd.JSON(w, http.StatusOK, &h.svr.GetConfig().Schedule) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use schedulePrefix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the API setSchedule and getSchedule are not consistent. considering compatible I just adjust it in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's ok to give up supporting old pd-server.