|
|
@@ -20,6 +20,7 @@ import (
|
|
|
"fmt"
|
|
|
"math/rand"
|
|
|
"net/http"
|
|
|
+ "os"
|
|
|
"path"
|
|
|
"regexp"
|
|
|
"sync/atomic"
|
|
|
@@ -27,6 +28,7 @@ import (
|
|
|
|
|
|
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/go-semver/semver"
|
|
|
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
|
|
|
+ "github.com/coreos/etcd/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
|
|
|
"github.com/coreos/etcd/Godeps/_workspace/src/golang.org/x/net/context"
|
|
|
"github.com/coreos/etcd/discovery"
|
|
|
"github.com/coreos/etcd/etcdserver/etcdhttp/httptypes"
|
|
|
@@ -43,6 +45,7 @@ import (
|
|
|
"github.com/coreos/etcd/raft/raftpb"
|
|
|
"github.com/coreos/etcd/rafthttp"
|
|
|
"github.com/coreos/etcd/snap"
|
|
|
+ dstorage "github.com/coreos/etcd/storage"
|
|
|
"github.com/coreos/etcd/store"
|
|
|
"github.com/coreos/etcd/version"
|
|
|
"github.com/coreos/etcd/wal"
|
|
|
@@ -106,6 +109,7 @@ type Server interface {
|
|
|
Leader() types.ID
|
|
|
// Do takes a request and attempts to fulfill it, returning a Response.
|
|
|
Do(ctx context.Context, r pb.Request) (Response, error)
|
|
|
+ V3DemoDo(ctx context.Context, r pb.InternalRaftRequest) proto.Message
|
|
|
// Process takes a raft message and applies it to the server's raft state
|
|
|
// machine, respecting any timeout of the given context.
|
|
|
Process(ctx context.Context, m raftpb.Message) error
|
|
|
@@ -156,6 +160,7 @@ type EtcdServer struct {
|
|
|
cluster *cluster
|
|
|
|
|
|
store store.Store
|
|
|
+ kv dstorage.KV
|
|
|
|
|
|
stats *stats.ServerStats
|
|
|
lstats *stats.LeaderStats
|
|
|
@@ -313,6 +318,13 @@ func NewServer(cfg *ServerConfig) (*EtcdServer, error) {
|
|
|
forceVersionC: make(chan struct{}),
|
|
|
}
|
|
|
|
|
|
+ if cfg.V3demo {
|
|
|
+ srv.kv = dstorage.New(path.Join(cfg.DataDir, "member", "v3demo"))
|
|
|
+ } else {
|
|
|
+ // we do not care about the error of the removal
|
|
|
+ os.RemoveAll(path.Join(cfg.DataDir, "member", "v3demo"))
|
|
|
+ }
|
|
|
+
|
|
|
// TODO: move transport initialization near the definition of remote
|
|
|
tr := rafthttp.NewTransporter(cfg.Transport, id, cl.ID(), srv, srv.errorc, sstats, lstats)
|
|
|
// add all remotes into transport
|