add metastore, switching sequence to use it

metastore is for storing metadata. This will be used later when moving
to distributed master mode.
This commit is contained in:
Chris Lu
2013-11-05 01:59:00 -08:00
parent b579451db9
commit 5cb6590eae
5 changed files with 164 additions and 19 deletions

View File

@@ -0,0 +1,37 @@
package metastore
import (
"fmt"
"path"
)
//this is for testing only
type MetaStoreMemoryBacking struct {
m map[string][]byte
}
func NewMetaStoreMemoryBacking() MetaStoreMemoryBacking {
mms := MetaStoreMemoryBacking{}
mms.m = make(map[string][]byte)
return mms
}
func (mms MetaStoreMemoryBacking) Set(val []byte, elem ...string) error {
mms.m[path.Join(elem...)] = val
return nil
}
func (mms MetaStoreMemoryBacking) Get(elem ...string) (val []byte, err error) {
var ok bool
val, ok = mms.m[path.Join(elem...)]
if !ok {
return nil, fmt.Errorf("Missing value for %s", path.Join(elem...))
}
return
}
func (mms MetaStoreMemoryBacking) Has(elem ...string) (ok bool) {
_, ok = mms.m[path.Join(elem...)]
return
}