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
01bae9f2
Commit
01bae9f2
authored
Feb 05, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d95400c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
23 deletions
+31
-23
go/neo/master.go
go/neo/master.go
+30
-22
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+1
-1
No files found.
go/neo/master.go
View file @
01bae9f2
...
@@ -356,7 +356,7 @@ loop:
...
@@ -356,7 +356,7 @@ loop:
// new connection comes in
// new connection comes in
case
n
:=
<-
m
.
nodeCome
:
case
n
:=
<-
m
.
nodeCome
:
// FIXME if identify=ok -> subscribe to δ(nodeTab) and send initial nodeTab right after accept (accept should do it?)
// FIXME if identify=ok -> subscribe to δ(nodeTab) and send initial nodeTab right after accept (accept should do it?)
node
,
resp
:=
m
.
identify
(
ctx
,
n
,
/* XXX only accept storages -> PENDING */
)
node
,
state0
,
resp
:=
m
.
identify
(
ctx
,
n
,
/* XXX only accept storages -> PENDING */
)
if
node
==
nil
{
if
node
==
nil
{
goreject
(
ctx
,
wg
,
n
.
req
,
resp
)
goreject
(
ctx
,
wg
,
n
.
req
,
resp
)
...
@@ -369,7 +369,7 @@ loop:
...
@@ -369,7 +369,7 @@ loop:
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
err
:=
m
.
accept
(
ctx
,
n
.
req
,
resp
)
err
:=
m
.
accept
(
node
,
state0
,
n
.
req
,
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
recovery
<-
storRecovery
{
stor
:
node
,
err
:
err
}
recovery
<-
storRecovery
{
stor
:
node
,
err
:
err
}
return
return
...
@@ -609,7 +609,7 @@ loop:
...
@@ -609,7 +609,7 @@ loop:
for
inprogress
>
0
{
for
inprogress
>
0
{
select
{
select
{
case
n
:=
<-
m
.
nodeCome
:
case
n
:=
<-
m
.
nodeCome
:
node
,
resp
:=
m
.
identify
(
ctx
,
n
,
/* XXX only accept storages -> known ? RUNNING : PENDING */
)
node
,
state0
,
resp
:=
m
.
identify
(
ctx
,
n
,
/* XXX only accept storages -> known ? RUNNING : PENDING */
)
if
node
==
nil
{
if
node
==
nil
{
goreject
(
ctx
,
wg
,
n
.
req
,
resp
)
goreject
(
ctx
,
wg
,
n
.
req
,
resp
)
...
@@ -622,7 +622,7 @@ loop:
...
@@ -622,7 +622,7 @@ loop:
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
err
:=
m
.
accept
(
ctx
,
n
.
req
,
resp
)
err
:=
m
.
accept
(
node
,
state0
,
n
.
req
,
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
verify
<-
storVerify
{
stor
:
node
,
err
:
err
}
verify
<-
storVerify
{
stor
:
node
,
err
:
err
}
return
return
...
@@ -822,7 +822,7 @@ loop:
...
@@ -822,7 +822,7 @@ loop:
select
{
select
{
// new connection comes in
// new connection comes in
case
n
:=
<-
m
.
nodeCome
:
case
n
:=
<-
m
.
nodeCome
:
node
,
resp
:=
m
.
identify
(
ctx
,
n
,
/* XXX accept everyone */
)
node
,
state0
,
resp
:=
m
.
identify
(
ctx
,
n
,
/* XXX accept everyone */
)
if
node
==
nil
{
if
node
==
nil
{
goreject
(
ctx
,
wg
,
n
.
req
,
resp
)
goreject
(
ctx
,
wg
,
n
.
req
,
resp
)
...
@@ -833,7 +833,7 @@ loop:
...
@@ -833,7 +833,7 @@ loop:
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
err
=
m
.
accept
(
ctx
,
n
.
req
,
resp
)
err
=
m
.
accept
(
node
,
state0
,
n
.
req
,
resp
)
if
err
!=
nil
{
if
err
!=
nil
{
serviced
<-
serviceDone
{
node
:
node
,
err
:
err
}
serviced
<-
serviceDone
{
node
:
node
,
err
:
err
}
return
return
...
@@ -988,8 +988,8 @@ func (m *Master) serveClient1(ctx context.Context, req proto.Msg) (resp proto.Ms
...
@@ -988,8 +988,8 @@ func (m *Master) serveClient1(ctx context.Context, req proto.Msg) (resp proto.Ms
// XXX place
// XXX place
// called from main master process. XXX
// called from main master process. XXX
func
(
m
*
Master
)
updateNodeTab
(
ctx
context
.
Context
,
nodeInfo
proto
.
NodeInfo
)
{
func
(
m
*
Master
)
updateNodeTab
(
ctx
context
.
Context
,
nodeInfo
proto
.
NodeInfo
)
*
xneo
.
PeerNode
{
m
.
node
.
State
.
NodeTab
.
Update
(
nodeInfo
)
peer
:=
m
.
node
.
State
.
NodeTab
.
Update
(
nodeInfo
)
event
:=
&
_ΔNodeTab
{
nodeInfo
}
event
:=
&
_ΔNodeTab
{
nodeInfo
}
// XXX locking
// XXX locking
...
@@ -1005,6 +1005,8 @@ func (m *Master) updateNodeTab(ctx context.Context, nodeInfo proto.NodeInfo) {
...
@@ -1005,6 +1005,8 @@ func (m *Master) updateNodeTab(ctx context.Context, nodeInfo proto.NodeInfo) {
log
.
Warningf
(
ctx
,
"peer %s is slow -> detaching it"
,
nid
)
log
.
Warningf
(
ctx
,
"peer %s is slow -> detaching it"
,
nid
)
// TODO ^^^
// TODO ^^^
}
}
return
peer
}
}
// XXX place
// XXX place
...
@@ -1109,7 +1111,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neonet.NodeLink) (er
...
@@ -1109,7 +1111,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neonet.NodeLink) (er
// If node identification is accepted .nodeTab is updated and corresponding node entry is returned.
// If node identification is accepted .nodeTab is updated and corresponding node entry is returned.
// Response message is constructed but not send back not to block the caller - it is
// Response message is constructed but not send back not to block the caller - it is
// the caller responsibility to send the response to node which requested identification.
// the caller responsibility to send the response to node which requested identification.
func
(
m
*
Master
)
identify
(
ctx
context
.
Context
,
n
nodeCome
)
(
node
*
xneo
.
PeerNode
,
resp
proto
.
Msg
)
{
func
(
m
*
Master
)
identify
(
ctx
context
.
Context
,
n
nodeCome
)
(
node
*
xneo
.
PeerNode
,
state0
*
xneo
.
ClusterStateSnapshot
,
resp
proto
.
Msg
)
{
// XXX also verify ? :
// XXX also verify ? :
// - NodeType valid
// - NodeType valid
// - IdTime ?
// - IdTime ?
...
@@ -1158,7 +1160,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *xneo.PeerNode,
...
@@ -1158,7 +1160,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *xneo.PeerNode,
subj
:=
fmt
.
Sprintf
(
"identify: %s (%s)"
,
n
.
req
.
Link
()
.
RemoteAddr
(),
n
.
idReq
.
NID
)
subj
:=
fmt
.
Sprintf
(
"identify: %s (%s)"
,
n
.
req
.
Link
()
.
RemoteAddr
(),
n
.
idReq
.
NID
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Infof
(
ctx
,
"%s: rejecting: %s"
,
subj
,
err
)
log
.
Infof
(
ctx
,
"%s: rejecting: %s"
,
subj
,
err
)
return
nil
,
err
return
nil
,
nil
,
err
}
}
log
.
Infof
(
ctx
,
"%s: accepting as %s"
,
subj
,
nid
)
log
.
Infof
(
ctx
,
"%s: accepting as %s"
,
subj
,
nid
)
...
@@ -1193,7 +1195,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *xneo.PeerNode,
...
@@ -1193,7 +1195,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *xneo.PeerNode,
node
.
SetLink
(
n
.
req
.
Link
())
node
.
SetLink
(
n
.
req
.
Link
())
// make nodeTab/partTab snapshot to push to accepted node and subscribe it for updates
// make nodeTab/partTab snapshot to push to accepted node and subscribe it for updates
state0
:
=
m
.
node
.
State
.
Snapshot
()
state0
=
m
.
node
.
State
.
Snapshot
()
// TODO change limiting by buffer size -> to limiting by time
// TODO change limiting by buffer size -> to limiting by time
// (see updateNodeTab for details)
// (see updateNodeTab for details)
notifyq
:=
make
(
chan
_ΔClusterState
,
1024
)
notifyq
:=
make
(
chan
_ΔClusterState
,
1024
)
...
@@ -1206,26 +1208,30 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *xneo.PeerNode,
...
@@ -1206,26 +1208,30 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *xneo.PeerNode,
}()
}()
*/
*/
return
node
,
accept
return
node
,
state0
,
accept
}
}
func
(
m
*
Master
)
accept
(
peer
*
xneo
.
PeerNode
,
idReq
*
neonet
.
Request
,
idResp
proto
.
Msg
)
error
{
// accept sends acceptance to just identified peer, sends nodeTab and partTab
// and spawns task to proxy their updates to the peer. XXX
func
(
m
*
Master
)
accept
(
peer
*
xneo
.
PeerNode
,
state0
*
xneo
.
ClusterStateSnapshot
,
idReq
*
neonet
.
Request
,
idResp
proto
.
Msg
)
error
{
err
:=
idReq
.
Reply
(
idResp
)
err
:=
idReq
.
Reply
(
idResp
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"send accept: %w"
,
err
)
return
fmt
.
Errorf
(
"send accept: %w"
,
err
)
}
}
// XXX idReq close?
// send initial state snapshot to accepted node
// send initial state snapshot to accepted node
link
:=
peer
.
Link
()
// XXX -> idReq.Link() instead?
// nodeTab
// nodeTab
err
=
link
.
Send1
(
state0
.
nodeTab
)
// = proto.NotifyNodeInformation{
err
=
link
.
Send1
(
&
state0
.
NodeTab
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"send nodeTab: %w"
,
err
)
return
fmt
.
Errorf
(
"send nodeTab: %w"
,
err
)
}
}
// partTab (not to S until cluster is RUNNING)
// partTab (not to S until cluster is RUNNING)
if
!
(
peer
.
NodeType
==
proto
.
STORAGE
&&
cs
.
State
Code
!=
proto
.
ClusterRunning
)
{
if
!
(
peer
.
Type
==
proto
.
STORAGE
&&
state0
.
Code
!=
proto
.
ClusterRunning
)
{
err
=
link
.
Send1
(
state0
.
p
artTab
)
err
=
link
.
Send1
(
&
state0
.
P
artTab
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"send partTab: %w"
,
err
)
return
fmt
.
Errorf
(
"send partTab: %w"
,
err
)
}
}
...
@@ -1239,7 +1245,7 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
...
@@ -1239,7 +1245,7 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
wg
.
Go
(
func
(
ctx
context
.
Context
)
(
err
error
)
{
wg
.
Go
(
func
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Runningf
(
&
ctx
,
"send cluster updates"
)(
&
err
)
defer
task
.
Runningf
(
&
ctx
,
"send cluster updates"
)(
&
err
)
stateCode
==
state0
.
State
Code
stateCode
:=
state0
.
Code
for
{
for
{
var
δstate
_ΔClusterState
var
δstate
_ΔClusterState
...
@@ -1255,13 +1261,13 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
...
@@ -1255,13 +1261,13 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
switch
δstate
:=
δstate
.
(
type
)
{
switch
δstate
:=
δstate
.
(
type
)
{
case
*
_ΔNodeTab
:
case
*
_ΔNodeTab
:
msg
=
&
proto
.
NotifyNodeInformation
{
msg
=
&
proto
.
NotifyNodeInformation
{
IdTime
:
...
,
IdTime
:
proto
.
IdTimeNone
,
// FIXME
NodeList
:
[]
NodeInfo
{
δstate
.
NodeInfo
},
NodeList
:
[]
proto
.
NodeInfo
{
δstate
.
NodeInfo
},
}
}
case
*
_ΔPartTab
:
case
*
_ΔPartTab
:
// don't send δpartTab to S unless cluster is RUNNING
// don't send δpartTab to S unless cluster is RUNNING
if
peer
.
NodeType
==
proto
.
STORAGE
&&
stateCode
!=
ClusterRunning
{
if
peer
.
Type
==
proto
.
STORAGE
&&
stateCode
!=
proto
.
ClusterRunning
{
continue
continue
}
}
msg
=
&
proto
.
NotifyPartitionChanges
{
msg
=
&
proto
.
NotifyPartitionChanges
{
...
@@ -1275,7 +1281,7 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
...
@@ -1275,7 +1281,7 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
case
*
_ΔStateCode
:
case
*
_ΔStateCode
:
stateCode
=
δstate
.
ClusterState
stateCode
=
δstate
.
ClusterState
msg
=
&
proto
.
NotifyClusterState
{
msg
=
&
proto
.
NotifyClusterState
{
State
:
stateCode
State
:
stateCode
,
}
}
default
:
default
:
...
@@ -1287,7 +1293,9 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
...
@@ -1287,7 +1293,9 @@ func (m *Master) accept(peer *xneo.PeerNode, idReq *neonet.Request, idResp proto
return
err
return
err
}
}
}
}
}()
})
return
nil
}
}
// allocNID allocates new node ID for a node of kind nodeType.
// allocNID allocates new node ID for a node of kind nodeType.
...
...
go/neo/xneo/xneo.go
View file @
01bae9f2
...
@@ -46,7 +46,7 @@ func (cs *ClusterState) IsOperational() bool {
...
@@ -46,7 +46,7 @@ func (cs *ClusterState) IsOperational() bool {
type
ClusterStateSnapshot
struct
{
type
ClusterStateSnapshot
struct
{
NodeTab
proto
.
NotifyNodeInformation
NodeTab
proto
.
NotifyNodeInformation
PartTab
proto
.
SendPartitionTable
PartTab
proto
.
SendPartitionTable
Code
proto
.
CluterState
Code
proto
.
Clu
s
terState
}
}
func
(
cs
*
ClusterState
)
Snapshot
()
*
ClusterStateSnapshot
{
func
(
cs
*
ClusterState
)
Snapshot
()
*
ClusterStateSnapshot
{
...
...
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