aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2018-12-06 00:44:41 -0800
committerChris Lu <chris.lu@gmail.com>2018-12-06 00:44:41 -0800
commitc28e8a23972949fa8aefd018502885a115f5e51a (patch)
tree2870de43786ec61dfc4165ce49089498f256c01f
parentffa2827ab162b37b75349dda7e73bf873ae1fdca (diff)
downloadseaweedfs-c28e8a23972949fa8aefd018502885a115f5e51a.tar.xz
seaweedfs-c28e8a23972949fa8aefd018502885a115f5e51a.zip
refactoring
-rw-r--r--weed/command/filer_replication.go24
-rw-r--r--weed/filer2/configuration.go24
-rw-r--r--weed/notification/configuration.go24
3 files changed, 42 insertions, 30 deletions
diff --git a/weed/command/filer_replication.go b/weed/command/filer_replication.go
index 087a12059..3384e4023 100644
--- a/weed/command/filer_replication.go
+++ b/weed/command/filer_replication.go
@@ -41,16 +41,7 @@ func runFilerReplicate(cmd *Command, args []string) bool {
var notificationInput sub.NotificationInput
- enabledInput := ""
- for _, input := range sub.NotificationInputs {
- if config.GetBool("notification." + input.GetName() + ".enabled") {
- if enabledInput == "" {
- enabledInput = input.GetName()
- } else {
- glog.Fatalf("Notification input is enabled for both %s and %s", enabledInput, input.GetName())
- }
- }
- }
+ validateOneEnabledInput(config)
for _, input := range sub.NotificationInputs {
if config.GetBool("notification." + input.GetName() + ".enabled") {
@@ -133,3 +124,16 @@ func runFilerReplicate(cmd *Command, args []string) bool {
return true
}
+
+func validateOneEnabledInput(config *viper.Viper) {
+ enabledInput := ""
+ for _, input := range sub.NotificationInputs {
+ if config.GetBool("notification." + input.GetName() + ".enabled") {
+ if enabledInput == "" {
+ enabledInput = input.GetName()
+ } else {
+ glog.Fatalf("Notification input is enabled for both %s and %s", enabledInput, input.GetName())
+ }
+ }
+ }
+}
diff --git a/weed/filer2/configuration.go b/weed/filer2/configuration.go
index 4b20b608b..7b05b53dc 100644
--- a/weed/filer2/configuration.go
+++ b/weed/filer2/configuration.go
@@ -13,16 +13,7 @@ var (
func (f *Filer) LoadConfiguration(config *viper.Viper) {
- enabledStore := ""
- for _, store := range Stores {
- if config.GetBool(store.GetName() + ".enabled") {
- if enabledStore == "" {
- enabledStore = store.GetName()
- } else {
- glog.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
- }
- }
- }
+ validateOneEnabledStore(config)
for _, store := range Stores {
if config.GetBool(store.GetName() + ".enabled") {
@@ -45,3 +36,16 @@ func (f *Filer) LoadConfiguration(config *viper.Viper) {
os.Exit(-1)
}
+
+func validateOneEnabledStore(config *viper.Viper) {
+ enabledStore := ""
+ for _, store := range Stores {
+ if config.GetBool(store.GetName() + ".enabled") {
+ if enabledStore == "" {
+ enabledStore = store.GetName()
+ } else {
+ glog.Fatalf("Filer store is enabled for both %s and %s", enabledStore, store.GetName())
+ }
+ }
+ }
+}
diff --git a/weed/notification/configuration.go b/weed/notification/configuration.go
index f34ccf305..7f8765cc3 100644
--- a/weed/notification/configuration.go
+++ b/weed/notification/configuration.go
@@ -27,16 +27,7 @@ func LoadConfiguration(config *viper.Viper) {
return
}
- enabledQueue := ""
- for _, queue := range MessageQueues {
- if config.GetBool(queue.GetName() + ".enabled") {
- if enabledQueue == "" {
- enabledQueue = queue.GetName()
- } else {
- glog.Fatalf("Notification message queue is enabled for both %s and %s", enabledQueue, queue.GetName())
- }
- }
- }
+ validateOneEnabledQueue(config)
for _, queue := range MessageQueues {
if config.GetBool(queue.GetName() + ".enabled") {
@@ -52,3 +43,16 @@ func LoadConfiguration(config *viper.Viper) {
}
}
+
+func validateOneEnabledQueue(config *viper.Viper) {
+ enabledQueue := ""
+ for _, queue := range MessageQueues {
+ if config.GetBool(queue.GetName() + ".enabled") {
+ if enabledQueue == "" {
+ enabledQueue = queue.GetName()
+ } else {
+ glog.Fatalf("Notification message queue is enabled for both %s and %s", enabledQueue, queue.GetName())
+ }
+ }
+ }
+}