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
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
48e38f91
Commit
48e38f91
authored
Aug 08, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2c0345b9
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
67 deletions
+108
-67
go/neo/connection.go
go/neo/connection.go
+1
-1
go/neo/server/master.go
go/neo/server/master.go
+94
-53
go/neo/server/storage.go
go/neo/server/storage.go
+13
-13
No files found.
go/neo/connection.go
View file @
48e38f91
...
...
@@ -949,7 +949,7 @@ func (c *Conn) Expect(msgv ...Msg) (which int, err error) {
return
-
1
,
&
ConnError
{
c
,
"recv"
,
fmt
.
Errorf
(
"unexpected message: %v"
,
msgType
)}
}
// Ask sends request and receives response
// Ask sends request and receives response
.
// It expects response to be exactly of resp type and errors otherwise
// XXX clarify error semantic (when Error is decoded)
// XXX do the same as Expect wrt respv ?
...
...
go/neo/server/master.go
View file @
48e38f91
This diff is collapsed.
Click to expand it.
go/neo/server/storage.go
View file @
48e38f91
...
...
@@ -143,9 +143,9 @@ func (stor *Storage) talkMaster(ctx context.Context) error {
// XXX errctx
for
{
fmt
.
Printf
(
"stor: master(%v): connecting
\n
"
,
stor
.
node
.
MasterAddr
)
// XXX info
stor
.
vlogf
(
"master(%v): connecting ..."
,
stor
.
node
.
MasterAddr
)
err
:=
stor
.
talkMaster1
(
ctx
)
fmt
.
Printf
(
"stor: master(%v): %v
\n
"
,
stor
.
node
.
MasterAddr
,
err
)
stor
.
logf
(
"master(%v): %v
"
,
stor
.
node
.
MasterAddr
,
err
)
// TODO if err = shutdown -> return
...
...
@@ -186,7 +186,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// XXX -> node.Dial ?
if
accept
.
YourNodeUUID
!=
stor
.
node
.
MyInfo
.
NodeUUID
{
fmt
.
Printf
(
"stor: %v: master told us to have UUID=%v
\n
"
,
Mlink
,
accept
.
YourNodeUUID
)
stor
.
logf
(
"%v: master told us to have UUID=%v
"
,
Mlink
,
accept
.
YourNodeUUID
)
stor
.
node
.
MyInfo
.
NodeUUID
=
accept
.
YourNodeUUID
}
...
...
@@ -224,13 +224,13 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
// let master initialize us. If successful this ends with StartOperation command.
err
=
stor
.
m1initialize
(
ctx
,
Mconn
)
if
err
!=
nil
{
fmt
.
Println
(
"stor: %v: master: %v"
,
err
)
stor
.
logf
(
"%v: master: %v"
,
Mconn
,
err
)
continue
// retry initializing
}
// we got StartOperation command. Let master drive us during servicing phase.
err
=
stor
.
m1serve
(
ctx
,
Mconn
)
fmt
.
Println
(
"stor: %v: master: %v"
,
err
)
stor
.
logf
(
"%v: master: %v"
,
Mconn
,
err
)
continue
// retry from initializing
}
...
...
@@ -358,7 +358,7 @@ func (stor *Storage) m1serve(ctx context.Context, Mconn *neo.Conn) (err error) {
// ServeLink serves incoming node-node link connection
// XXX +error return?
func
(
stor
*
Storage
)
ServeLink
(
ctx
context
.
Context
,
link
*
neo
.
NodeLink
)
{
fmt
.
Printf
(
"stor: %s: serving new node
\n
"
,
link
)
stor
.
logf
(
"%s: serving new node
"
,
link
)
// close link when either cancelling or returning (e.g. due to an error)
// ( when cancelling - link.Close will signal to all current IO to
...
...
@@ -373,7 +373,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
// XXX ret err = ctx.Err()
case
<-
retch
:
}
fmt
.
Printf
(
"stor: %v: closing link
\n
"
,
link
)
stor
.
logf
(
"%v: closing link
"
,
link
)
link
.
Close
()
// XXX err
}()
...
...
@@ -381,7 +381,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
// XXX only accept when operational (?)
nodeInfo
,
err
:=
IdentifyPeer
(
link
,
neo
.
STORAGE
)
if
err
!=
nil
{
fmt
.
Printf
(
"stor: %v
\n
"
,
err
)
stor
.
logf
(
"%v
"
,
err
)
return
}
...
...
@@ -392,7 +392,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
default
:
// XXX vvv should be reply to peer
fmt
.
Printf
(
"stor: %v: unexpected peer type: %v
\n
"
,
link
,
nodeInfo
.
NodeType
)
stor
.
logf
(
"%v: unexpected peer type: %v
"
,
link
,
nodeInfo
.
NodeType
)
return
}
...
...
@@ -400,7 +400,7 @@ func (stor *Storage) ServeLink(ctx context.Context, link *neo.NodeLink) {
for
{
conn
,
err
:=
link
.
Accept
()
if
err
!=
nil
{
fmt
.
Printf
(
"stor: %v
\n
"
,
err
)
// XXX err ctx
stor
.
logf
(
"%v
"
,
err
)
// XXX err ctx
break
}
...
...
@@ -426,7 +426,7 @@ func (stor *Storage) withWhileOperational(ctx context.Context) (context.Context,
// the connection is closed when serveClient returns
// XXX +error return?
func
(
stor
*
Storage
)
serveClient
(
ctx
context
.
Context
,
conn
*
neo
.
Conn
)
{
fmt
.
Printf
(
"stor: %s: serving new client conn
\
n
"
,
conn
)
stor
.
logf
(
"%s: serving new client con
n"
,
conn
)
// rederive ctx to be also cancelled if M tells us StopOperation
ctx
,
cancel
:=
stor
.
withWhileOperational
(
ctx
)
...
...
@@ -457,9 +457,9 @@ func (stor *Storage) serveClient(ctx context.Context, conn *neo.Conn) {
case
err
=
<-
done
:
}
fmt
.
Printf
(
"stor: %v: %v
\n
"
,
conn
,
err
)
stor
.
logf
(
"%v: %v
"
,
conn
,
err
)
// XXX vvv -> defer ?
fmt
.
Printf
(
"stor: %v: closing client conn
\
n
"
,
conn
)
stor
.
logf
(
"%v: closing client con
n"
,
conn
)
conn
.
Close
()
// XXX err
}
...
...
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