etcdserver: Member.storeKey -> memberStoreKey
This commit is contained in:
@ -60,7 +60,7 @@ func (s *clusterStore) Add(m Member) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("marshal error: %v", err)
|
log.Panicf("marshal error: %v", err)
|
||||||
}
|
}
|
||||||
if _, err := s.Store.Create(m.storeKey()+raftAttributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
if _, err := s.Store.Create(memberStoreKey(m.ID)+raftAttributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
||||||
log.Panicf("add raftAttributes should never fail: %v", err)
|
log.Panicf("add raftAttributes should never fail: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ func (s *clusterStore) Add(m Member) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("marshal error: %v", err)
|
log.Panicf("marshal error: %v", err)
|
||||||
}
|
}
|
||||||
if _, err := s.Store.Create(m.storeKey()+attributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
if _, err := s.Store.Create(memberStoreKey(m.ID)+attributesSuffix, false, string(b), false, store.Permanent); err != nil {
|
||||||
log.Panicf("add attributes should never fail: %v", err)
|
log.Panicf("add attributes should never fail: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ func nodeToMember(n *store.NodeExtern) (Member, error) {
|
|||||||
// Remove removes a member from the store.
|
// Remove removes a member from the store.
|
||||||
// The given id MUST exist.
|
// The given id MUST exist.
|
||||||
func (s *clusterStore) Remove(id uint64) {
|
func (s *clusterStore) Remove(id uint64) {
|
||||||
if _, err := s.Store.Delete(Member{ID: id}.storeKey(), true, true); err != nil {
|
if _, err := s.Store.Delete(memberStoreKey(id), true, true); err != nil {
|
||||||
log.Panicf("delete peer should never fail: %v", err)
|
log.Panicf("delete peer should never fail: %v", err)
|
||||||
}
|
}
|
||||||
if _, err := s.Store.Create(removedMemberStoreKey(id), false, "", false, store.Permanent); err != nil {
|
if _, err := s.Store.Create(removedMemberStoreKey(id), false, "", false, store.Permanent); err != nil {
|
||||||
|
@ -114,7 +114,7 @@ func TestClusterStoreRemove(t *testing.T) {
|
|||||||
cs.Remove(1)
|
cs.Remove(1)
|
||||||
|
|
||||||
wactions := []action{
|
wactions := []action{
|
||||||
{name: "Delete", params: []interface{}{Member{ID: 1}.storeKey(), true, true}},
|
{name: "Delete", params: []interface{}{memberStoreKey(1), true, true}},
|
||||||
{name: "Create", params: []interface{}{removedMemberStoreKey(1), false, "", false, store.Permanent}},
|
{name: "Create", params: []interface{}{removedMemberStoreKey(1), false, "", false, store.Permanent}},
|
||||||
}
|
}
|
||||||
if !reflect.DeepEqual(st.Action(), wactions) {
|
if !reflect.DeepEqual(st.Action(), wactions) {
|
||||||
|
@ -68,8 +68,8 @@ func newMember(name string, peerURLs types.URLs, now *time.Time) *Member {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Member) storeKey() string {
|
func memberStoreKey(id uint64) string {
|
||||||
return path.Join(storeMembersPrefix, idAsHex(m.ID))
|
return path.Join(storeMembersPrefix, idAsHex(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseMemberID(key string) uint64 {
|
func parseMemberID(key string) uint64 {
|
||||||
|
@ -496,7 +496,7 @@ func (s *EtcdServer) publish(retryInterval time.Duration) {
|
|||||||
req := pb.Request{
|
req := pb.Request{
|
||||||
ID: GenID(),
|
ID: GenID(),
|
||||||
Method: "PUT",
|
Method: "PUT",
|
||||||
Path: Member{ID: s.id}.storeKey() + attributesSuffix,
|
Path: memberStoreKey(s.id) + attributesSuffix,
|
||||||
Val: string(b),
|
Val: string(b),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -967,7 +967,7 @@ func TestPublish(t *testing.T) {
|
|||||||
t.Errorf("method = %s, want PUT", r.Method)
|
t.Errorf("method = %s, want PUT", r.Method)
|
||||||
}
|
}
|
||||||
wm := Member{ID: 1, Attributes: Attributes{Name: "node1", ClientURLs: []string{"http://a", "http://b"}}}
|
wm := Member{ID: 1, Attributes: Attributes{Name: "node1", ClientURLs: []string{"http://a", "http://b"}}}
|
||||||
if w := wm.storeKey() + attributesSuffix; r.Path != w {
|
if w := memberStoreKey(wm.ID) + attributesSuffix; r.Path != w {
|
||||||
t.Errorf("path = %s, want %s", r.Path, w)
|
t.Errorf("path = %s, want %s", r.Path, w)
|
||||||
}
|
}
|
||||||
var gattr Attributes
|
var gattr Attributes
|
||||||
|
Reference in New Issue
Block a user