Commit 9f2bb7b3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 12a2af21
...@@ -203,21 +203,21 @@ func TestMasterStorage(t *testing.T) { ...@@ -203,21 +203,21 @@ func TestMasterStorage(t *testing.T) {
} }
// shortcut for NodeInfo // shortcut for NodeInfo
nodei := func(laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtstamp float64) neo.NodeInfo { nodei := func(laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtime neo.IdTime) neo.NodeInfo {
return neo.NodeInfo{ return 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, IdTime: idtime,
} }
} }
// shortcut for nodetab change // shortcut for nodetab change
node := func(x *neo.NodeApp, laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtstamp float64) *traceNode { node := func(x *neo.NodeApp, laddr string, typ neo.NodeType, num int32, state neo.NodeState, idtime neo.IdTime) *traceNode {
return &traceNode{ return &traceNode{
NodeTab: unsafe.Pointer(x.NodeTab), NodeTab: unsafe.Pointer(x.NodeTab),
NodeInfo: nodei(laddr, typ, num, state, idtstamp), NodeInfo: nodei(laddr, typ, num, state, idtime),
} }
} }
...@@ -229,7 +229,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -229,7 +229,7 @@ func TestMasterStorage(t *testing.T) {
gwg := &xsync.WorkGroup{} gwg := &xsync.WorkGroup{}
// start master // start master
Mclock := &vclock{100} Mclock := &vclock{}
M := NewMaster("abc1", ":1", Mhost) M := NewMaster("abc1", ":1", Mhost)
M.monotime = Mclock.monotime M.monotime = Mclock.monotime
Mctx, Mcancel := context.WithCancel(bg) Mctx, Mcancel := context.WithCancel(bg)
...@@ -241,7 +241,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -241,7 +241,7 @@ func TestMasterStorage(t *testing.T) {
// M starts listening // M starts listening
tc.Expect(netlisten("m:1")) tc.Expect(netlisten("m:1"))
tc.Expect(node(M.node, "m:1", neo.MASTER, 1, neo.RUNNING, 0)) tc.Expect(node(M.node, "m:1", neo.MASTER, 1, neo.RUNNING, neo.IdTimeNone))
tc.Expect(clusterState(&M.node.ClusterState, neo.ClusterRecovering)) tc.Expect(clusterState(&M.node.ClusterState, neo.ClusterRecovering))
// TODO create C; C tries connect to master - rejected ("not yet operational") // TODO create C; C tries connect to master - rejected ("not yet operational")
...@@ -266,10 +266,10 @@ func TestMasterStorage(t *testing.T) { ...@@ -266,10 +266,10 @@ func TestMasterStorage(t *testing.T) {
UUID: 0, UUID: 0,
Address: xnaddr("s:1"), Address: xnaddr("s:1"),
ClusterName: "abc1", ClusterName: "abc1",
IdTimestamp: 0, IdTime: neo.IdTimeNone,
})) }))
tc.Expect(node(M.node, "s:1", neo.STORAGE, 1, neo.PENDING, 100.01)) tc.Expect(node(M.node, "s:1", neo.STORAGE, 1, neo.PENDING, 0.01))
tc.Expect(conntx("m:2", "s:2", 1, &neo.AcceptIdentification{ tc.Expect(conntx("m:2", "s:2", 1, &neo.AcceptIdentification{
NodeType: neo.MASTER, NodeType: neo.MASTER,
...@@ -306,7 +306,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -306,7 +306,7 @@ func TestMasterStorage(t *testing.T) {
exc.Raiseif(err) exc.Raiseif(err)
}) })
tc.Expect(node(M.node, "s:1", neo.STORAGE, 1, neo.RUNNING, 100.01)) tc.Expect(node(M.node, "s:1", neo.STORAGE, 1, neo.RUNNING, 0.01))
xwait(wg) xwait(wg)
// XXX M.partTab <- S1 // XXX M.partTab <- S1
...@@ -364,10 +364,10 @@ func TestMasterStorage(t *testing.T) { ...@@ -364,10 +364,10 @@ func TestMasterStorage(t *testing.T) {
UUID: 0, UUID: 0,
Address: xnaddr(""), Address: xnaddr(""),
ClusterName: "abc1", ClusterName: "abc1",
IdTimestamp: 0, IdTime: neo.IdTimeNone,
})) }))
tc.Expect(node(M.node, "", neo.CLIENT, 1, neo.RUNNING, 100.02)) tc.Expect(node(M.node, "", neo.CLIENT, 1, neo.RUNNING, 0.02))
tc.Expect(conntx("m:3", "c:1", 1, &neo.AcceptIdentification{ tc.Expect(conntx("m:3", "c:1", 1, &neo.AcceptIdentification{
NodeType: neo.MASTER, NodeType: neo.MASTER,
...@@ -390,18 +390,18 @@ func TestMasterStorage(t *testing.T) { ...@@ -390,18 +390,18 @@ func TestMasterStorage(t *testing.T) {
// C <- M NotifyNodeInformation C1,M1,S1 // C <- M NotifyNodeInformation C1,M1,S1
// FIXME this might come in parallel with ^^^ "C asks M about PT" // FIXME this might come in parallel with ^^^ "C asks M about PT"
tc.Expect(conntx("m:3", "c:1", 0, &neo.NotifyNodeInformation{ tc.Expect(conntx("m:3", "c:1", 0, &neo.NotifyNodeInformation{
IdTimestamp: 0, // XXX ? IdTime: neo.IdTimeNone, // XXX ?
NodeList: []neo.NodeInfo{ NodeList: []neo.NodeInfo{
nodei("m:1", neo.MASTER, 1, neo.RUNNING, 0), nodei("m:1", neo.MASTER, 1, neo.RUNNING, neo.IdTimeNone),
nodei("s:1", neo.STORAGE, 1, neo.RUNNING, 100.01), nodei("s:1", neo.STORAGE, 1, neo.RUNNING, 0.01),
nodei("", neo.CLIENT, 1, neo.RUNNING, 100.02), nodei("", neo.CLIENT, 1, neo.RUNNING, 0.02),
}, },
})) }))
Cnode := *(**neo.NodeApp)(unsafe.Pointer(C)) // XXX hack, fragile Cnode := *(**neo.NodeApp)(unsafe.Pointer(C)) // XXX hack, fragile
tc.Expect(node(Cnode, "m:1", neo.MASTER, 1, neo.RUNNING, 0)) tc.Expect(node(Cnode, "m:1", neo.MASTER, 1, neo.RUNNING, neo.IdTimeNone))
tc.Expect(node(Cnode, "s:1", neo.STORAGE, 1, neo.RUNNING, 100.01)) tc.Expect(node(Cnode, "s:1", neo.STORAGE, 1, neo.RUNNING, 0.01))
tc.Expect(node(Cnode, "", neo.CLIENT, 1, neo.RUNNING, 100.02)) 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
...@@ -444,7 +444,7 @@ func TestMasterStorage(t *testing.T) { ...@@ -444,7 +444,7 @@ func TestMasterStorage(t *testing.T) {
UUID: neo.UUID(neo.CLIENT, 1), UUID: neo.UUID(neo.CLIENT, 1),
Address: xnaddr(""), Address: xnaddr(""),
ClusterName: "abc1", ClusterName: "abc1",
IdTimestamp: 0, // XXX ? IdTime: 0.02,
})) }))
tc.Expect(conntx("s:3", "c:2", 1, &neo.AcceptIdentification{ tc.Expect(conntx("s:3", "c:2", 1, &neo.AcceptIdentification{
......
...@@ -147,7 +147,7 @@ func (m *Master) Run(ctx context.Context) (err error) { ...@@ -147,7 +147,7 @@ func (m *Master) Run(ctx context.Context) (err error) {
Addr: naddr, Addr: naddr,
UUID: m.allocUUID(neo.MASTER), UUID: m.allocUUID(neo.MASTER),
State: neo.RUNNING, State: neo.RUNNING,
IdTimestamp: 0, // XXX ok? IdTime: neo.IdTimeNone, // XXX ok?
} }
// update nodeTab with self // update nodeTab with self
...@@ -979,7 +979,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e ...@@ -979,7 +979,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// XXX +ClusterState // XXX +ClusterState
err = link.Send1(&neo.NotifyNodeInformation{ err = link.Send1(&neo.NotifyNodeInformation{
IdTimestamp: 0, // XXX what here? IdTime: neo.IdTimeNone, // XXX what here?
NodeList: nodeiv, NodeList: nodeiv,
}) })
if err != nil { if err != nil {
...@@ -998,7 +998,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e ...@@ -998,7 +998,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
case nodeiv = <-nodech: case nodeiv = <-nodech:
msg = &neo.NotifyNodeInformation{ msg = &neo.NotifyNodeInformation{
IdTimestamp: 0, // XXX what here? IdTime: neo.IdTimeNone, // XXX what here?
NodeList: nodeiv, NodeList: nodeiv,
} }
} }
...@@ -1023,7 +1023,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e ...@@ -1023,7 +1023,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp neo.Msg) { func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp neo.Msg) {
// XXX also verify ? : // XXX also verify ? :
// - NodeType valid // - NodeType valid
// - IdTimestamp ? // - IdTime ?
uuid := n.idReq.UUID uuid := n.idReq.UUID
nodeType := n.idReq.NodeType nodeType := n.idReq.NodeType
...@@ -1098,7 +1098,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp ...@@ -1098,7 +1098,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
Addr: n.idReq.Address, Addr: n.idReq.Address,
UUID: uuid, UUID: uuid,
State: nodeState, State: nodeState,
IdTimestamp: m.monotime(), IdTime: neo.IdTime(m.monotime()),
} }
node = m.node.NodeTab.Update(nodeInfo) // NOTE this notifies all nodeTab subscribers node = m.node.NodeTab.Update(nodeInfo) // NOTE this notifies all nodeTab subscribers
......
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