Chris Lu
5 years ago
5 changed files with 101 additions and 9 deletions
-
29weed/filesys/dir.go
-
32weed/filesys/meta_cache/cache_config.go
-
34weed/filesys/meta_cache/meta_cache.go
-
6weed/filesys/wfs.go
-
9weed/filesys/xattr.go
@ -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") |
||||
|
} |
@ -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 |
||||
|
|
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue