From b556ac65434ba432192208ba824d97bcec08826f Mon Sep 17 00:00:00 2001 From: vinllen Date: Wed, 3 Apr 2019 11:53:53 +0800 Subject: [PATCH 1/4] set parallel to 1 when not set --- src/redis-shake/main/main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/redis-shake/main/main.go b/src/redis-shake/main/main.go index 26dce4b..94c4c8d 100644 --- a/src/redis-shake/main/main.go +++ b/src/redis-shake/main/main.go @@ -172,7 +172,9 @@ func sanitizeOptions(tp string) error { runtime.GOMAXPROCS(conf.Options.NCpu) } - if conf.Options.Parallel == 0 || conf.Options.Parallel > 1024 { + if conf.Options.Parallel == 0 { + conf.Options.Parallel = 1 + } else if conf.Options.Parallel > 1024 { return fmt.Errorf("parallel[%v] should in (0, 1024]", conf.Options.Parallel) } else { conf.Options.Parallel = int(math.Max(float64(conf.Options.Parallel), float64(conf.Options.NCpu))) From 0b4d0effa6ddec9833ac270a919d1ee6c712d62c Mon Sep 17 00:00:00 2001 From: vinllen Date: Wed, 3 Apr 2019 13:47:53 +0800 Subject: [PATCH 2/4] modify code: enable heartbeat=0 --- src/redis-shake/main/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/redis-shake/main/main.go b/src/redis-shake/main/main.go index 94c4c8d..5b77f38 100644 --- a/src/redis-shake/main/main.go +++ b/src/redis-shake/main/main.go @@ -172,7 +172,7 @@ func sanitizeOptions(tp string) error { runtime.GOMAXPROCS(conf.Options.NCpu) } - if conf.Options.Parallel == 0 { + if conf.Options.Parallel == 0 { // not set conf.Options.Parallel = 1 } else if conf.Options.Parallel > 1024 { return fmt.Errorf("parallel[%v] should in (0, 1024]", conf.Options.Parallel) @@ -217,9 +217,9 @@ func sanitizeOptions(tp string) error { log.StdLog = log.New(utils.LogRotater, "") } - // heartbeat - if conf.Options.HeartbeatInterval <= 0 || conf.Options.HeartbeatInterval > 86400 { - return fmt.Errorf("HeartbeatInterval[%v] should in (0, 86400]", conf.Options.HeartbeatInterval) + // heartbeat, 86400 = 1 day + if conf.Options.HeartbeatInterval > 86400 { + return fmt.Errorf("HeartbeatInterval[%v] should in [0, 86400]", conf.Options.HeartbeatInterval) } if conf.Options.HeartbeatNetworkInterface == "" { conf.Options.HeartbeatIp = "127.0.0.1" From 956cabe9181b9ee3ce8c6bee97dd068a1ee83e37 Mon Sep 17 00:00:00 2001 From: vinllen Date: Wed, 3 Apr 2019 13:57:14 +0800 Subject: [PATCH 3/4] add some default settings --- src/redis-shake/main/main.go | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/src/redis-shake/main/main.go b/src/redis-shake/main/main.go index 5b77f38..f725153 100644 --- a/src/redis-shake/main/main.go +++ b/src/redis-shake/main/main.go @@ -39,6 +39,11 @@ const ( TypeRestore = "restore" TypeDump = "dump" TypeSync = "sync" + + defaultHttpPort = 20881 + defaultSystemPort = 20882 + defaultSenderSize = 65535 + defaultSenderCount = 1024 ) func main() { @@ -275,19 +280,32 @@ func sanitizeOptions(tp string) error { // pass, >= 0 means enable } - if conf.Options.HttpProfile <= 0 || conf.Options.HttpProfile > 65535 { - return fmt.Errorf("HttpProfile[%v] should in (0, 65535]", conf.Options.HttpProfile) + if conf.Options.HttpProfile < 0 || conf.Options.HttpProfile > 65535 { + return fmt.Errorf("HttpProfile[%v] should in [0, 65535]", conf.Options.HttpProfile) + } else if conf.Options.HttpProfile == 0 { + // set to default when not set + conf.Options.HttpProfile = defaultHttpPort } - if conf.Options.SystemProfile <= 0 || conf.Options.SystemProfile > 65535 { - return fmt.Errorf("SystemProfile[%v] should in (0, 65535]", conf.Options.SystemProfile) + + if conf.Options.SystemProfile < 0 || conf.Options.SystemProfile > 65535 { + return fmt.Errorf("SystemProfile[%v] should in [0, 65535]", conf.Options.SystemProfile) + } else if conf.Options.SystemProfile == 0 { + // set to default when not set + conf.Options.SystemProfile = defaultSystemPort } - if conf.Options.SenderSize <= 0 || conf.Options.SenderSize >= 1073741824 { - return fmt.Errorf("SenderSize[%v] should in (0, 1073741824]", conf.Options.SenderSize) + if conf.Options.SenderSize < 0 || conf.Options.SenderSize >= 1073741824 { + return fmt.Errorf("SenderSize[%v] should in [0, 1073741824]", conf.Options.SenderSize) + } else if conf.Options.SenderSize == 0 { + // set to default when not set + conf.Options.SenderSize = defaultSenderSize } - if conf.Options.SenderCount <= 0 || conf.Options.SenderCount >= 100000 { - return fmt.Errorf("SenderCount[%v] should in (0, 100000]", conf.Options.SenderCount) + if conf.Options.SenderCount < 0 || conf.Options.SenderCount >= 100000 { + return fmt.Errorf("SenderCount[%v] should in [0, 100000]", conf.Options.SenderCount) + } else if conf.Options.SenderCount == 0 { + // set to default when not set + conf.Options.SenderCount = defaultSenderCount } if tp == TypeRestore || tp == TypeSync { From 8e6c2ac36f54af62d7ea8f794e83d1c072c5f2f3 Mon Sep 17 00:00:00 2001 From: vinllen Date: Wed, 3 Apr 2019 14:05:27 +0800 Subject: [PATCH 4/4] remove src/github.com/kardianos/govendor --- src/github.com/kardianos/govendor | 1 - 1 file changed, 1 deletion(-) delete mode 160000 src/github.com/kardianos/govendor diff --git a/src/github.com/kardianos/govendor b/src/github.com/kardianos/govendor deleted file mode 160000 index e079574..0000000 --- a/src/github.com/kardianos/govendor +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e07957427183a9892f35634ffc9ea48dedc6bbb4