clean up etcd backing for sequence persistent storage. It uses some OS

specific calls and is not OS-agnostic.
This commit is contained in:
Chris Lu 2013-12-03 23:30:55 -08:00
parent 5fdb1d89ce
commit 2e2f426fe2
5 changed files with 0 additions and 70 deletions

View file

@ -14,11 +14,6 @@ func TestFileBacking(t *testing.T) {
verifySetGet(t, ms)
}
func TestEtcdBacking(t *testing.T) {
ms := &MetaStore{NewMetaStoreEtcdBacking("http://localhost:4001")}
verifySetGet(t, ms)
}
func verifySetGet(t *testing.T, ms *MetaStore) {
data := uint64(234234)
ms.SetUint64("/tmp/sequence", data)

View file

@ -1,53 +0,0 @@
// +build ignore
package metastore
import (
"code.google.com/p/weed-fs/go/glog"
"errors"
"github.com/coreos/go-etcd/etcd"
"strings"
)
// store data on etcd
type MetaStoreEtcdBacking struct {
client *etcd.Client
}
func NewMetaStoreEtcdBacking(etcdCluster string) *MetaStoreEtcdBacking {
m := &MetaStoreEtcdBacking{}
m.client = etcd.NewClient(strings.Split(etcdCluster, ","))
return m
}
func (m MetaStoreEtcdBacking) Set(path, val string) error {
res, e := m.client.Set(path, val, 0)
glog.V(2).Infof("etcd set response: %+v\n", res)
return e
}
func (m MetaStoreEtcdBacking) Get(path string) (string, error) {
results, err := m.client.Get(path)
for i, res := range results {
glog.V(2).Infof("[%d] get response: %+v\n", i, res)
}
if err != nil {
return "", err
}
if results[0].Key != path {
return "", errors.New("Key Not Found:" + path)
}
return results[0].Value, nil
}
func (m MetaStoreEtcdBacking) Has(path string) (ok bool) {
results, err := m.client.Get(path)
if err != nil {
return false
}
if results[0].Key != path {
return false
}
return true
}

View file

@ -34,13 +34,6 @@ func NewFileSequencer(filepath string) (m *SequencerImpl) {
return
}
//func NewEtcdSequencer(etcdCluster string) (m *SequencerImpl) {
// m = &SequencerImpl{fileFullPath: "/weedfs/default/sequence"}
// m.metaStore = &metastore.MetaStore{metastore.NewMetaStoreEtcdBacking(etcdCluster)}
// m.initilize()
// return
//}
func (m *SequencerImpl) initilize() {
if !m.metaStore.Has(m.fileFullPath) {
m.FileIdSequence = FileIdSaveInterval

View file

@ -37,7 +37,6 @@ var (
mMaxCpu = cmdMaster.Flag.Int("maxCpu", 0, "maximum number of CPUs. 0 means all available CPUs")
garbageThreshold = cmdMaster.Flag.String("garbageThreshold", "0.3", "threshold to vacuum and reclaim spaces")
masterWhiteListOption = cmdMaster.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")
//etcdCluster = cmdMaster.Flag.String("etcd", "", "comma separated etcd urls, e.g., http://localhost:4001, See github.com/coreos/go-etcd/etcd")
masterWhiteList []string
)

View file

@ -40,11 +40,7 @@ func NewMasterServer(r *mux.Router, version string, port int, metaFolder string,
garbageThreshold: garbageThreshold,
whiteList: whiteList,
}
//if len(*etcdCluster) == 0 {
seq := sequence.NewFileSequencer(path.Join(metaFolder, "weed.seq"))
//} else {
// seq = sequence.NewEtcdSequencer(*etcdCluster)
//}
var e error
if ms.topo, e = topology.NewTopology("topo", confFile, seq,
uint64(volumeSizeLimitMB)*1024*1024, pulseSeconds); e != nil {