Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
54137dd2
Commit
54137dd2
authored
Feb 18, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
030b0056
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
103 deletions
+4
-103
go/neo/master.go
go/neo/master.go
+4
-6
go/neo/xneo/nodetab.go
go/neo/xneo/nodetab.go
+0
-97
No files found.
go/neo/master.go
View file @
54137dd2
...
...
@@ -1033,18 +1033,16 @@ func (m *Master) disconnectPeer(ctx context.Context, peer *_MasteredPeer) {
// 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
{
log
.
Infof
(
ctx
,
"nodeTab[%s] <- %s"
,
nodeInfo
.
NID
,
nodeInfo
)
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 ?
// updateNodeState updates nodeTab[peer.nid].state = state
func
(
m
*
Master
)
updateNodeState
(
ctx
context
.
Context
,
peer
*
xneo
.
PeerNode
,
state
proto
.
NodeState
)
{
nodei
:=
peer
.
NodeInfo
nodei
.
State
=
state
m
.
updateNodeTab
(
ctx
,
nodei
)
}
...
...
go/neo/xneo/nodetab.go
View file @
54137dd2
...
...
@@ -69,7 +69,6 @@ type NodeTable struct {
localNode
*
Node
nodev
[]
*
PeerNode
// all nodes
// notifyv []chan proto.NodeInfo // subscribers
}
//trace:event traceNodeChanged(nt *NodeTable, n *PeerNode)
...
...
@@ -138,8 +137,6 @@ func (nt *NodeTable) Update(nodeInfo proto.NodeInfo) *PeerNode {
// XXX close link if .state becomes DOWN ?
traceNodeChanged
(
nt
,
node
)
// nt.notify(node.NodeInfo) XXX kill
return
node
}
...
...
@@ -156,16 +153,6 @@ func (nt *NodeTable) StorageList() []*PeerNode {
}
/*
// XXX doc
func (n *PeerNode) SetState(state proto.NodeState) {
n.State = state
traceNodeChanged(n.nodeTab, n)
n.nodeTab.notify(n.NodeInfo)
}
*/
func
(
nt
*
NodeTable
)
String
()
string
{
buf
:=
bytes
.
Buffer
{}
...
...
@@ -179,90 +166,6 @@ func (nt *NodeTable) String() string {
return
buf
.
String
()
}
/*
// ---- subscription to nodetab updates ----
// XXX used only by M -> move into M?
// notify notifies NodeTable subscribers that nodeInfo was updated
func (nt *NodeTable) notify(nodeInfo proto.NodeInfo) {
// XXX rlock for .notifyv ?
for _, notify := range nt.notifyv {
notify <- nodeInfo
}
}
// Subscribe subscribes to NodeTable updates.
//
// It returns a channel via which updates will be delivered and function to unsubscribe.
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
func (nt *NodeTable) Subscribe() (ch chan proto.NodeInfo, unsubscribe func()) {
ch = make(chan proto.NodeInfo) // XXX how to specify ch buf size if needed ?
nt.notifyv = append(nt.notifyv, ch)
unsubscribe = func() {
for i, c := range nt.notifyv {
if c == ch {
nt.notifyv = append(nt.notifyv[:i], nt.notifyv[i+1:]...)
close(ch)
return
}
}
panic("XXX unsubscribe not subscribed channel")
}
return ch, unsubscribe
}
// SubscribeBuffered subscribes to NodeTable updates without blocking updater.
//
// It returns a channel via which updates are delivered and unsubscribe function.
// The updates will be sent to destination in non-blocking way - if destination
// channel is not ready they will be buffered.
// It is the caller responsibility to make sure such buffering does not grow up
// to infinity - via e.g. detecting stuck connections and unsubscribing on shutdown.
//
// XXX locking: client for subscribe/unsubscribe XXX ok?
func (nt *NodeTable) SubscribeBuffered() (ch chan []proto.NodeInfo, unsubscribe func()) {
in, unsubscribe := nt.Subscribe()
ch = make(chan []proto.NodeInfo)
go func() {
var updatev []proto.NodeInfo
shutdown := false
for {
out := ch
if len(updatev) == 0 {
if shutdown {
// nothing to send and source channel closed
// -> close destination and stop
close(ch)
break
}
out = nil
}
select {
case update, ok := <-in:
if !ok {
shutdown = true
break
}
// FIXME merge updates as same node could be updated several times
updatev = append(updatev, update)
case out <- updatev:
updatev = nil
}
}
}()
return ch, unsubscribe
}
*/
// ---- peer link ----
// TODO review peer link dialing / setting / accepting.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment