Skip to content

Commit

Permalink
merge master
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Jan 8, 2024
2 parents dc6a222 + 1210bc2 commit 3cb74e7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 11 deletions.
14 changes: 11 additions & 3 deletions components/playground/instance/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ func (inst *PDInstance) Name() string {

// Start calls set inst.cmd and Start
func (inst *PDInstance) Start(ctx context.Context) error {
configPath := filepath.Join(inst.Dir, "pd.toml")
if err := prepareConfig(
configPath,
inst.ConfigPath,
inst.getConfig(),
); err != nil {
return err
}

uid := inst.Name()
var args []string
switch inst.Role {
Expand All @@ -97,16 +106,15 @@ func (inst *PDInstance) Start(ctx context.Context) error {
}
args = append(args, []string{
"--name=" + uid,
fmt.Sprintf("--config=%s", configPath),
fmt.Sprintf("--data-dir=%s", filepath.Join(inst.Dir, "data")),
fmt.Sprintf("--peer-urls=http://%s", utils.JoinHostPort(inst.Host, inst.Port)),
fmt.Sprintf("--advertise-peer-urls=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.Port)),
fmt.Sprintf("--client-urls=http://%s", utils.JoinHostPort(inst.Host, inst.StatusPort)),
fmt.Sprintf("--advertise-client-urls=http://%s", utils.JoinHostPort(AdvertiseHost(inst.Host), inst.StatusPort)),
fmt.Sprintf("--log-file=%s", inst.LogFile()),
}...)
if inst.ConfigPath != "" {
args = append(args, fmt.Sprintf("--config=%s", inst.ConfigPath))
}

switch {
case len(inst.initEndpoints) > 0:
endpoints := make([]string, 0)
Expand Down
20 changes: 20 additions & 0 deletions components/playground/instance/pd_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2024 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package instance

func (inst *PDInstance) getConfig() map[string]any {
config := make(map[string]any)
config["schedule.patrol-region-interval"] = "100ms"
return config
}
16 changes: 8 additions & 8 deletions components/playground/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,17 @@ func populateDefaultOpt(flagSet *pflag.FlagSet) error {
defaultInt(&options.PD.Num, "pd", 1)
case "ms":
defaultInt(&options.PDAPI.Num, "pd.api", 1)
defaultStr(&options.PDAPI.BinPath, "pd.api.binpath", options.PDAPI.BinPath)
defaultStr(&options.PDAPI.ConfigPath, "pd.api.config", options.PDAPI.ConfigPath)
defaultStr(&options.PDAPI.BinPath, "pd.api.binpath", options.PD.BinPath)
defaultStr(&options.PDAPI.ConfigPath, "pd.api.config", options.PD.ConfigPath)
defaultInt(&options.PDTSO.Num, "pd.tso", 1)
defaultStr(&options.PDTSO.BinPath, "pd.tso.binpath", options.PDTSO.BinPath)
defaultStr(&options.PDTSO.ConfigPath, "pd.tso.config", options.PDTSO.ConfigPath)
defaultStr(&options.PDTSO.BinPath, "pd.tso.binpath", options.PD.BinPath)
defaultStr(&options.PDTSO.ConfigPath, "pd.tso.config", options.PD.ConfigPath)
defaultInt(&options.PDScheduling.Num, "pd.scheduling", 1)
defaultStr(&options.PDScheduling.BinPath, "pd.scheduling.binpath", options.PDScheduling.BinPath)
defaultStr(&options.PDScheduling.ConfigPath, "pd.scheduling.config", options.PDScheduling.ConfigPath)
defaultStr(&options.PDScheduling.BinPath, "pd.scheduling.binpath", options.PD.BinPath)
defaultStr(&options.PDScheduling.ConfigPath, "pd.scheduling.config", options.PD.ConfigPath)
defaultInt(&options.PDRM.Num, "pd.rm", 1)
defaultStr(&options.PDRM.BinPath, "pd.rm.binpath", options.PDRM.BinPath)
defaultStr(&options.PDRM.ConfigPath, "pd.rm.config", options.PDRM.ConfigPath)
defaultStr(&options.PDRM.BinPath, "pd.rm.binpath", options.PD.BinPath)
defaultStr(&options.PDRM.ConfigPath, "pd.rm.config", options.PD.ConfigPath)
default:
return errors.Errorf("Unknown --pd.mode %s", options.PDMode)
}
Expand Down

0 comments on commit 3cb74e7

Please sign in to comment.