mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring scaffolding for master.toml
This commit is contained in:
parent
c6e8225a20
commit
de0c983808
|
@ -346,10 +346,11 @@ scripts = """
|
||||||
"""
|
"""
|
||||||
sleep_minutes = 17 # sleep minutes between each script execution
|
sleep_minutes = 17 # sleep minutes between each script execution
|
||||||
|
|
||||||
filer_url = "http://localhost:8888/"
|
[master.filer]
|
||||||
|
default_filer_url = "http://localhost:8888/"
|
||||||
sequencer_type = memory # Choose [memory|etcd] type for storing the file id sequence
|
|
||||||
|
|
||||||
|
[master.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
|
# 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
|
# 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
|
||||||
|
|
|
@ -28,9 +28,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
MasterPrefix = "master.maintenance"
|
SequencerType = "master.sequencer.type"
|
||||||
SequencerType = MasterPrefix + ".sequencer_type"
|
SequencerEtcdUrls = "master.sequencer.sequencer_etcd_urls"
|
||||||
SequencerEtcdUrls = MasterPrefix + ".sequencer_etcd_urls"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type MasterOption struct {
|
type MasterOption struct {
|
||||||
|
@ -194,8 +193,8 @@ func (ms *MasterServer) startAdminScripts() {
|
||||||
v.SetDefault("master.maintenance.sleep_minutes", 17)
|
v.SetDefault("master.maintenance.sleep_minutes", 17)
|
||||||
sleepMinutes := v.GetInt("master.maintenance.sleep_minutes")
|
sleepMinutes := v.GetInt("master.maintenance.sleep_minutes")
|
||||||
|
|
||||||
v.SetDefault("master.maintenance.filer_url", "http://localhost:8888/")
|
v.SetDefault("master.filer.default_filer_url", "http://localhost:8888/")
|
||||||
filerURL := v.GetString("master.maintenance.filer_url")
|
filerURL := v.GetString("master.filer.default_filer_url")
|
||||||
|
|
||||||
scriptLines := strings.Split(adminScripts, "\n")
|
scriptLines := strings.Split(adminScripts, "\n")
|
||||||
|
|
||||||
|
@ -207,7 +206,7 @@ func (ms *MasterServer) startAdminScripts() {
|
||||||
|
|
||||||
shellOptions.FilerHost, shellOptions.FilerPort, shellOptions.Directory, err = util.ParseFilerUrl(filerURL)
|
shellOptions.FilerHost, shellOptions.FilerPort, shellOptions.Directory, err = util.ParseFilerUrl(filerURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.V(0).Infof("failed to parse master.maintenance.filer_url=%s : %v\n", filerURL, err)
|
glog.V(0).Infof("failed to parse master.filer.default_filer_urll=%s : %v\n", filerURL, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,14 +250,13 @@ func (ms *MasterServer) startAdminScripts() {
|
||||||
|
|
||||||
func (ms *MasterServer) createSequencer(option *MasterOption) sequence.Sequencer {
|
func (ms *MasterServer) createSequencer(option *MasterOption) sequence.Sequencer {
|
||||||
var seq sequence.Sequencer
|
var seq sequence.Sequencer
|
||||||
seqType := strings.ToLower(util.Config().GetString(SequencerType))
|
v := viper.GetViper()
|
||||||
glog.V(0).Infof("[%s] : [%s]", SequencerType, seqType)
|
seqType := strings.ToLower(v.GetString(SequencerType))
|
||||||
|
glog.V(1).Infof("[%s] : [%s]", SequencerType, seqType)
|
||||||
switch strings.ToLower(seqType) {
|
switch strings.ToLower(seqType) {
|
||||||
case "memory":
|
|
||||||
seq = sequence.NewMemorySequencer()
|
|
||||||
case "etcd":
|
case "etcd":
|
||||||
var err error
|
var err error
|
||||||
urls := util.Config().GetString(SequencerEtcdUrls)
|
urls := v.GetString(SequencerEtcdUrls)
|
||||||
glog.V(0).Infof("[%s] : [%s]", SequencerEtcdUrls, urls)
|
glog.V(0).Infof("[%s] : [%s]", SequencerEtcdUrls, urls)
|
||||||
seq, err = sequence.NewEtcdSequencer(urls, option.MetaFolder)
|
seq, err = sequence.NewEtcdSequencer(urls, option.MetaFolder)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -41,7 +41,3 @@ func LoadConfiguration(configFileName string, required bool) (loaded bool) {
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func Config() Configuration {
|
|
||||||
return viper.GetViper()
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue