From 78f7df1ead4dc990d8e08e7967a81f060eca82a1 Mon Sep 17 00:00:00 2001 From: zhanghan2021 Date: Thu, 14 Sep 2023 11:22:17 +0800 Subject: [PATCH] add compress/fio/gcc examples atune info --- atune/server/httphandler/atune.go | 42 +++++++++++++++++++ atune/server/router/router.go | 8 ++-- atune/server/templete/enter_tune.go | 42 ++++++++++++++++++- atune/server/templete/tune/common.go | 8 ++-- atune/server/templete/tune/compress.go | 8 +++- atune/server/templete/tune/compress_Except.go | 15 +++++++ atune/server/templete/tune/compress_except.go | 8 ---- atune/server/templete/tune/ffmpeg.go | 18 +++++++- atune/server/templete/tune/fio.go | 18 +++++++- atune/server/templete/tune/gcc_compile.go | 8 ++-- 10 files changed, 151 insertions(+), 24 deletions(-) create mode 100644 atune/server/httphandler/atune.go create mode 100644 atune/server/templete/tune/compress_Except.go delete mode 100644 atune/server/templete/tune/compress_except.go diff --git a/atune/server/httphandler/atune.go b/atune/server/httphandler/atune.go new file mode 100644 index 00000000..76f78cd1 --- /dev/null +++ b/atune/server/httphandler/atune.go @@ -0,0 +1,42 @@ +package httphandler + +import ( + "gitee.com/openeuler/PilotGo-plugins/sdk/response" + "github.com/gin-gonic/gin" + "openeuler.org/PilotGo/atune-plugin/templete" +) + +func GetAtuneAll(c *gin.Context) { + allData := []string{ + "compress", + "compress_Except", + "ffmpeg", + "fio", + "gcc_compile", + "go_gc", + "graphicsmagick", + "iozone", + "key_parameters_select", + "key_parameters_select_variant", + "mariadb", + "memcached", + "memory", + "mysql_sysbench", + "nginx", + "openGauss", + "redis", + "spark", + "tensorflow_train", + "tidb", + "tomcat"} + response.Success(c, allData, "获取到全部的可调优业务名称") +} +func GetAtuneInfo(c *gin.Context) { + tuneName := c.Query("name") + tune := templete.GetTuneInfo(tuneName) + if tune == nil { + response.Fail(c, nil, "未找到可调优的业务名称") + return + } + response.Success(c, tune, "获取到调优步骤信息") +} diff --git a/atune/server/router/router.go b/atune/server/router/router.go index 3ae621a5..1b04a3b3 100644 --- a/atune/server/router/router.go +++ b/atune/server/router/router.go @@ -4,6 +4,7 @@ import ( "gitee.com/openeuler/PilotGo-plugins/sdk/logger" "github.com/gin-gonic/gin" "openeuler.org/PilotGo/atune-plugin/config" + "openeuler.org/PilotGo/atune-plugin/httphandler" "openeuler.org/PilotGo/atune-plugin/plugin" ) @@ -35,10 +36,9 @@ func registerAPIs(router *gin.Engine) { logger.Debug("router register") plugin.GlobalClient.RegisterHandlers(router) - DBTarget := router.Group("/plugin/" + plugin.GlobalClient.PluginInfo.Name) + atune := router.Group("/plugin/" + plugin.GlobalClient.PluginInfo.Name) { - DBTarget.GET("", func(ctx *gin.Context) { - ctx.JSON(200, `{"hello","world"}`) - }) + atune.GET("all", httphandler.GetAtuneAll) + atune.GET("info", httphandler.GetAtuneInfo) } } diff --git a/atune/server/templete/enter_tune.go b/atune/server/templete/enter_tune.go index 1f28c127..d83f6725 100644 --- a/atune/server/templete/enter_tune.go +++ b/atune/server/templete/enter_tune.go @@ -26,10 +26,50 @@ const ( Tomcat = "tomcat" ) -func GetTuneInfo(tuneName string) *tune.TuneInfo { +func GetTuneInfo(tuneName string) interface{} { switch tuneName { + case Compress: + return tune.TuneGroupApp.Compress.Info() + case CompressExcept: + return tune.TuneGroupApp.CompressExcept.Info() + case Ffmpeg: + return tune.TuneGroupApp.Ffmpeg.Info() + case Fio: + return tune.TuneGroupApp.Fio.Info() case GccCompile: return tune.TuneGroupApp.GccCompile.Info() + case GoGc: + return tune.TuneGroupApp.GoGc.Info() + case Graphicsmagick: + return tune.TuneGroupApp.Graphicsmagick.Info() + case Iozone: + return tune.TuneGroupApp.Iozone.Info() + case KeyParametersSelect: + return tune.TuneGroupApp.KeyParametersSelect.Info() + case KeyParametersSelectVariant: + return tune.TuneGroupApp.KeyParametersSelectVariant.Info() + case Mariadb: + return tune.TuneGroupApp.Mariadb.Info() + case Memcached: + return tune.TuneGroupApp.Memcached.Info() + case Memory: + return tune.TuneGroupApp.Memory.Info() + case MysqlSysbench: + return tune.TuneGroupApp.MysqlSysbench.Info() + case Nginx: + return tune.TuneGroupApp.Nginx.Info() + case OpenGauss: + return tune.TuneGroupApp.OpenGauss.Info() + case Redis: + return tune.TuneGroupApp.Redis.Info() + case Spark: + return tune.TuneGroupApp.Spark.Info() + case TensorflowTrain: + return tune.TuneGroupApp.TensorflowTrain.Info() + case Tidb: + return tune.TuneGroupApp.Tidb.Info() + case Tomcat: + return tune.TuneGroupApp.Tomcat.Info() default: return nil } diff --git a/atune/server/templete/tune/common.go b/atune/server/templete/tune/common.go index a1886d25..34dbe772 100644 --- a/atune/server/templete/tune/common.go +++ b/atune/server/templete/tune/common.go @@ -27,7 +27,9 @@ type TuneGroup struct { } type TuneInfo struct { - Prepare string `json:"prepare"` - Tune string `json:"tune"` - Restore string `json:"restore"` + TuneName string `json:"tuneName"` + WorkDirectory string `json:"workDir"` + Prepare string `json:"prepare"` + Tune string `json:"tune"` + Restore string `json:"restore"` } diff --git a/atune/server/templete/tune/compress.go b/atune/server/templete/tune/compress.go index cdee9291..32b8c718 100644 --- a/atune/server/templete/tune/compress.go +++ b/atune/server/templete/tune/compress.go @@ -3,6 +3,12 @@ package tune type CompressApp struct{} func (c *CompressApp) Info() *TuneInfo { - info := &TuneInfo{} + info := &TuneInfo{ + TuneName: "compress", + WorkDirectory: "mkdir -p /tmp/tune/ && cp -r ../../templete/compress.tar.gz /tmp/tune/ && cd /tmp/tune && tar -xzvf compress.tar.gz", + Prepare: "cd /tmp/tune/compress && sh prepare.sh enwik8.zip", + Tune: "atune-adm tuning --project compress --detail compress_client.yaml", + Restore: "atune-adm tuning --restore --project compress", + } return info } diff --git a/atune/server/templete/tune/compress_Except.go b/atune/server/templete/tune/compress_Except.go new file mode 100644 index 00000000..fa43f62d --- /dev/null +++ b/atune/server/templete/tune/compress_Except.go @@ -0,0 +1,15 @@ +package tune + +type CompressExceptApp struct{} + +func (ce *CompressExceptApp) Info() *TuneInfo { + info := &TuneInfo{ + TuneName: "compress_Except", + WorkDirectory: "mkdir -p /tmp/tune/ && cp -r ../../templete/compress_Except_example.tar.gz /tmp/tune/ && cd /tmp/tune && tar -xzvf compress_Except_example.tar.gz", + Prepare: "cd /tmp/tune/compress_Except_example && sh prepare.sh enwik8.zip", + Tune: "atune-adm tuning --project compress_Except_example --detail compress_Except_example_client.yaml", + Restore: "atune-adm tuning --restore --project compress_Except_example", + } + return info + +} diff --git a/atune/server/templete/tune/compress_except.go b/atune/server/templete/tune/compress_except.go deleted file mode 100644 index 5a647537..00000000 --- a/atune/server/templete/tune/compress_except.go +++ /dev/null @@ -1,8 +0,0 @@ -package tune - -type CompressExceptApp struct{} - -func (ce *CompressExceptApp) Info() *TuneInfo { - info := &TuneInfo{} - return info -} diff --git a/atune/server/templete/tune/ffmpeg.go b/atune/server/templete/tune/ffmpeg.go index ab01ba5c..e2d2f6e0 100644 --- a/atune/server/templete/tune/ffmpeg.go +++ b/atune/server/templete/tune/ffmpeg.go @@ -2,7 +2,21 @@ package tune type FfmpegApp struct{} -func (f *FfmpegApp) Info() *TuneInfo { - info := &TuneInfo{} +type FfmpegImp struct { + BaseTune TuneInfo + Notes string `json:"note"` +} + +func (f *FfmpegApp) Info() *FfmpegImp { + info := &FfmpegImp{ + BaseTune: TuneInfo{ + TuneName: "ffmpeg", + WorkDirectory: "mkdir -p /tmp/tune/ && cp -r ../../templete/ffmpeg.tar.gz /tmp/tune/ && cd /tmp/tune && tar -xzvf ffmpeg.tar.gz", + Prepare: "cd /tmp/tune/ffmpeg && sh prepare.sh", + Tune: "atune-adm tuning --project ffmpeg --detail ffmpeg_client.yaml", + Restore: "atune-adm tuning --restore --project ffmpeg", + }, + Notes: "请先找一个测试视频将其命名为test.flv(基本参数,41m34s,640x352,flv,83.6MB,视频编码AVC1,音频编码AAC),并将其放在/tmp/tune/ffmpeg目录下", + } return info } diff --git a/atune/server/templete/tune/fio.go b/atune/server/templete/tune/fio.go index 28b05ac3..57f0586a 100644 --- a/atune/server/templete/tune/fio.go +++ b/atune/server/templete/tune/fio.go @@ -2,7 +2,21 @@ package tune type FioApp struct{} -func (f *FioApp) Info() *TuneInfo { - info := &TuneInfo{} +type FioImp struct { + BaseTune TuneInfo + Notes string `json:"note"` +} + +func (f *FioApp) Info() *FioImp { + info := &FioImp{ + BaseTune: TuneInfo{ + TuneName: "compress_Except", + WorkDirectory: "mkdir -p /tmp/tune/ && cp -r ../../templete/fio.tar.gz /tmp/tune/ && cd /tmp/tune && tar -xzvf fio.tar.gz", + Prepare: "cd /tmp/tune/fio && sh prepare.sh 参数一 参数二", + Tune: "atune-adm tuning --project compress_Except_example --detail compress_Except_example_client.yaml", + Restore: "atune-adm tuning --restore --project compress_Except_example", + }, + Notes: "请注意prepare.sh的使用方法: sh prepare.sh [test_path] [test_disk]", + } return info } diff --git a/atune/server/templete/tune/gcc_compile.go b/atune/server/templete/tune/gcc_compile.go index 80020e70..90f4349f 100644 --- a/atune/server/templete/tune/gcc_compile.go +++ b/atune/server/templete/tune/gcc_compile.go @@ -4,9 +4,11 @@ type GccComplieApp struct{} func (gcc *GccComplieApp) Info() *TuneInfo { info := &TuneInfo{ - Prepare: "mkdir -p /tmp/tune/ && cp -r ../../templete/gcc_compile /tmp/tune/ && sh prepare.sh", - Tune: "atune-adm tuning --project gcc_compile --detail gcc_compile_client.yaml", - Restore: "atune-adm tuning --restore --project gcc_compile", + TuneName: "gcc_compile", + WorkDirectory: "mkdir -p /tmp/tune/ && cp -r ../../templete/gcc_compile.tar.gz /tmp/tune/ && cd /tmp/tune/ && tar -xzvf gcc_compile.tar.gz", + Prepare: "cd /tmp/tune/gcc_compile && sh prepare.sh", + Tune: "atune-adm tuning --project gcc_compile --detail gcc_compile_client.yaml", + Restore: "atune-adm tuning --restore --project gcc_compile", } return info } -- Gitee