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
19d95ba9
Commit
19d95ba9
authored
Aug 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
48c864b0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
20 deletions
+51
-20
go/neo/client/client.go
go/neo/client/client.go
+45
-15
go/neo/neo.go
go/neo/neo.go
+4
-3
go/xcommon/xcontext/xcontext.go
go/xcommon/xcontext/xcontext.go
+2
-2
No files found.
go/neo/client/client.go
View file @
19d95ba9
...
...
@@ -126,27 +126,28 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
log
.
Info
(
ctx
,
"identification accepted"
)
Mlink
:=
Mconn
.
Link
()
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
// XXX + close Mconn
defer
xio
.
CloseWhenDone
(
ctx
,
Mlink
)()
// XXX .nodeTab.Reset()
// launch master notifications receiver
wg
.
Go
(
func
()
error
{
return
c
.
recvMaster
(
ctx
,
Mlink
)
})
rpt
:=
neo
.
AnswerPartitionTable
{}
err
=
Mlink
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
if
err
!=
nil
{
// XXX
}
// launch process that "drives" master (initiates & tx requests)
wg
.
Go
(
func
()
error
{
return
c
.
ctlMaster
(
ctx
,
Mlink
)
}()
pt
:=
neo
.
PartTabFromDump
(
rpt
.
PTid
,
rpt
.
RowList
)
// XXX pt -> c.node.PartTab ?
_
=
pt
return
wg
.
Wait
()
rlastTxn
:=
neo
.
AnswerLastTransaction
{}
err
=
Mlink
.
Ask1
(
&
neo
.
LastTransaction
{},
&
rlastTxn
)
if
err
!=
nil
{
// XXX
}
}
// XXX rlastTxn.Tid -> c.lastTid
// recvMaster receives and handles notifications from master
func
(
c
*
Client
)
recvMaster
(
ctx
context
.
Context
,
Mlink
*
neo
.
NodeLink
)
error
{
// XXX .nodeTab.Reset()
for
{
req
,
err
:=
Mlink
.
Recv1
()
...
...
@@ -175,6 +176,35 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
}
}
func
(
c
*
Client
)
ctlMaster
(
ctx
context
.
Context
,
Mlink
*
neo
.
NodeLink
)
error
{
// ask M for PT
rpt
:=
neo
.
AnswerPartitionTable
{}
err
=
Mlink
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
if
err
!=
nil
{
return
err
}
// XXX lock
pt
:=
neo
.
PartTabFromDump
(
rpt
.
PTid
,
rpt
.
RowList
)
// XXX pt -> c.node.PartTab ?
_
=
pt
// ask M about last_tid
rlastTxn
:=
neo
.
AnswerLastTransaction
{}
err
=
Mlink
.
Ask1
(
&
neo
.
LastTransaction
{},
&
rlastTxn
)
if
err
!=
nil
{
return
err
}
// XXX lock
// XXX rlastTxn.Tid -> c.lastTid
// XXX what next?
return
nil
// TODO transaction control? -> better in original goroutines doing the txn (just share Mlink)
}
// --- user API calls ---
func
(
c
*
Client
)
LastTid
(
ctx
context
.
Context
)
(
zodb
.
Tid
,
error
)
{
...
...
go/neo/neo.go
View file @
19d95ba9
...
...
@@ -74,7 +74,7 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
defer
xerr
.
Contextf
(
&
err
,
"%s: request identification"
,
link
)
// close link on error return
// FIXME also close link on ctx cancel
// FIXME also close link on ctx cancel
-> xcontext.WhenDone()
defer
func
()
{
if
err
!=
nil
{
link
.
Close
()
...
...
@@ -104,8 +104,9 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
return
nil
,
nil
,
fmt
.
Errorf
(
"accepted, but peer is not %v (identifies as %v)"
,
peerType
,
accept
.
NodeType
)
}
//accept.MyNodeUUID, link // XXX register .NodeTab? (or better LinkTab as NodeTab is driven by M)
//accept.YourNodeUUID // XXX M can tell us to change UUID -> take in effect
// XXX accept.MyUUID, link // XXX register .NodeTab? (or better LinkTab as NodeTab is driven by M)
// XXX accept.YourUUID // XXX M can tell us to change UUID -> take in effect
// XXX accept.NumPartitions, ... wrt n.node.PartTab
return
conn
,
accept
,
nil
}
...
...
go/xcommon/xcontext/xcontext.go
View file @
19d95ba9
...
...
@@ -172,8 +172,8 @@ func Canceled(err error) bool {
}
// WhenDone arranges f
to be called either when ctx is cancelled or surrounding
// function returns.
// WhenDone arranges f
or f to be called either when ctx is cancelled or
//
surrounding
function returns.
//
// To work as intended it should be called under defer like this:
//
...
...
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