Commit 030b0056 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e88063c9
......@@ -898,7 +898,7 @@ func (m *Master) serve(ctx context.Context) (err error) {
ctlStop = nil
nodeComeq = nil
// XXX tell storages to stop
// TODO tell storages to stop serving
}
for inprogress > 0 {
......@@ -941,7 +941,7 @@ func (m *Master) serve(ctx context.Context) (err error) {
return err
}
// storCtlServe drives a storage node during cluster serve state
// storCtlServe drives a storage node during cluster serve state.
func storCtlServe(ctx context.Context, stor *_MasteredPeer) (err error) {
defer task.Runningf(&ctx, "%s serve", stor.node.NID)(&err)
slink := stor.node.Link()
......@@ -959,8 +959,9 @@ func storCtlServe(ctx context.Context, stor *_MasteredPeer) (err error) {
//if err != nil {
// return err
//}
//req.Close() XXX must be after req handling
//switch msg := req.Msg.(type) {
//msg := req.Msg
//req.Close()
//switch msg := msg.(type) {
//case *proto.NotifyReady:
// // ok
//case *proto.Error:
......@@ -974,12 +975,11 @@ func storCtlServe(ctx context.Context, stor *_MasteredPeer) (err error) {
// TODO this should be also controlling transactions
for {
select {
// XXX stub
case <-time.After(1*time.Second):
//println(".")
case <-ctx.Done():
// FIXME also send StopOperation
// TODO also send StopOperation
return ctx.Err()
}
}
......@@ -1024,18 +1024,33 @@ func (m *Master) serveClient1(ctx context.Context, req proto.Msg) (resp proto.Ms
// disconnectPeer resets link to the peer and sets its state to DOWN in nodeTab.
// other peers are notified with δnodeTab about it.
// must be called from main.
// XXX place=?
func (m *Master) disconnectPeer(ctx context.Context, peer *_MasteredPeer) {
// XXX log?
log.Infof(ctx, "disconnecting %s", peer.node.NID)
peer.node.ResetLink(ctx)
delete(m.peerTab, peer.node.NID)
m.updateNodeState(ctx, peer.node, proto.DOWN)
}
// notifyAll notifies all peers about event.
// updateNodeTab = .nodeTab.Update + send δnodeTab to all subscribers.
// must be called from main.
// XXX place
func (m *Master) updateNodeTab(ctx context.Context, nodeInfo proto.NodeInfo) *xneo.PeerNode {
node := m.node.State.NodeTab.Update(nodeInfo)
m.notifyAll(ctx, &_ΔNodeTab{nodeInfo})
return node
}
// XXX place
// XXX doc
func (m *Master) updateNodeState(ctx context.Context, node *xneo.PeerNode, state proto.NodeState) {
nodei := node.NodeInfo
// XXX skip if .State == state ?
nodei.State = state
m.updateNodeTab(ctx, nodei)
}
// notifyAll notifies all peers about event.
// XXX place
func (m *Master) notifyAll(ctx context.Context, event _ΔClusterState) {
// XXX locking
for nid, peer := range m.peerTab {
......@@ -1057,24 +1072,6 @@ func (m *Master) notifyAll(ctx context.Context, event _ΔClusterState) {
}
// updateNodeTab = .nodeTab.Update + send δnodeTab to all subscribers.
// must be called from main.
// XXX place
func (m *Master) updateNodeTab(ctx context.Context, nodeInfo proto.NodeInfo) *xneo.PeerNode {
node := m.node.State.NodeTab.Update(nodeInfo)
m.notifyAll(ctx, &_ΔNodeTab{nodeInfo})
return node
}
// XXX place
// XXX doc
func (m *Master) updateNodeState(ctx context.Context, node *xneo.PeerNode, state proto.NodeState) {
nodei := node.NodeInfo
// XXX skip if .State == state ?
nodei.State = state
m.updateNodeTab(ctx, nodei)
}
// ----------------------------------------
......@@ -1336,10 +1333,7 @@ func (p *_MasteredPeer) notify(ctx context.Context) (err error) {
return nil
}
// allocNID allocates new node ID for a node of kind nodeType.
// XXX it is bad idea for master to assign node ID to coming node
// -> better nodes generate really unique UUID themselves and always show with them
func (m *Master) allocNID(nodeType proto.NodeType) proto.NodeID {
for num := int32(1); num < 1<<24; num++ {
nid := proto.NID(nodeType, num)
......
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