Commit ca492f72 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c8857f53
...@@ -117,6 +117,7 @@ type _MasteredPeer struct { ...@@ -117,6 +117,7 @@ type _MasteredPeer struct {
node *xneo.PeerNode node *xneo.PeerNode
// all tasks are spawned under wg. If any task fails - whole wg is canceled. // all tasks are spawned under wg. If any task fails - whole wg is canceled.
// When wg is done, main is signalled that "peer (should be) disconnected".
// cancel signals all tasks under wg to stop. // cancel signals all tasks under wg to stop.
wg *xsync.WorkGroup wg *xsync.WorkGroup
cancel func() cancel func()
...@@ -129,7 +130,7 @@ type _MasteredPeer struct { ...@@ -129,7 +130,7 @@ type _MasteredPeer struct {
// XXX no need? (peer.notify is canceled via peerWork.cancel) // XXX no need? (peer.notify is canceled via peerWork.cancel)
notifyqOverflow chan struct{} notifyqOverflow chan struct{}
acceptDone chan struct{} // ready after initial accept sequence is sent to the peer acceptSent chan struct{} // ready after initial accept sequence is sent to the peer
} }
// _ΔClusterState represents δnodeTab/δpartTab/δClusterState. // _ΔClusterState represents δnodeTab/δpartTab/δClusterState.
...@@ -138,7 +139,7 @@ type _ΔNodeTab struct { ...@@ -138,7 +139,7 @@ type _ΔNodeTab struct {
proto.NodeInfo // new value for change of 1 nodeTab entry proto.NodeInfo // new value for change of 1 nodeTab entry
} }
type _ΔPartTab struct { type _ΔPartTab struct {
// XXX // TODO
} }
type _ΔStateCode struct { type _ΔStateCode struct {
proto.ClusterState // new value proto.ClusterState // new value
...@@ -192,12 +193,6 @@ func (m *Master) Stop() { ...@@ -192,12 +193,6 @@ func (m *Master) Stop() {
<-ech <-ech
} }
// Shutdown requests all known nodes in the cluster to stop.
// XXX + master's run to finish ?
func (m *Master) Shutdown() error {
panic("TODO")
}
// setClusterState sets .clusterState and notifies subscribers. // setClusterState sets .clusterState and notifies subscribers.
func (m *Master) setClusterState(state proto.ClusterState) { func (m *Master) setClusterState(state proto.ClusterState) {
...@@ -1199,7 +1194,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (peer *_MasteredPeer, ...@@ -1199,7 +1194,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (peer *_MasteredPeer,
// (see updateNodeTab for details) // (see updateNodeTab for details)
notifyq: make(chan _ΔClusterState, 1024), notifyq: make(chan _ΔClusterState, 1024),
notifyqOverflow: make(chan struct{}), notifyqOverflow: make(chan struct{}),
acceptDone: make(chan struct{}), acceptSent: make(chan struct{}),
} }
m.peerTab[node.NID] = peer m.peerTab[node.NID] = peer
...@@ -1254,7 +1249,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (peer *_MasteredPeer, ...@@ -1254,7 +1249,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (peer *_MasteredPeer,
// XXX send clusterState too? (NEO/py does not send it) // XXX send clusterState too? (NEO/py does not send it)
// indicate to run that initial acceptance is done // indicate to run that initial acceptance is done
close(peer.acceptDone) close(peer.acceptSent)
// proxy δnodeTab,δpartTab/δclusterState from main to the peer // proxy δnodeTab,δpartTab/δclusterState from main to the peer
return peer.notify(ctx) return peer.notify(ctx)
...@@ -1279,7 +1274,7 @@ func (p *_MasteredPeer) run(ctx context.Context, f func() error) error { ...@@ -1279,7 +1274,7 @@ func (p *_MasteredPeer) run(ctx context.Context, f func() error) error {
// as that means accept0 task error, it would cancel ctx for all other // as that means accept0 task error, it would cancel ctx for all other
// tasks run through p.wg . And run is called with contexts whose // tasks run through p.wg . And run is called with contexts whose
// cancel is derived from wg cancel - so we don't check for that. XXX // cancel is derived from wg cancel - so we don't check for that. XXX
case <-p.acceptDone: case <-p.acceptSent:
return f() return f()
} }
} }
......
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