-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 新增riak监控、在riak部署与扩缩容的flow与dbactor中补充监控内容的功能 #600
- Loading branch information
1 parent
bb54e36
commit 3d0ffc1
Showing
60 changed files
with
3,263 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
dbm-services/riak/db-tools/dbactuator/internal/subcmd/riakcmd/deploy_monitor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package riakcmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"dbm-services/common/go-pubpkg/logger" | ||
"dbm-services/riak/db-tools/dbactuator/internal/subcmd" | ||
"dbm-services/riak/db-tools/dbactuator/pkg/components/riak" | ||
"dbm-services/riak/db-tools/dbactuator/pkg/util" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// DeployMonitorAct 部署riak监控dbactor参数 | ||
type DeployMonitorAct struct { | ||
*subcmd.BaseOptions | ||
Payload riak.DeployMonitorComp | ||
} | ||
|
||
// NewDeployMonitorCommand riak搬迁数据进度 | ||
func NewDeployMonitorCommand() *cobra.Command { | ||
act := DeployMonitorAct{ | ||
BaseOptions: subcmd.GBaseOptions, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "deploy-monitor", | ||
Short: "部署监控", | ||
Example: fmt.Sprintf("dbactuator riak deploy-monitor %s", subcmd.CmdBaseExampleStr), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
util.CheckErr(act.Validator()) | ||
util.CheckErr(act.Init()) | ||
util.CheckErr(act.Run()) | ||
}, | ||
} | ||
return cmd | ||
} | ||
|
||
// Validator TODO | ||
func (d *DeployMonitorAct) Validator() error { | ||
return d.BaseOptions.Validate() | ||
} | ||
|
||
// Init 反序列化并检查 | ||
func (d *DeployMonitorAct) Init() error { | ||
if err := d.DeserializeAndValidate(&d.Payload); err != nil { | ||
logger.Error("DeserializeAndValidate err %s", err.Error()) | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// Run 运行 | ||
func (d *DeployMonitorAct) Run() error { | ||
steps := subcmd.Steps{ | ||
{ | ||
FunName: "解压crond和monitor介质", | ||
Func: d.Payload.DeployBinary, | ||
}, | ||
// riak使用mysql-crond实现定时功能 | ||
// 生成mysql-crond与riak-monitor的配置文件,部分根据template生成 | ||
// 部分直接生成yaml | ||
{ | ||
FunName: "生成crond的runtime.yaml文件", | ||
Func: d.Payload.GenerateCrondConfigYaml, | ||
}, | ||
{ | ||
FunName: "生成monitor的runtime.yaml文件", | ||
Func: d.Payload.GenerateMonitorConfigYaml, | ||
}, | ||
{ | ||
FunName: "生成crond的jobs-config.yaml文件", | ||
Func: d.Payload.GenerateJobsConfigYaml, | ||
}, | ||
{ | ||
FunName: "生成monitor的items-config.yaml文件", | ||
Func: d.Payload.GenerateItemsConfigYaml, | ||
}, | ||
// 前台预执行便于发现执行报错,然后后台正式执行 | ||
{ | ||
FunName: "部署监控", | ||
Func: d.Payload.DeployMonitor, | ||
}, | ||
} | ||
// 部署失败 | ||
if err := steps.Run(); err != nil { | ||
return err | ||
} | ||
// 部署成功 | ||
logger.Info("deploy monitor success") | ||
return nil | ||
} |
65 changes: 65 additions & 0 deletions
65
dbm-services/riak/db-tools/dbactuator/internal/subcmd/riakcmd/start_monitor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package riakcmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"dbm-services/common/go-pubpkg/logger" | ||
"dbm-services/riak/db-tools/dbactuator/internal/subcmd" | ||
"dbm-services/riak/db-tools/dbactuator/pkg/components/riak" | ||
"dbm-services/riak/db-tools/dbactuator/pkg/util" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// StartMonitorAct 启动监控riak dbactor参数 | ||
type StartMonitorAct struct { | ||
*subcmd.BaseOptions | ||
Payload riak.StartMonitorComp | ||
} | ||
|
||
// NewStartMonitorCommand riak搬迁数据进度 | ||
func NewStartMonitorCommand() *cobra.Command { | ||
act := StartMonitorAct{ | ||
BaseOptions: subcmd.GBaseOptions, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "start-monitor", | ||
Short: "启动监控", | ||
Example: fmt.Sprintf("dbactuator riak start-monitor %s", subcmd.CmdBaseExampleStr), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
util.CheckErr(act.Validator()) | ||
util.CheckErr(act.Init()) | ||
util.CheckErr(act.Run()) | ||
}, | ||
} | ||
return cmd | ||
} | ||
|
||
// Validator TODO | ||
func (d *StartMonitorAct) Validator() error { | ||
return d.BaseOptions.Validate() | ||
} | ||
|
||
// Init 反序列化并检查 | ||
func (d *StartMonitorAct) Init() error { | ||
if err := d.DeserializeAndValidate(&d.Payload); err != nil { | ||
logger.Error("DeserializeAndValidate err %s", err.Error()) | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// Run 运行 | ||
func (d *StartMonitorAct) Run() error { | ||
steps := subcmd.Steps{ | ||
{ | ||
FunName: "启动监控", | ||
Func: d.Payload.StartMonitor, | ||
}, | ||
} | ||
if err := steps.Run(); err != nil { | ||
return err | ||
} | ||
logger.Info("start monitor success") | ||
return nil | ||
} |
65 changes: 65 additions & 0 deletions
65
dbm-services/riak/db-tools/dbactuator/internal/subcmd/riakcmd/stop_monitor.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package riakcmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"dbm-services/common/go-pubpkg/logger" | ||
"dbm-services/riak/db-tools/dbactuator/internal/subcmd" | ||
"dbm-services/riak/db-tools/dbactuator/pkg/components/riak" | ||
"dbm-services/riak/db-tools/dbactuator/pkg/util" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// StopMonitorAct 关闭监控riak dbactor参数 | ||
type StopMonitorAct struct { | ||
*subcmd.BaseOptions | ||
Payload riak.StopMonitorComp | ||
} | ||
|
||
// NewStopMonitorCommand riak关闭监控 | ||
func NewStopMonitorCommand() *cobra.Command { | ||
act := StopMonitorAct{ | ||
BaseOptions: subcmd.GBaseOptions, | ||
} | ||
cmd := &cobra.Command{ | ||
Use: "stop-monitor", | ||
Short: "关闭监控", | ||
Example: fmt.Sprintf("dbactuator riak stop-monitor %s", subcmd.CmdBaseExampleStr), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
util.CheckErr(act.Validator()) | ||
util.CheckErr(act.Init()) | ||
util.CheckErr(act.Run()) | ||
}, | ||
} | ||
return cmd | ||
} | ||
|
||
// Validator TODO | ||
func (d *StopMonitorAct) Validator() error { | ||
return d.BaseOptions.Validate() | ||
} | ||
|
||
// Init 反序列化并检查 | ||
func (d *StopMonitorAct) Init() error { | ||
if err := d.DeserializeAndValidate(&d.Payload); err != nil { | ||
logger.Error("DeserializeAndValidate err %s", err.Error()) | ||
return err | ||
} | ||
return nil | ||
} | ||
|
||
// Run 运行 | ||
func (d *StopMonitorAct) Run() error { | ||
steps := subcmd.Steps{ | ||
{ | ||
FunName: "关闭监控", | ||
Func: d.Payload.StopMonitor, | ||
}, | ||
} | ||
if err := steps.Run(); err != nil { | ||
return err | ||
} | ||
logger.Info("stop monitor success") | ||
return nil | ||
} |
Oops, something went wrong.