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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
neo
Commits
03a6d5f4
Commit
03a6d5f4
authored
Sep 01, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fc667f6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
19 deletions
+38
-19
go/neo/client/client.go
go/neo/client/client.go
+2
-11
go/neo/neo.go
go/neo/neo.go
+22
-2
go/neo/server/storage.go
go/neo/server/storage.go
+14
-6
No files found.
go/neo/client/client.go
View file @
03a6d5f4
...
...
@@ -258,19 +258,10 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
// TODO
case
*
neo
.
NotifyNodeInformation
:
// XXX msg.IdTimestamp ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"rx node update: %v"
,
nodeInfo
)
c
.
node
.
NodeTab
.
Update
(
nodeInfo
)
}
// FIXME logging under lock
log
.
Infof
(
ctx
,
"full nodetab:
\n
%s"
,
c
.
node
.
NodeTab
)
c
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
case
*
neo
.
NotifyClusterState
:
// XXX loging under lock
log
.
Infof
(
ctx
,
"rx state update: %v"
,
msg
.
State
)
c
.
node
.
ClusterState
.
Set
(
msg
.
State
)
c
.
node
.
UpdateClusterState
(
ctx
,
msg
)
}
// update .operational + notify those who was waiting for it
...
...
go/neo/neo.go
View file @
03a6d5f4
...
...
@@ -322,7 +322,27 @@ func (l *listener) Addr() net.Addr {
return
l
.
l
.
Addr
()
}
// ----------------------------------------
// TODO functions to update:
// .PartTab from NotifyPartitionTable msg
// .NodeTab from NotifyNodeInformation msg
// .ClusterState from NotifyClusterState msg
// UpdateNodeTab applies updates to .NodeTab from message and logs changes appropriately.
func
(
app
*
NodeApp
)
UpdateNodeTab
(
ctx
context
.
Context
,
msg
*
NotifyNodeInformation
)
{
// XXX msg.IdTimestamp ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"rx node update: %v"
,
nodeInfo
)
app
.
NodeTab
.
Update
(
nodeInfo
)
}
// FIXME logging under lock (if caller took e.g. .StateMu before applying updates)
log
.
Infof
(
ctx
,
"full nodetab:
\n
%s"
,
app
.
NodeTab
)
}
// UpdateClusterState applies update to .ClusterState from message and logs change appropriately.
func
(
app
*
NodeApp
)
UpdateClusterState
(
ctx
context
.
Context
,
msg
*
NotifyClusterState
)
{
// XXX loging under lock
log
.
Infof
(
ctx
,
"rx state update: %v"
,
msg
.
State
)
app
.
ClusterState
.
Set
(
msg
.
State
)
}
go/neo/server/storage.go
View file @
03a6d5f4
...
...
@@ -143,12 +143,12 @@ func (stor *Storage) Run(ctx context.Context) error {
return
err
// XXX err ctx
}
// --- connect to master and let it d
irect
us ---
// --- connect to master and let it d
rive
us ---
// talkMaster connects to master, announces self and receives commands and notifications.
// it tries to persist master link reconnecting as needed.
//
// it always returns an error - either due to cancel or command from master to shutdown
// it always returns an error - either due to cancel or command from master to shutdown
.
func
(
stor
*
Storage
)
talkMaster
(
ctx
context
.
Context
)
(
err
error
)
{
defer
task
.
Runningf
(
&
ctx
,
"talk master(%v)"
,
stor
.
node
.
MasterAddr
)(
&
err
)
...
...
@@ -173,7 +173,7 @@ func (stor *Storage) talkMaster(ctx context.Context) (err error) {
// talkMaster1 does 1 cycle of connect/talk/disconnect to master.
//
// it returns error describing why such cycle had to finish
// it returns error describing why such cycle had to finish
.
// XXX distinguish between temporary problems and non-temporary ones?
func
(
stor
*
Storage
)
talkMaster1
(
ctx
context
.
Context
)
(
err
error
)
{
// XXX dup in Client.talkMaster1 ?
...
...
@@ -276,11 +276,10 @@ func (stor *Storage) m1initialize(ctx context.Context, mlink *neo.NodeLink) (req
case
*
neo
.
NotifyNodeInformation
:
// XXX check for myUUID and consider it a command (like neo/py) does?
// TODO update .nodeTab
stor
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
// XXX lock?
case
*
neo
.
NotifyClusterState
:
// TODO .clusterState = ... XXX what to do with it?
stor
.
node
.
UpdateClusterState
(
ctx
,
msg
)
// XXX lock? what to do with it?
}
// XXX move req.Reply here and ^^^ only prepare reply
...
...
@@ -336,6 +335,15 @@ func (stor *Storage) m1serve(ctx context.Context, reqStart *neo.Request) (err er
case
*
neo
.
StopOperation
:
return
fmt
.
Errorf
(
"stop requested"
)
// XXX NotifyPartitionTable?
// XXX NotifyPartitionChanges?
case
*
neo
.
NotifyNodeInformation
:
stor
.
node
.
UpdateNodeTab
(
ctx
,
msg
)
// XXX lock?
case
*
neo
.
NotifyClusterState
:
stor
.
node
.
UpdateClusterState
(
ctx
,
msg
)
// XXX lock? what to do with it?
// TODO commit related messages
}
}
...
...
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