Browse Source

filer: default filer store directory

1. set default filer store directory
2. set peers, avoiding empty string counted as 1.
pull/1383/head
Chris Lu 5 years ago
parent
commit
a2eb680f34
  1. 7
      weed/command/filer.go
  2. 21
      weed/server/filer_server.go

7
weed/command/filer.go

@ -103,6 +103,11 @@ func (fo *FilerOptions) startFiler() {
defaultLevelDbDirectory = *fo.defaultLevelDbDirectory + "/filerldb2" defaultLevelDbDirectory = *fo.defaultLevelDbDirectory + "/filerldb2"
} }
var peers []string
if *fo.peers != "" {
peers = strings.Split(*fo.peers, ",")
}
fs, nfs_err := weed_server.NewFilerServer(defaultMux, publicVolumeMux, &weed_server.FilerOption{ fs, nfs_err := weed_server.NewFilerServer(defaultMux, publicVolumeMux, &weed_server.FilerOption{
Masters: strings.Split(*fo.masters, ","), Masters: strings.Split(*fo.masters, ","),
Collection: *fo.collection, Collection: *fo.collection,
@ -116,7 +121,7 @@ func (fo *FilerOptions) startFiler() {
Host: *fo.ip, Host: *fo.ip,
Port: uint32(*fo.port), Port: uint32(*fo.port),
Cipher: *fo.cipher, Cipher: *fo.cipher,
Filers: strings.Split(*fo.peers, ","),
Filers: peers,
}) })
if nfs_err != nil { if nfs_err != nil {
glog.Fatalf("Filer startup error: %v", nfs_err) glog.Fatalf("Filer startup error: %v", nfs_err)

21
weed/server/filer_server.go

@ -89,19 +89,9 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
}) })
fs.filer.Cipher = option.Cipher fs.filer.Cipher = option.Cipher
// set peers
if strings.HasPrefix(fs.filer.GetStore().GetName(), "leveldb") && len(option.Filers) > 0 {
glog.Fatal("filers using separate leveldb stores should not configure peers!")
}
if len(option.Filers) == 0 {
option.Filers = append(option.Filers, fmt.Sprintf("%s:%d", option.Host, option.Port))
}
fs.metaAggregator = filer2.NewMetaAggregator(option.Filers, fs.grpcDialOption)
maybeStartMetrics(fs, option) maybeStartMetrics(fs, option)
go fs.filer.KeepConnectedToMaster() go fs.filer.KeepConnectedToMaster()
fs.metaAggregator.StartLoopSubscribe(time.Now().UnixNano())
v := util.GetViper() v := util.GetViper()
if !util.LoadConfiguration("filer", false) { if !util.LoadConfiguration("filer", false) {
@ -111,6 +101,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
if os.IsNotExist(err) { if os.IsNotExist(err) {
os.MkdirAll(option.DefaultLevelDbDir, 0755) os.MkdirAll(option.DefaultLevelDbDir, 0755)
} }
glog.V(0).Infof("default to create filer store dir in %s", option.DefaultLevelDbDir)
} }
util.LoadConfiguration("notification", false) util.LoadConfiguration("notification", false)
@ -130,6 +121,16 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
readonlyMux.HandleFunc("/", fs.readonlyFilerHandler) readonlyMux.HandleFunc("/", fs.readonlyFilerHandler)
} }
// set peers
if strings.HasPrefix(fs.filer.GetStore().GetName(), "leveldb") && len(option.Filers) > 0 {
glog.Fatalf("filers using separate leveldb stores should not configure %d peers %+v", len(option.Filers), option.Filers)
}
if len(option.Filers) == 0 {
option.Filers = append(option.Filers, fmt.Sprintf("%s:%d", option.Host, option.Port))
}
fs.metaAggregator = filer2.NewMetaAggregator(option.Filers, fs.grpcDialOption)
fs.metaAggregator.StartLoopSubscribe(time.Now().UnixNano())
fs.filer.LoadBuckets() fs.filer.LoadBuckets()
grace.OnInterrupt(func() { grace.OnInterrupt(func() {

Loading…
Cancel
Save