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,34 @@
package metastore
import (
"io/ioutil"
"os"
"path"
)
// store data on disk, enough for most cases
type MetaStoreFileBacking struct {
}
func NewMetaStoreFileBacking() MetaStoreFileBacking {
mms := MetaStoreFileBacking{}
return mms
}
func (mms MetaStoreFileBacking) Set(val []byte, elem ...string) error {
return ioutil.WriteFile(path.Join(elem...), val, 0644)
}
func (mms MetaStoreFileBacking) Get(elem ...string) (val []byte, err error) {
return ioutil.ReadFile(path.Join(elem...))
}
func (mms MetaStoreFileBacking) Has(elem ...string) (ok bool) {
seqFile, se := os.OpenFile(path.Join(elem...), os.O_RDONLY, 0644)
if se != nil {
return false
}
defer seqFile.Close()
return true
}