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
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) {
...
@@ -126,27 +126,28 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
log
.
Info
(
ctx
,
"identification accepted"
)
log
.
Info
(
ctx
,
"identification accepted"
)
Mlink
:=
Mconn
.
Link
()
Mlink
:=
Mconn
.
Link
()
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
// XXX + close Mconn
defer
xio
.
CloseWhenDone
(
ctx
,
Mlink
)()
defer
xio
.
CloseWhenDone
(
ctx
,
Mlink
)()
// XXX .nodeTab.Reset()
// launch master notifications receiver
wg
.
Go
(
func
()
error
{
return
c
.
recvMaster
(
ctx
,
Mlink
)
})
rpt
:=
neo
.
AnswerPartitionTable
{}
// launch process that "drives" master (initiates & tx requests)
err
=
Mlink
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
wg
.
Go
(
func
()
error
{
if
err
!=
nil
{
return
c
.
ctlMaster
(
ctx
,
Mlink
)
// XXX
}()
}
pt
:=
neo
.
PartTabFromDump
(
rpt
.
PTid
,
rpt
.
RowList
)
return
wg
.
Wait
()
// XXX pt -> c.node.PartTab ?
_
=
pt
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
{
for
{
req
,
err
:=
Mlink
.
Recv1
()
req
,
err
:=
Mlink
.
Recv1
()
...
@@ -175,6 +176,35 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
...
@@ -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 ---
// --- user API calls ---
func
(
c
*
Client
)
LastTid
(
ctx
context
.
Context
)
(
zodb
.
Tid
,
error
)
{
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) (
...
@@ -74,7 +74,7 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
defer
xerr
.
Contextf
(
&
err
,
"%s: request identification"
,
link
)
defer
xerr
.
Contextf
(
&
err
,
"%s: request identification"
,
link
)
// close link on error return
// close link on error return
// FIXME also close link on ctx cancel
// FIXME also close link on ctx cancel
-> xcontext.WhenDone()
defer
func
()
{
defer
func
()
{
if
err
!=
nil
{
if
err
!=
nil
{
link
.
Close
()
link
.
Close
()
...
@@ -104,8 +104,9 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
...
@@ -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
)
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)
// XXX accept.MyUUID, 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.YourUUID // XXX M can tell us to change UUID -> take in effect
// XXX accept.NumPartitions, ... wrt n.node.PartTab
return
conn
,
accept
,
nil
return
conn
,
accept
,
nil
}
}
...
...
go/xcommon/xcontext/xcontext.go
View file @
19d95ba9
...
@@ -172,8 +172,8 @@ func Canceled(err error) bool {
...
@@ -172,8 +172,8 @@ func Canceled(err error) bool {
}
}
// WhenDone arranges f
to be called either when ctx is cancelled or surrounding
// WhenDone arranges f
or f to be called either when ctx is cancelled or
// function returns.
//
surrounding
function returns.
//
//
// To work as intended it should be called under defer like this:
// 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