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
221be50a
Commit
221be50a
authored
Feb 22, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a317f201
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
18 deletions
+23
-18
go/neo/mastered.go
go/neo/mastered.go
+23
-18
No files found.
go/neo/mastered.go
View file @
221be50a
...
...
@@ -70,7 +70,7 @@ type _MasteredNode struct {
operational
bool
// cache for Node.State.IsOperational()
rxmFlags
_MasteredNodeFlags
// if e.g. δPartTab messages should be delivered to mlink.Recv1
// XXX just use `.
myInfo.Node
Type == STORAGE` instead?
// XXX just use `.
node.
Type == STORAGE` instead?
}
type
_MasteredNodeFlags
int
...
...
@@ -104,13 +104,14 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker,
//
// f is called on every reconnection to master after identification and protocol prologue.
//
// TalkMaster should be the only mutator of
cluster state and .MyInfo.NID. XXX -> updateState
// TalkMaster should be the only mutator of
node state.
//
// See top-level _MasteredNode overview for details.
func
(
node
*
_MasteredNode
)
TalkMaster
(
ctx
context
.
Context
,
f
func
(
context
.
Context
,
*
_MasterLink
)
error
)
(
err
error
)
{
// start logging with initial NID (that might be temporary, and which master can tell us to change)
ctx0
:=
ctx
defer
task
.
Runningf
(
&
ctx
,
"%s: talk master(%s)"
,
node
.
MyInfo
.
NID
,
node
.
MasterAddr
)(
&
err
)
// XXX .State protect with snapshot? (but we are the only mutator - it is ok not to)
defer
task
.
Runningf
(
&
ctx
,
"%s: talk master(%s)"
,
node
.
State
.
MyNID
,
node
.
MasterAddr
)(
&
err
)
for
{
node
.
updateOperational
(
func
()
{
...
...
@@ -137,12 +138,13 @@ func (node *_MasteredNode) TalkMaster(ctx context.Context, f func(context.Contex
}
func
(
node
*
_MasteredNode
)
talkMaster1
(
ctx
,
ctxPreTalkM
context
.
Context
,
f
func
(
context
.
Context
,
*
_MasterLink
)
error
)
error
{
s
:=
node
.
StateHead
()
reqID
:=
&
proto
.
RequestIdentification
{
NodeType
:
node
.
MyInfo
.
Type
,
NID
:
node
.
MyInfo
.
NID
,
Address
:
node
.
MyInfo
.
Addr
,
NodeType
:
node
.
Type
,
NID
:
s
.
My
NID
,
Address
:
node
.
Addr
,
ClusterName
:
node
.
ClusterName
,
IdTime
:
node
.
MyInfo
.
IdTime
,
IdTime
:
s
.
IdTime
,
DevPath
:
nil
,
// XXX stub
NewNID
:
nil
,
// XXX stub
}
...
...
@@ -152,9 +154,11 @@ func (node *_MasteredNode) talkMaster1(ctx, ctxPreTalkM context.Context, f func(
}
return
xio
.
WithCloseOnRetCancel
(
ctx
,
mlink
,
func
()
(
err
error
)
{
if
accept
.
YourNID
!=
node
.
MyInfo
.
NID
{
if
accept
.
YourNID
!=
s
.
My
NID
{
log
.
Infof
(
ctx
,
"master %s told us to be %s"
,
accept
.
MyNID
,
accept
.
YourNID
)
node
.
MyInfo
.
NID
=
accept
.
YourNID
// XXX .updateState
node
.
UpdateState
(
func
(
s
*
xneo
.
State
)
{
s
.
MyNID
=
accept
.
YourNID
})
}
// TODO verify Mnid = M*; our nid corresponds to our type
...
...
@@ -176,7 +180,7 @@ func (node *_MasteredNode) talkMaster1(ctx, ctxPreTalkM context.Context, f func(
// partTab (not to S and secondary M(?))
// https://lab.nexedi.com/nexedi/neoppod/blob/v1.12-69-gd98205d0/neo/master/handlers/__init__.py#L60-67
pt
:=
node
.
State
.
PartTab
if
!
(
node
.
MyInfo
.
Type
==
proto
.
STORAGE
)
{
if
!
(
node
.
Type
==
proto
.
STORAGE
)
{
mpt
:=
proto
.
SendPartitionTable
{}
_
,
err
=
mlink
.
Expect1
(
&
mpt
)
if
err
!=
nil
{
...
...
@@ -187,8 +191,8 @@ func (node *_MasteredNode) talkMaster1(ctx, ctxPreTalkM context.Context, f func(
}
// update cluster state
node
.
update
Operational
(
func
()
{
// XXX -> updateState
err
=
node
.
updateNodeTab
(
ctx
,
&
mnt
)
// the only err is cmdShutdown
node
.
update
State
(
func
(
s
*
xneo
.
State
)
{
err
=
s
.
updateNodeTab
(
ctx
,
&
mnt
)
// the only err is cmdShutdown
node
.
State
.
PartTab
=
pt
if
err
==
nil
{
// keep mlink=nil on shutdown so that
...
...
@@ -379,20 +383,21 @@ var cmdShutdown = errors.New("master told us to shutdown")
// updateNodeTab applies updates to .nodeTab from message and logs changes appropriately.
// the only possible error is cmdShutdown.
// must be called under .opMu.
func
(
node
*
_MasteredNod
e
)
updateNodeTab
(
ctx
context
.
Context
,
msg
*
proto
.
NotifyNodeInformation
)
error
{
func
(
s
*
_MasteredStat
e
)
updateNodeTab
(
ctx
context
.
Context
,
msg
*
proto
.
NotifyNodeInformation
)
error
{
// XXX msg.IdTime ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"<- node: %v"
,
nodeInfo
)
node
.
State
.
NodeTab
.
Update
(
nodeInfo
)
s
.
NodeTab
.
Update
(
nodeInfo
)
// we have to provide IdTime when requesting identification to other peers
// (e.g. Spy checks this is what master broadcast them and if not replies "unknown by master")
// TODO .State = DOWN -> ResetLink
if
nodeInfo
.
NID
==
node
.
MyInfo
.
NID
{
// XXX recheck locking -> under .updateState
node
.
MyInfo
=
nodeInfo
if
nodeInfo
.
NID
==
s
.
MyNID
{
// TODO verify .Type is ours
// TODO verify .Addr is ours
// TODO .IdTime - do something with it?
// NEO/py currently employs this hack
// FIXME -> better it be separate command and handled cleanly
...
...
@@ -404,6 +409,6 @@ func (node *_MasteredNode) updateNodeTab(ctx context.Context, msg *proto.NotifyN
}
}
log
.
Infof
(
ctx
,
"full nodetab:
\n
%s"
,
node
.
State
.
NodeTab
)
log
.
Infof
(
ctx
,
"full nodetab:
\n
%s"
,
s
.
NodeTab
)
return
nil
}
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