Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Levin Zimmermann
neoppod
Commits
e6fbafe8
Commit
e6fbafe8
authored
Aug 31, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
620df4c7
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
283 additions
and
307 deletions
+283
-307
go/neo/client/client.go
go/neo/client/client.go
+2
-2
go/neo/nodetab.go
go/neo/nodetab.go
+252
-249
go/neo/server/master.go
go/neo/server/master.go
+29
-56
No files found.
go/neo/client/client.go
View file @
e6fbafe8
...
...
@@ -272,7 +272,7 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
// XXX msg.IdTimestamp ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"rx node update: %v"
,
nodeInfo
)
c
.
node
.
NodeTab
.
Update
(
nodeInfo
,
/*XXX conn should not be here*/
nil
)
c
.
node
.
NodeTab
.
Update
(
nodeInfo
)
}
// FIXME logging under lock
...
...
@@ -399,7 +399,7 @@ func (c *Client) Load(ctx context.Context, xid zodb.Xid) (data []byte, serial zo
// retry from the beginning if all are found to fail?
stor
:=
storv
[
rand
.
Intn
(
len
(
storv
))]
slink
,
err
:=
stor
.
Link
(
)
slink
,
err
:=
stor
.
Dial
(
ctx
)
if
err
!=
nil
{
return
nil
,
0
,
err
// XXX err ctx
}
...
...
go/neo/nodetab.go
View file @
e6fbafe8
This diff is collapsed.
Click to expand it.
go/neo/server/master.go
View file @
e6fbafe8
...
...
@@ -176,7 +176,7 @@ func (m *Master) Run(ctx context.Context) (err error) {
}
// update nodeTab with self
m
.
node
.
NodeTab
.
Update
(
m
.
node
.
MyInfo
,
nil
/*XXX ok? we are not connecting to self*/
)
m
.
node
.
NodeTab
.
Update
(
m
.
node
.
MyInfo
)
// accept incoming connections and pass them to main driver
...
...
@@ -368,13 +368,8 @@ loop:
log
.
Error
(
ctx
,
r
.
err
)
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
// XXX dup wrt vvv (loop2)
log
.
Infof
(
ctx
,
"%v: closing link"
,
r
.
stor
.
Link
)
// close stor link / update .nodeTab
lclose
(
ctx
,
r
.
stor
.
Link
)
// r.stor.SetState(neo.DOWN)
m
.
node
.
NodeTab
.
SetNodeState
(
r
.
stor
,
neo
.
DOWN
)
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
SetState
(
neo
.
DOWN
)
}
}
else
{
...
...
@@ -457,12 +452,8 @@ loop2:
log
.
Error
(
ctx
,
r
.
err
)
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
// XXX -> r.stor.CloseLink(ctx) ?
log
.
Infof
(
ctx
,
"%v: closing link"
,
r
.
stor
.
Link
)
// close stor link / update .nodeTab
lclose
(
ctx
,
r
.
stor
.
Link
)
m
.
node
.
NodeTab
.
SetNodeState
(
r
.
stor
,
neo
.
DOWN
)
r
.
stor
.
CloseLink
(
ctx
)
r
.
stor
.
SetState
(
neo
.
DOWN
)
}
case
<-
done
:
...
...
@@ -480,7 +471,7 @@ loop2:
// XXX recheck logic is ok for when starting existing cluster
for
_
,
stor
:=
range
m
.
node
.
NodeTab
.
StorageList
()
{
if
stor
.
State
==
neo
.
PENDING
{
m
.
node
.
NodeTab
.
SetNodeState
(
stor
,
neo
.
RUNNING
)
stor
.
SetState
(
neo
.
RUNNING
)
}
}
...
...
@@ -513,28 +504,19 @@ func storCtlRecovery(ctx context.Context, stor *neo.Node, res chan storRecovery)
// on error provide feedback to storRecovery chan
res
<-
storRecovery
{
stor
:
stor
,
err
:
err
}
}()
defer
task
.
Runningf
(
&
ctx
,
"%s: stor recovery"
,
stor
.
Link
.
RemoteAddr
())(
&
err
)
conn
:=
stor
.
Conn
// conn, err := stor.Link.NewConn()
// if err != nil {
// return
// }
// defer func() {
// err2 := conn.Close()
// err = xerr.First(err, err2)
// }()
slink
:=
stor
.
Link
()
defer
task
.
Runningf
(
&
ctx
,
"%s: stor recovery"
,
slink
.
RemoteAddr
())(
&
err
)
// XXX cancel on ctx
recovery
:=
neo
.
AnswerRecovery
{}
err
=
conn
.
Ask
(
&
neo
.
Recovery
{},
&
recovery
)
err
=
slink
.
Ask1
(
&
neo
.
Recovery
{},
&
recovery
)
if
err
!=
nil
{
return
}
resp
:=
neo
.
AnswerPartitionTable
{}
err
=
conn
.
Ask
(
&
neo
.
AskPartitionTable
{},
&
resp
)
err
=
slink
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
resp
)
if
err
!=
nil
{
return
}
...
...
@@ -621,7 +603,7 @@ loop:
}()
case
n
:=
<-
m
.
nodeLeave
:
m
.
node
.
NodeTab
.
SetNodeState
(
n
.
node
,
neo
.
DOWN
)
n
.
node
.
SetState
(
neo
.
DOWN
)
// if cluster became non-operational - we cancel verification
if
!
m
.
node
.
PartTab
.
OperationalWith
(
m
.
node
.
NodeTab
)
{
...
...
@@ -643,12 +625,8 @@ loop:
log
.
Error
(
ctx
,
v
.
err
)
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
// XXX dup wrt recovery ^^^
log
.
Infof
(
ctx
,
"%s: closing link"
,
v
.
stor
.
Link
)
// mark storage as non-working in nodeTab
lclose
(
ctx
,
v
.
stor
.
Link
)
m
.
node
.
NodeTab
.
SetNodeState
(
v
.
stor
,
neo
.
DOWN
)
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
SetState
(
neo
.
DOWN
)
}
// check partTab is still operational
...
...
@@ -696,11 +674,8 @@ loop2:
log
.
Error
(
ctx
,
v
.
err
)
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
v
.
err
))
{
log
.
Infof
(
ctx
,
"%v: closing link"
,
v
.
stor
.
Link
)
// close stor link / update .nodeTab
lclose
(
ctx
,
v
.
stor
.
Link
)
m
.
node
.
NodeTab
.
SetNodeState
(
v
.
stor
,
neo
.
DOWN
)
v
.
stor
.
CloseLink
(
ctx
)
v
.
stor
.
SetState
(
neo
.
DOWN
)
}
case
<-
done
:
...
...
@@ -730,12 +705,11 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
res
<-
storVerify
{
stor
:
stor
,
err
:
err
}
}
}()
defer
task
.
Runningf
(
&
ctx
,
"%s: stor verify"
,
stor
.
Link
)(
&
err
)
conn
:=
stor
.
Conn
slink
:=
stor
.
Link
()
defer
task
.
Runningf
(
&
ctx
,
"%s: stor verify"
,
slink
)(
&
err
)
// send just recovered parttab so storage saves it
err
=
conn
.
Send
(
&
neo
.
NotifyPartitionTable
{
err
=
slink
.
Send1
(
&
neo
.
NotifyPartitionTable
{
PTid
:
pt
.
PTid
,
RowList
:
pt
.
Dump
(),
})
...
...
@@ -744,7 +718,7 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
}
locked
:=
neo
.
AnswerLockedTransactions
{}
err
=
conn
.
Ask
(
&
neo
.
LockedTransactions
{},
&
locked
)
err
=
slink
.
Ask1
(
&
neo
.
LockedTransactions
{},
&
locked
)
if
err
!=
nil
{
return
}
...
...
@@ -756,7 +730,7 @@ func storCtlVerify(ctx context.Context, stor *neo.Node, pt *neo.PartitionTable,
}
last
:=
neo
.
AnswerLastIDs
{}
err
=
conn
.
Ask
(
&
neo
.
LastIDs
{},
&
last
)
err
=
slink
.
Ask1
(
&
neo
.
LastIDs
{},
&
last
)
if
err
!=
nil
{
return
}
...
...
@@ -850,7 +824,7 @@ loop:
// XXX who sends here?
case
n
:=
<-
m
.
nodeLeave
:
m
.
node
.
NodeTab
.
SetNodeState
(
n
.
node
,
neo
.
DOWN
)
n
.
node
.
SetState
(
neo
.
DOWN
)
// if cluster became non-operational - cancel service
if
!
m
.
node
.
PartTab
.
OperationalWith
(
m
.
node
.
NodeTab
)
{
...
...
@@ -884,15 +858,14 @@ loop:
// storCtlService drives a storage node during cluster service state
func
storCtlService
(
ctx
context
.
Context
,
stor
*
neo
.
Node
)
(
err
error
)
{
defer
task
.
Runningf
(
&
ctx
,
"%s: stor service"
,
stor
.
Link
.
RemoteAddr
())(
&
err
)
conn
:=
stor
.
Conn
slink
:=
stor
.
Link
()
defer
task
.
Runningf
(
&
ctx
,
"%s: stor service"
,
slink
.
RemoteAddr
())(
&
err
)
// XXX send nodeTab ?
// XXX send clusterInformation ?
ready
:=
neo
.
NotifyReady
{}
err
=
conn
.
Ask
(
&
neo
.
StartOperation
{
Backup
:
false
},
&
ready
)
err
=
slink
.
Ask1
(
&
neo
.
StartOperation
{
Backup
:
false
},
&
ready
)
if
err
!=
nil
{
return
err
}
...
...
@@ -915,12 +888,11 @@ func storCtlService(ctx context.Context, stor *neo.Node) (err error) {
// serveClient serves incoming client link
func
(
m
*
Master
)
serveClient
(
ctx
context
.
Context
,
cli
*
neo
.
Node
)
(
err
error
)
{
defer
task
.
Runningf
(
&
ctx
,
"%s: client service"
,
cli
.
Link
.
RemoteAddr
())(
&
err
)
clink
:=
cli
.
Link
()
defer
task
.
Runningf
(
&
ctx
,
"%s: client service"
,
clink
.
RemoteAddr
())(
&
err
)
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
clink
:=
cli
.
Link
defer
xio
.
CloseWhenDone
(
ctx
,
clink
)()
defer
xio
.
CloseWhenDone
(
ctx
,
clink
)()
// XXX -> cli.CloseLink?
// M -> C notifications about cluster state
wg
.
Go
(
func
()
error
{
...
...
@@ -1128,7 +1100,8 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
IdTimestamp
:
m
.
monotime
(),
}
node
=
m
.
node
.
NodeTab
.
Update
(
nodeInfo
,
n
.
conn
)
// NOTE this notifies all nodeTab subscribers
node
=
m
.
node
.
NodeTab
.
Update
(
nodeInfo
)
// NOTE this notifies all nodeTab subscribers
node
.
SetLink
(
n
.
conn
.
Link
())
return
node
,
accept
}
...
...
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