adding etcd storage support for cluster meta data. Currently just

sequence. More to come...
This commit is contained in:
Chris Lu
2013-11-10 01:31:50 -08:00
parent 5cb6590eae
commit 1888d01fa0
12 changed files with 149 additions and 56 deletions

View File

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