|
|
@@ -4,12 +4,13 @@ import (
|
|
|
"encoding/binary"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
- etcdErr "github.com/coreos/etcd/error"
|
|
|
- "github.com/coreos/etcd/store"
|
|
|
- "github.com/coreos/go-raft"
|
|
|
"os"
|
|
|
"path"
|
|
|
"time"
|
|
|
+
|
|
|
+ etcdErr "github.com/coreos/etcd/error"
|
|
|
+ "github.com/coreos/etcd/store"
|
|
|
+ "github.com/coreos/go-raft"
|
|
|
)
|
|
|
|
|
|
const commandPrefix = "etcd:"
|
|
|
@@ -168,6 +169,7 @@ func (c *JoinCommand) Apply(raftServer *raft.Server) (interface{}, error) {
|
|
|
key := path.Join("_etcd/machines", c.Name)
|
|
|
value := fmt.Sprintf("raft=%s&etcd=%s&raftVersion=%s", c.RaftURL, c.EtcdURL, c.RaftVersion)
|
|
|
etcdStore.Set(key, value, time.Unix(0, 0), raftServer.CommitIndex())
|
|
|
+ r.peersStats[c.Name] = &peerStats{}
|
|
|
|
|
|
return b, err
|
|
|
}
|
|
|
@@ -193,6 +195,7 @@ func (c *RemoveCommand) Apply(raftServer *raft.Server) (interface{}, error) {
|
|
|
key := path.Join("_etcd/machines", c.Name)
|
|
|
|
|
|
_, err := etcdStore.Delete(key, raftServer.CommitIndex())
|
|
|
+ r.peersStats[c.Name] = nil
|
|
|
|
|
|
if err != nil {
|
|
|
return []byte{0}, err
|