|
@@ -3,9 +3,11 @@ package etcdserver
|
|
|
import (
|
|
import (
|
|
|
"crypto/sha1"
|
|
"crypto/sha1"
|
|
|
"encoding/binary"
|
|
"encoding/binary"
|
|
|
|
|
+ "fmt"
|
|
|
"path"
|
|
"path"
|
|
|
"sort"
|
|
"sort"
|
|
|
"strconv"
|
|
"strconv"
|
|
|
|
|
+ "time"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const machineKVPrefix = "/_etcd/machines/"
|
|
const machineKVPrefix = "/_etcd/machines/"
|
|
@@ -20,7 +22,7 @@ type Member struct {
|
|
|
|
|
|
|
|
// newMember creates a Member without an ID and generates one based on the
|
|
// newMember creates a Member without an ID and generates one based on the
|
|
|
// name, peer URLs. This is used for bootstrapping.
|
|
// name, peer URLs. This is used for bootstrapping.
|
|
|
-func newMember(name string, peerURLs []string) *Member {
|
|
|
|
|
|
|
+func newMember(name string, peerURLs []string, now *time.Time) *Member {
|
|
|
sort.Strings(peerURLs)
|
|
sort.Strings(peerURLs)
|
|
|
m := &Member{Name: name, PeerURLs: peerURLs}
|
|
m := &Member{Name: name, PeerURLs: peerURLs}
|
|
|
|
|
|
|
@@ -29,6 +31,10 @@ func newMember(name string, peerURLs []string) *Member {
|
|
|
b = append(b, []byte(p)...)
|
|
b = append(b, []byte(p)...)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if now != nil {
|
|
|
|
|
+ b = append(b, []byte(fmt.Sprintf("%d", now.Unix()))...)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
hash := sha1.Sum(b)
|
|
hash := sha1.Sum(b)
|
|
|
m.ID = int64(binary.BigEndian.Uint64(hash[:8]))
|
|
m.ID = int64(binary.BigEndian.Uint64(hash[:8]))
|
|
|
if m.ID < 0 {
|
|
if m.ID < 0 {
|