This commit is contained in:
stlpmo 2019-11-11 10:52:21 +08:00
parent 802a0eb3fe
commit 62d393d6c9
4 changed files with 16 additions and 11 deletions

View file

@ -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)

View file

@ -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
`

View file

@ -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)

View file

@ -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
}