read from meta cache

meta cache is not initialized
This commit is contained in:
Chris Lu
2020-04-21 18:50:30 -07:00
parent b8e4238ad2
commit 4f02f7121d
5 changed files with 101 additions and 9 deletions

View File

@@ -0,0 +1,32 @@
package meta_cache
import "github.com/chrislusf/seaweedfs/weed/util"
var (
_ = util.Configuration(&cacheConfig{})
)
// implementing util.Configuraion
type cacheConfig struct {
dir string
}
func (c cacheConfig) GetString(key string) string {
return c.dir
}
func (c cacheConfig) GetBool(key string) bool {
panic("implement me")
}
func (c cacheConfig) GetInt(key string) int {
panic("implement me")
}
func (c cacheConfig) GetStringSlice(key string) []string {
panic("implement me")
}
func (c cacheConfig) SetDefault(key string, value interface{}) {
panic("implement me")
}

View File

@@ -0,0 +1,34 @@
package meta_cache
import (
"os"
"github.com/chrislusf/seaweedfs/weed/filer2"
"github.com/chrislusf/seaweedfs/weed/filer2/leveldb"
"github.com/chrislusf/seaweedfs/weed/glog"
)
type MetaCache struct {
filer2.FilerStore
}
func NewMetaCache(dbFolder string) *MetaCache {
return &MetaCache{
FilerStore: OpenMetaStore(dbFolder),
}
}
func OpenMetaStore(dbFolder string) filer2.FilerStore {
os.MkdirAll(dbFolder, 0755)
store := &leveldb.LevelDBStore{}
config := &cacheConfig{}
if err := store.Initialize(config, ""); err != nil {
glog.Fatalf("Failed to initialize metadata cache store for %s: %+v", store.GetName(), err)
}
return store
}