Commit 17a95c4f authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4e33b5f7
...@@ -82,8 +82,9 @@ func NewClient(clusterName, masterAddr string, net xnet.Networker) *Client { ...@@ -82,8 +82,9 @@ func NewClient(clusterName, masterAddr string, net xnet.Networker) *Client {
Net: net, Net: net,
MasterAddr: masterAddr, MasterAddr: masterAddr,
//NodeTab: &neo.NodeTable{}, NodeTab: &neo.NodeTable{},
//PartTab: &neo.PartitionTable{}, PartTab: &neo.PartitionTable{},
ClusterState: -1, // invalid
}, },
mlinkReady: make(chan struct{}), mlinkReady: make(chan struct{}),
...@@ -270,9 +271,13 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error { ...@@ -270,9 +271,13 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
case *neo.NotifyNodeInformation: case *neo.NotifyNodeInformation:
// XXX msg.IdTimestamp ? // XXX msg.IdTimestamp ?
for _, nodeInfo := range msg.NodeList { for _, nodeInfo := range msg.NodeList {
log.Infof(ctx, "rx peer update: %v", nodeInfo)
c.node.NodeTab.Update(nodeInfo, /*XXX conn should not be here*/nil) c.node.NodeTab.Update(nodeInfo, /*XXX conn should not be here*/nil)
} }
// FIXME logging under lock
log.Infof(ctx, "full nodetab:\n%s", c.node.NodeTab)
case *neo.NotifyClusterState: case *neo.NotifyClusterState:
c.node.ClusterState.Set(msg.State) c.node.ClusterState.Set(msg.State)
} }
......
//go:generate stringer -output zproto-str.go -type ErrorCode,NodeType proto.go //go:generate stringer -output zproto-str.go -type ErrorCode,NodeType,NodeState proto.go
package neo package neo
// supporting code for types defined in proto.go // supporting code for types defined in proto.go
......
...@@ -199,28 +199,22 @@ func TestMasterStorage(t *testing.T) { ...@@ -199,28 +199,22 @@ func TestMasterStorage(t *testing.T) {
return &traceNeoSend{Src: xaddr(src), Dst: xaddr(dst), ConnID: connid, Msg: msg} return &traceNeoSend{Src: xaddr(src), Dst: xaddr(dst), ConnID: connid, Msg: msg}
} }
// shortcut for nodetab change // shortcut for NodeInfo
node := func(x *neo.NodeCommon, laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtstamp float64) *traceNode { nodei := func(laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtstamp float64) neo.NodeInfo {
return &traceNode{ return neo.NodeInfo{
NodeTab: unsafe.Pointer(x.NodeTab),
NodeInfo: neo.NodeInfo{
Type: typ, Type: typ,
Addr: xnaddr(laddr), Addr: xnaddr(laddr),
UUID: neo.UUID(typ, num), UUID: neo.UUID(typ, num),
State: state, State: state,
IdTimestamp: idtstamp, IdTimestamp: idtstamp,
},
} }
} }
// shortcut for NodeInfo // shortcut for nodetab change
nodei := func(typ neo.NodeType, addr string, uuid neo.NodeUUID, state neo.NodeState, idtstamp float64) neo.NodeInfo { node := func(x *neo.NodeCommon, laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtstamp float64) *traceNode {
return neo.NodeInfo{ return &traceNode{
Type: typ, NodeTab: unsafe.Pointer(x.NodeTab),
Addr: xnaddr(addr), NodeInfo: nodei(laddr, typ, num, state, idtstamp),
UUID: uuid,
State: state,
IdTimestamp: idtstamp,
} }
} }
...@@ -380,16 +374,6 @@ func TestMasterStorage(t *testing.T) { ...@@ -380,16 +374,6 @@ func TestMasterStorage(t *testing.T) {
YourUUID: neo.UUID(neo.CLIENT, 1), YourUUID: neo.UUID(neo.CLIENT, 1),
})) }))
// C <- M NotifyNodeInformation C1,M1,S1
tc.Expect(conntx("m:3", "c:1", 2, &neo.NotifyNodeInformation{
IdTimestamp: 0, // XXX ?
NodeList: []neo.NodeInfo{
nodei(neo.MASTER, "m:1", neo.UUID(neo.MASTER, 1), neo.RUNNING, 0.00),
nodei(neo.STORAGE, "s:1", neo.UUID(neo.STORAGE, 1), neo.RUNNING, 0.01),
nodei(neo.STORAGE, "", neo.UUID(neo.CLIENT, 1), neo.RUNNING, 0.02),
},
}))
// C asks M about PT // C asks M about PT
tc.Expect(conntx("c:1", "m:3", 3, &neo.AskPartitionTable{})) tc.Expect(conntx("c:1", "m:3", 3, &neo.AskPartitionTable{}))
tc.Expect(conntx("m:3", "c:1", 3, &neo.AnswerPartitionTable{ tc.Expect(conntx("m:3", "c:1", 3, &neo.AnswerPartitionTable{
...@@ -399,6 +383,21 @@ func TestMasterStorage(t *testing.T) { ...@@ -399,6 +383,21 @@ func TestMasterStorage(t *testing.T) {
}, },
})) }))
// C <- M NotifyNodeInformation C1,M1,S1
tc.Expect(conntx("m:3", "c:1", 0, &neo.NotifyNodeInformation{
IdTimestamp: 0, // XXX ?
NodeList: []neo.NodeInfo{
nodei("m:1", neo.MASTER, 1, neo.RUNNING, 0.00),
nodei("s:1", neo.STORAGE, 1, neo.RUNNING, 0.01),
nodei("", neo.CLIENT, 1, neo.RUNNING, 0.02),
},
}))
Cnode := (*neo.NodeCommon)(unsafe.Pointer(C)) // XXX hack
tc.Expect(node(Cnode, "m:1", neo.MASTER, 1, neo.RUNNING, 0.00))
tc.Expect(node(Cnode, "s:1", neo.STORAGE, 1, neo.RUNNING, 0.01))
tc.Expect(node(Cnode, "", neo.CLIENT, 1, neo.RUNNING, 0.02))
// C asks M about last tid XXX better master sends it itself on new client connected // C asks M about last tid XXX better master sends it itself on new client connected
wg = &xsync.WorkGroup{} wg = &xsync.WorkGroup{}
......
// Code generated by "stringer -output zproto-str.go -type ErrorCode,NodeType proto.go"; DO NOT EDIT. // Code generated by "stringer -output zproto-str.go -type ErrorCode,NodeType,NodeState proto.go"; DO NOT EDIT.
package neo package neo
...@@ -25,3 +25,14 @@ func (i NodeType) String() string { ...@@ -25,3 +25,14 @@ func (i NodeType) String() string {
} }
return _NodeType_name[_NodeType_index[i]:_NodeType_index[i+1]] return _NodeType_name[_NodeType_index[i]:_NodeType_index[i+1]]
} }
const _NodeState_name = "UNKNOWNDOWNRUNNINGPENDING"
var _NodeState_index = [...]uint8{0, 7, 11, 18, 25}
func (i NodeState) String() string {
if i < 0 || i >= NodeState(len(_NodeState_index)-1) {
return fmt.Sprintf("NodeState(%d)", i)
}
return _NodeState_name[_NodeState_index[i]:_NodeState_index[i+1]]
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment