Commit 5a6ce3e2 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 598538fd
...@@ -40,7 +40,10 @@ import ( ...@@ -40,7 +40,10 @@ import (
// _MasteredNode provides base functioanlity of a NEO node driven by master. // _MasteredNode provides base functioanlity of a NEO node driven by master.
// //
// talkMaster persists connection to master node, adn receives update from M // XXX requests/notifications from master go through filter that handles
// nodeTab/partTab/ClusterState changes ...
//
// talkMaster persists connection to master node, and receives update from M
// about δNodeTab, δPartTab, ClusterState. // about δNodeTab, δPartTab, ClusterState.
// //
// XXX how to use // XXX how to use
...@@ -110,10 +113,12 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker, ...@@ -110,10 +113,12 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker,
// talkMaster dials master, identifies to it, and receives master updates to // talkMaster dials master, identifies to it, and receives master notifications and requests.
// node/partition tables and cluster state. //
// Notifications to node/partition tables and cluster state are automatically
// handled, while other notifications and requests are passed through to RecvM1.
// //
// XXX connection to master is persisted (redial) // The connection to master is persisted by redial as needed.
func (node *_MasteredNode) talkMaster(ctx context.Context) (err error) { func (node *_MasteredNode) talkMaster(ctx context.Context) (err error) {
defer task.Runningf(&ctx, "talk master(%s)", node.MasterAddr)(&err) defer task.Runningf(&ctx, "talk master(%s)", node.MasterAddr)(&err)
...@@ -136,7 +141,7 @@ func (node *_MasteredNode) talkMaster(ctx context.Context) (err error) { ...@@ -136,7 +141,7 @@ func (node *_MasteredNode) talkMaster(ctx context.Context) (err error) {
} }
} }
func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) { func (node *_MasteredNode) talkMaster1(ctx context.Context) error {
reqID := &proto.RequestIdentification{ reqID := &proto.RequestIdentification{
NodeType: node.myInfo.Type, NodeType: node.myInfo.Type,
NID: node.myInfo.NID, NID: node.myInfo.NID,
...@@ -151,7 +156,7 @@ func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) { ...@@ -151,7 +156,7 @@ func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) {
return err return err
} }
err = xcontext.WithCloseOnErrCancel(ctx, mlink, func() error { return xcontext.WithCloseOnErrCancel(ctx, mlink, func() (err error) {
if accept.YourNID != node.myInfo.NID { if accept.YourNID != node.myInfo.NID {
log.Infof(ctx, "master told us to have nid=%s", accept.YourNID) log.Infof(ctx, "master told us to have nid=%s", accept.YourNID)
node.myInfo.NID = accept.YourNID // XXX locking ? node.myInfo.NID = accept.YourNID // XXX locking ?
...@@ -179,23 +184,18 @@ func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) { ...@@ -179,23 +184,18 @@ func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) {
// update cluster state // update cluster state
// XXX locking // XXX locking
err := node.updateNodeTab(ctx, &mnt) node.stateMu.Lock()
if err != nil { err = node.updateNodeTab(ctx, &mnt)
return err
}
node.state.PartTab = pt node.state.PartTab = pt
// XXX update "operational" // XXX update "operational"
node.stateMu.Unlock()
if err != nil { // might be command to shutdown
return err
}
// XXX update .masterLink + notify waiters // XXX update .masterLink + notify waiters
return nil
})
if err != nil {
// XXX
}
// receive and handle notifications from master // receive and handle notifications from master
// XXX put inside ^^^ ?
defer task.Running(&ctx, "rx")(&err) defer task.Running(&ctx, "rx")(&err)
for { for {
req, err := mlink.Recv1() req, err := mlink.Recv1()
...@@ -208,6 +208,8 @@ func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) { ...@@ -208,6 +208,8 @@ func (node *_MasteredNode) talkMaster1(ctx context.Context) (err error) {
return err return err
} }
} }
})
} }
// recvMaster1 handles 1 message from master. // recvMaster1 handles 1 message from master.
......
...@@ -168,8 +168,8 @@ type NodeLink struct { ...@@ -168,8 +168,8 @@ type NodeLink struct {
// Encoding returns protocol encoding with which the link was handshaked. XXX // Encoding returns protocol encoding with which the link was handshaked. XXX
// XXX place // XXX place
func (nl *NodeLink) Encoding() proto.Encoding { func (link *NodeLink) Encoding() proto.Encoding {
return nl.enc return link.enc
} }
// XXX rx handoff make latency better for serial request-reply scenario but // XXX rx handoff make latency better for serial request-reply scenario but
......
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