Browse Source

ut pass

pull/1102/head
stlpmo 5 years ago
parent
commit
62d393d6c9
  1. 1
      weed/command/master.go
  2. 4
      weed/command/scaffold.go
  3. 10
      weed/server/master_server.go
  4. 12
      weed/util/config.go

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

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

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

12
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
}
Loading…
Cancel
Save