mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
refactoring
This commit is contained in:
parent
fc9af962ec
commit
1dd2c76532
|
@ -38,9 +38,11 @@ type Filer struct {
|
|||
LocalMetaLogBuffer *log_buffer.LogBuffer
|
||||
metaLogCollection string
|
||||
metaLogReplication string
|
||||
MetaAggregator *MetaAggregator
|
||||
}
|
||||
|
||||
func NewFiler(masters []string, grpcDialOption grpc.DialOption, filerHost string, filerGrpcPort uint32, collection string, replication string, notifyFn func()) *Filer {
|
||||
func NewFiler(masters []string, grpcDialOption grpc.DialOption,
|
||||
filerHost string, filerGrpcPort uint32, collection string, replication string, notifyFn func()) *Filer {
|
||||
f := &Filer{
|
||||
directoryCache: ccache.New(ccache.Configure().MaxSize(1000).ItemsToPrune(100)),
|
||||
MasterClient: wdclient.NewMasterClient(grpcDialOption, "filer", filerHost, filerGrpcPort, masters),
|
||||
|
@ -56,6 +58,20 @@ func NewFiler(masters []string, grpcDialOption grpc.DialOption, filerHost string
|
|||
return f
|
||||
}
|
||||
|
||||
func (f *Filer) AggregateFromPeers(self string, filers []string) {
|
||||
|
||||
// set peers
|
||||
if strings.HasPrefix(f.GetStore().GetName(), "leveldb") && len(filers) > 0 {
|
||||
glog.Fatalf("filers using separate leveldb stores should not configure %d peers %+v", len(filers), filers)
|
||||
}
|
||||
if len(filers) == 0 {
|
||||
filers = append(filers, self)
|
||||
}
|
||||
f.MetaAggregator = NewMetaAggregator(filers, f.GrpcDialOption)
|
||||
f.MetaAggregator.StartLoopSubscribe(time.Now().UnixNano())
|
||||
|
||||
}
|
||||
|
||||
func (f *Filer) SetStore(store FilerStore) {
|
||||
f.store = NewFilerStoreWrapper(store)
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ func (fs *FilerServer) SubscribeMetadata(req *filer_pb.SubscribeMetadataRequest,
|
|||
lastReadTime = time.Unix(0, processedTsNs)
|
||||
}
|
||||
|
||||
err = fs.metaAggregator.MetaLogBuffer.LoopProcessLogData(lastReadTime, func() bool {
|
||||
fs.metaAggregator.ListenersLock.Lock()
|
||||
fs.metaAggregator.ListenersCond.Wait()
|
||||
fs.metaAggregator.ListenersLock.Unlock()
|
||||
err = fs.filer.MetaAggregator.MetaLogBuffer.LoopProcessLogData(lastReadTime, func() bool {
|
||||
fs.filer.MetaAggregator.ListenersLock.Lock()
|
||||
fs.filer.MetaAggregator.ListenersCond.Wait()
|
||||
fs.filer.MetaAggregator.ListenersLock.Unlock()
|
||||
return true
|
||||
}, eachLogEntryFn)
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -60,7 +59,6 @@ type FilerServer struct {
|
|||
option *FilerOption
|
||||
secret security.SigningKey
|
||||
filer *filer2.Filer
|
||||
metaAggregator *filer2.MetaAggregator
|
||||
grpcDialOption grpc.DialOption
|
||||
|
||||
// notifying clients
|
||||
|
@ -121,15 +119,7 @@ func NewFilerServer(defaultMux, readonlyMux *http.ServeMux, option *FilerOption)
|
|||
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.AggregateFromPeers(fmt.Sprintf("%s:%d", option.Host, option.Port), option.Filers)
|
||||
|
||||
fs.filer.LoadBuckets()
|
||||
|
||||
|
|
Loading…
Reference in a new issue