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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
250c5485
Commit
250c5485
authored
Sep 01, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b16ca531
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
28 deletions
+22
-28
go/neo/client/client.go
go/neo/client/client.go
+9
-11
go/neo/neo.go
go/neo/neo.go
+11
-12
go/neo/nodetab.go
go/neo/nodetab.go
+1
-3
go/neo/server/storage.go
go/neo/server/storage.go
+1
-2
No files found.
go/neo/client/client.go
View file @
250c5485
...
@@ -193,7 +193,7 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
...
@@ -193,7 +193,7 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
// XXX dup from Server.talkMaster1
// XXX dup from Server.talkMaster1
// XXX put logging into Dial?
// XXX put logging into Dial?
log
.
Info
(
ctx
,
"connecting ..."
)
log
.
Info
(
ctx
,
"connecting ..."
)
Mconn
,
accept
,
err
:=
c
.
node
.
Dial
(
ctx
,
neo
.
MASTER
,
c
.
node
.
MasterAddr
)
mlink
,
accept
,
err
:=
c
.
node
.
Dial
(
ctx
,
neo
.
MASTER
,
c
.
node
.
MasterAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
// FIXME it is not only identification - e.g. ECONNREFUSED
// FIXME it is not only identification - e.g. ECONNREFUSED
log
.
Info
(
ctx
,
"identification rejected"
)
// XXX ok here? (err is logged above)
log
.
Info
(
ctx
,
"identification rejected"
)
// XXX ok here? (err is logged above)
...
@@ -203,11 +203,10 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
...
@@ -203,11 +203,10 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
_
=
accept
// XXX
_
=
accept
// XXX
log
.
Info
(
ctx
,
"identification accepted"
)
log
.
Info
(
ctx
,
"identification accepted"
)
Mlink
:=
Mconn
.
Link
()
// set c.mlink and notify waiters
// set c.mlink and notify waiters
c
.
mlinkMu
.
Lock
()
c
.
mlinkMu
.
Lock
()
c
.
mlink
=
M
link
c
.
mlink
=
m
link
ready
:=
c
.
mlinkReady
ready
:=
c
.
mlinkReady
c
.
mlinkReady
=
make
(
chan
struct
{})
c
.
mlinkReady
=
make
(
chan
struct
{})
c
.
mlinkMu
.
Unlock
()
c
.
mlinkMu
.
Unlock
()
...
@@ -215,8 +214,7 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
...
@@ -215,8 +214,7 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
wg
,
ctx
:=
errgroup
.
WithContext
(
ctx
)
// XXX + close Mconn
defer
xio
.
CloseWhenDone
(
ctx
,
mlink
)()
defer
xio
.
CloseWhenDone
(
ctx
,
Mlink
)()
// when we are done - reset .mlink
// when we are done - reset .mlink
defer
func
()
{
defer
func
()
{
...
@@ -227,13 +225,13 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
...
@@ -227,13 +225,13 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
// launch master notifications receiver
// launch master notifications receiver
wg
.
Go
(
func
()
error
{
wg
.
Go
(
func
()
error
{
return
c
.
recvMaster
(
ctx
,
M
link
)
return
c
.
recvMaster
(
ctx
,
m
link
)
})
})
// init partition table from master
// init partition table from master
// XXX is this needed at all or we can expect master sending us pt via notify channel?
// XXX is this needed at all or we can expect master sending us pt via notify channel?
wg
.
Go
(
func
()
error
{
wg
.
Go
(
func
()
error
{
return
c
.
initFromMaster
(
ctx
,
M
link
)
return
c
.
initFromMaster
(
ctx
,
m
link
)
})
})
return
wg
.
Wait
()
return
wg
.
Wait
()
...
@@ -308,10 +306,10 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
...
@@ -308,10 +306,10 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
}
}
}
}
func
(
c
*
Client
)
initFromMaster
(
ctx
context
.
Context
,
M
link
*
neo
.
NodeLink
)
error
{
func
(
c
*
Client
)
initFromMaster
(
ctx
context
.
Context
,
m
link
*
neo
.
NodeLink
)
error
{
// ask M for PT
// ask M for PT
rpt
:=
neo
.
AnswerPartitionTable
{}
rpt
:=
neo
.
AnswerPartitionTable
{}
err
:=
M
link
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
err
:=
m
link
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
@@ -326,7 +324,7 @@ func (c *Client) initFromMaster(ctx context.Context, Mlink *neo.NodeLink) error
...
@@ -326,7 +324,7 @@ func (c *Client) initFromMaster(ctx context.Context, Mlink *neo.NodeLink) error
// ask M about last_tid
// ask M about last_tid
rlastTxn := neo.AnswerLastTransaction{}
rlastTxn := neo.AnswerLastTransaction{}
err =
M
link.Ask1(&neo.LastTransaction{}, &rlastTxn)
err =
m
link.Ask1(&neo.LastTransaction{}, &rlastTxn)
if err != nil {
if err != nil {
return err
return err
}
}
...
@@ -338,7 +336,7 @@ func (c *Client) initFromMaster(ctx context.Context, Mlink *neo.NodeLink) error
...
@@ -338,7 +336,7 @@ func (c *Client) initFromMaster(ctx context.Context, Mlink *neo.NodeLink) error
// XXX what next?
// XXX what next?
return
nil
return
nil
// TODO transaction control? -> better in original goroutines doing the txn (just share
M
link)
// TODO transaction control? -> better in original goroutines doing the txn (just share
m
link)
}
}
// --- user API calls ---
// --- user API calls ---
...
...
go/neo/neo.go
View file @
250c5485
...
@@ -35,6 +35,7 @@ import (
...
@@ -35,6 +35,7 @@ import (
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/neo/go/xcommon/xio"
"lab.nexedi.com/kirr/neo/go/xcommon/xnet"
"lab.nexedi.com/kirr/neo/go/xcommon/xnet"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
)
)
...
@@ -70,28 +71,23 @@ type NodeApp struct {
...
@@ -70,28 +71,23 @@ type NodeApp struct {
// Dial connects to another node in the cluster
// Dial connects to another node in the cluster
//
//
// It handshakes, requests identification and checks peer type. If successful returned are:
// It handshakes, requests identification and checks peer type. If successful returned are:
// -
primary link connection which carried identification
// -
established link
// - accept identification reply
// - accept identification reply
func
(
n
*
NodeApp
)
Dial
(
ctx
context
.
Context
,
peerType
NodeType
,
addr
string
)
(
_
*
Conn
,
_
*
AcceptIdentification
,
err
error
)
{
func
(
n
*
NodeApp
)
Dial
(
ctx
context
.
Context
,
peerType
NodeType
,
addr
string
)
(
_
*
NodeLink
,
_
*
AcceptIdentification
,
err
error
)
{
link
,
err
:=
DialLink
(
ctx
,
n
.
Net
,
addr
)
link
,
err
:=
DialLink
(
ctx
,
n
.
Net
,
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
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
or ctx cancel
// FIXME also close link on ctx cancel -> xcontext.WhenDone(
)
cleanup
:=
xio
.
CloseWhenDone
(
ctx
,
link
)
defer
func
()
{
defer
func
()
{
if
err
!=
nil
{
if
err
!=
nil
{
link
.
Close
()
cleanup
()
}
}
}()
}()
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
return
nil
,
nil
,
err
}
req
:=
&
RequestIdentification
{
req
:=
&
RequestIdentification
{
NodeType
:
n
.
MyInfo
.
Type
,
NodeType
:
n
.
MyInfo
.
Type
,
UUID
:
n
.
MyInfo
.
UUID
,
UUID
:
n
.
MyInfo
.
UUID
,
...
@@ -100,11 +96,14 @@ func (n *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_ *
...
@@ -100,11 +96,14 @@ func (n *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_ *
IdTimestamp
:
n
.
MyInfo
.
IdTimestamp
,
// XXX ok?
IdTimestamp
:
n
.
MyInfo
.
IdTimestamp
,
// XXX ok?
}
}
accept
:=
&
AcceptIdentification
{}
accept
:=
&
AcceptIdentification
{}
err
=
conn
.
Ask
(
req
,
accept
)
// FIXME error if peer sends us something with another connID
// (currently we ignore and serveRecv will deadlock)
err
=
link
.
Ask1
(
req
,
accept
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
nil
,
err
return
nil
,
nil
,
err
}
}
// XXX vvv move out of here (e.g. to DialPeer) if we are not checking everthing in full here?
if
accept
.
NodeType
!=
peerType
{
if
accept
.
NodeType
!=
peerType
{
// XXX send Error to peer?
// XXX send Error to peer?
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
)
...
@@ -114,7 +113,7 @@ func (n *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_ *
...
@@ -114,7 +113,7 @@ func (n *NodeApp) Dial(ctx context.Context, peerType NodeType, addr string) (_ *
// XXX accept.YourUUID // 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
// XXX accept.NumPartitions, ... wrt n.node.PartTab
return
conn
,
accept
,
nil
return
link
,
accept
,
nil
}
}
...
...
go/neo/nodetab.go
View file @
250c5485
...
@@ -453,13 +453,11 @@ func (p *Peer) PutConn(c *Conn) {
...
@@ -453,13 +453,11 @@ func (p *Peer) PutConn(c *Conn) {
// XXX p.* reading without lock - ok?
// XXX p.* reading without lock - ok?
func
(
p
*
Node
)
dial
(
ctx
context
.
Context
)
(
*
NodeLink
,
error
)
{
func
(
p
*
Node
)
dial
(
ctx
context
.
Context
)
(
*
NodeLink
,
error
)
{
var
me
*
NodeApp
// XXX bad -> crashes
var
me
*
NodeApp
// XXX bad -> crashes
conn0
,
accept
,
err
:=
me
.
Dial
(
ctx
,
p
.
Type
,
p
.
Addr
.
String
())
link
,
accept
,
err
:=
me
.
Dial
(
ctx
,
p
.
Type
,
p
.
Addr
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
link
:=
conn0
.
Link
()
// verify peer identifies as what we expect
// verify peer identifies as what we expect
// XXX move to Dial?
// XXX move to Dial?
switch
{
switch
{
...
...
go/neo/server/storage.go
View file @
250c5485
...
@@ -176,7 +176,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -176,7 +176,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// XXX dup in Client.talkMaster1
// XXX dup in Client.talkMaster1
// XXX put logging into Dial?
// XXX put logging into Dial?
log
.
Info
(
ctx
,
"connecting ..."
)
log
.
Info
(
ctx
,
"connecting ..."
)
Mconn
,
accept
,
err
:=
stor
.
node
.
Dial
(
ctx
,
neo
.
MASTER
,
stor
.
node
.
MasterAddr
)
mlink
,
accept
,
err
:=
stor
.
node
.
Dial
(
ctx
,
neo
.
MASTER
,
stor
.
node
.
MasterAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
// FIXME it is not only identification - e.g. ECONNREFUSED
// FIXME it is not only identification - e.g. ECONNREFUSED
log
.
Info
(
ctx
,
"identification rejected"
)
// XXX ok here? (err is logged above)
log
.
Info
(
ctx
,
"identification rejected"
)
// XXX ok here? (err is logged above)
...
@@ -184,7 +184,6 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -184,7 +184,6 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
}
}
log
.
Info
(
ctx
,
"identification accepted"
)
log
.
Info
(
ctx
,
"identification accepted"
)
mlink
:=
Mconn
.
Link
()
defer
xio
.
CloseWhenDone
(
ctx
,
mlink
)()
defer
xio
.
CloseWhenDone
(
ctx
,
mlink
)()
// XXX add master UUID -> nodeTab ? or master will notify us with it himself ?
// XXX add master UUID -> nodeTab ? or master will notify us with it himself ?
...
...
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