aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstlpmo <hq-STLPMO@chinaunicom.cn>2019-11-11 10:52:21 +0800
committerstlpmo <hq-STLPMO@chinaunicom.cn>2019-11-11 10:52:21 +0800
commit62d393d6c90362bd596bd841266ca9390fe3bb86 (patch)
tree6623af543b2edd16b3bae412652a7cded774ef01
parent802a0eb3fe115cd213d1238912fe431601e8f102 (diff)
downloadseaweedfs-62d393d6c90362bd596bd841266ca9390fe3bb86.tar.xz
seaweedfs-62d393d6c90362bd596bd841266ca9390fe3bb86.zip
ut pass
-rw-r--r--weed/command/master.go1
-rw-r--r--weed/command/scaffold.go4
-rw-r--r--weed/server/master_server.go10
-rw-r--r--weed/util/config.go12
4 files changed, 16 insertions, 11 deletions
diff --git a/weed/command/master.go b/weed/command/master.go
index d4c2b9b16..3d33f4f7a 100644
--- a/weed/command/master.go
+++ b/weed/command/master.go
@@ -78,7 +78,6 @@ func runMaster(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadConfiguration("master", false)
- glog.V(0).Infof("%v", viper.GetViper().GetString("master.maintenance.scripts"))
runtime.GOMAXPROCS(runtime.NumCPU())
util.SetupProfiling(*masterCpuProfile, *masterMemProfile)
diff --git a/weed/command/scaffold.go b/weed/command/scaffold.go
index 9b266a69d..6fa72c730 100644
--- a/weed/command/scaffold.go
+++ b/weed/command/scaffold.go
@@ -346,11 +346,11 @@ scripts = """
"""
sleep_minutes = 17 # sleep minutes between each script execution
-sequencer.type = memory # Choose [memory|etcd] type for storing the file id sequence
+sequencer_type = memory # Choose [memory|etcd] type for storing the file id sequence
# when sequencer.type = etcd, set listen client urls of etcd cluster that store file id sequence
# example : http://127.0.0.1:2379,http://127.0.0.1:2389
-sequencer.etcd.urls = http://127.0.0.1:2379
+sequencer_etcd_urls = http://127.0.0.1:2379
`
diff --git a/weed/server/master_server.go b/weed/server/master_server.go
index 41764c2e7..15e6ee51c 100644
--- a/weed/server/master_server.go
+++ b/weed/server/master_server.go
@@ -28,9 +28,9 @@ import (
)
const (
- MasterPrefix = "master.maintenance."
- SequencerType = MasterPrefix + "sequencer_type"
- SequencerEtcdUrls = MasterPrefix + "sequencer_etcd_urls"
+ MasterPrefix = "master.maintenance"
+ SequencerType = MasterPrefix + ".sequencer_type"
+ SequencerEtcdUrls = MasterPrefix + ".sequencer_etcd_urls"
)
type MasterOption struct {
@@ -244,14 +244,14 @@ func (ms *MasterServer) startAdminScripts() {
func (ms *MasterServer) createSequencer(option *MasterOption) sequence.Sequencer {
var seq sequence.Sequencer
seqType := strings.ToLower(util.Config().GetString(SequencerType))
- glog.V(0).Infof("sequencer type [%s]", seqType)
+ glog.V(0).Infof("[%s] : [%s]", SequencerType, seqType)
switch strings.ToLower(seqType) {
case "memory":
seq = sequence.NewMemorySequencer()
case "etcd":
var err error
urls := util.Config().GetString(SequencerEtcdUrls)
- glog.V(4).Infof("ETCD urls : %s", urls)
+ glog.V(0).Infof("[%s] : [%s]", SequencerEtcdUrls, urls)
seq, err = sequence.NewEtcdSequencer(urls, option.MetaFolder)
if err != nil {
glog.Error(err)
diff --git a/weed/util/config.go b/weed/util/config.go
index f51955263..385ef92d7 100644
--- a/weed/util/config.go
+++ b/weed/util/config.go
@@ -1,6 +1,8 @@
package util
import (
+ "fmt"
+
"github.com/chrislusf/seaweedfs/weed/glog"
"github.com/spf13/viper"
)
@@ -46,9 +48,13 @@ func Config() Configuration {
return viper.GetViper()
}
-func SubConfig(subKey string) Configuration {
+func SubConfig(subKey string) (Configuration, error) {
if subKey != "" {
- return viper.GetViper().Sub(subKey)
+ sub := viper.GetViper().Sub(subKey)
+ if sub == nil {
+ return nil, fmt.Errorf("sub config [%s] not exist", subKey)
+ }
+ return sub, nil
}
- return viper.GetViper()
+ return viper.GetViper(), nil
} \ No newline at end of file