support filter db to db0 when target type is cluster, seee #127

v4
vinllen 5 years ago
parent c5b3885063
commit c96cae1ae4
  1. 18
      src/redis-shake/main/main.go

@ -328,13 +328,6 @@ func sanitizeOptions(tp string) error {
return fmt.Errorf("only one of 'filter.key.whitelist' and 'filter.key.blacklist' can be given") return fmt.Errorf("only one of 'filter.key.whitelist' and 'filter.key.blacklist' can be given")
} }
// if the target is "cluster", only allow pass db 0
if conf.Options.TargetType == conf.RedisTypeCluster {
conf.Options.FilterDBWhitelist = []string{"0"} // set whitelist = 0
conf.Options.FilterDBBlacklist = []string{} // reset blacklist
log.Info("the target redis type is cluster, only pass db0")
}
if len(conf.Options.FilterSlot) > 0 { if len(conf.Options.FilterSlot) > 0 {
for i, val := range conf.Options.FilterSlot { for i, val := range conf.Options.FilterSlot {
if _, err := strconv.Atoi(val); err != nil { if _, err := strconv.Atoi(val); err != nil {
@ -357,6 +350,17 @@ func sanitizeOptions(tp string) error {
return fmt.Errorf("target.db[%v] should in {-1, 0} when target type is cluster", conf.Options.TargetDB) return fmt.Errorf("target.db[%v] should in {-1, 0} when target type is cluster", conf.Options.TargetDB)
} }
// if the target is "cluster", only allow pass db 0
if conf.Options.TargetType == conf.RedisTypeCluster {
if conf.Options.TargetDB == -1 {
conf.Options.FilterDBWhitelist = []string{"0"} // set whitelist = 0
conf.Options.FilterDBBlacklist = []string{} // reset blacklist
log.Info("the target redis type is cluster, only pass db0")
} else { // targetDB == 0
log.Info("the target redis type is cluster, all db syncing to db0")
}
}
if conf.Options.HttpProfile < 0 || conf.Options.HttpProfile > 65535 { if conf.Options.HttpProfile < 0 || conf.Options.HttpProfile > 65535 {
return fmt.Errorf("HttpProfile[%v] should in [0, 65535]", conf.Options.HttpProfile) return fmt.Errorf("HttpProfile[%v] should in [0, 65535]", conf.Options.HttpProfile)
} else if conf.Options.HttpProfile == 0 { } else if conf.Options.HttpProfile == 0 {

Loading…
Cancel
Save