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
171c9f09
Commit
171c9f09
authored
Feb 03, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e699c83b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
45 deletions
+29
-45
go/neo/storage.go
go/neo/storage.go
+29
-45
No files found.
go/neo/storage.go
View file @
171c9f09
...
@@ -24,7 +24,6 @@ import (
...
@@ -24,7 +24,6 @@ import (
"context"
"context"
"fmt"
"fmt"
"sync"
"sync"
// "time"
"github.com/pkg/errors"
"github.com/pkg/errors"
...
@@ -42,6 +41,7 @@ import (
...
@@ -42,6 +41,7 @@ import (
"lab.nexedi.com/kirr/go123/xcontext"
"lab.nexedi.com/kirr/go123/xcontext"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xerr"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xnet"
"lab.nexedi.com/kirr/go123/xsync"
)
)
// Storage is NEO node that keeps data and provides read/write access to it via network.
// Storage is NEO node that keeps data and provides read/write access to it via network.
...
@@ -96,25 +96,35 @@ func (stor *Storage) Run(ctx context.Context, l xnet.Listener) (err error) {
...
@@ -96,25 +96,35 @@ func (stor *Storage) Run(ctx context.Context, l xnet.Listener) (err error) {
// wrap listener with link / identificaton hello checker
// wrap listener with link / identificaton hello checker
lli
:=
xneo
.
NewListener
(
neonet
.
NewLinkListener
(
l
))
lli
:=
xneo
.
NewListener
(
neonet
.
NewLinkListener
(
l
))
// start serving incoming connections
wg
:=
xsync
.
NewWorkGroup
(
ctx
)
wg
:=
sync
.
WaitGroup
{}
/*
// connect to master and get commands and updates from it
serveCtx, serveCancel := context.WithCancel(ctx)
wg
.
Go
(
func
(
ctx
context
.
Context
)
error
{
//stor.node.OnShutdown = serveCancel
return
stor
.
node
.
TalkMaster
(
ctx
,
func
(
ctx
context
.
Context
,
mlink
*
neonet
.
NodeLink
)
error
{
// XXX hack: until ctx cancel is not handled properly by Recv/Send
// XXX move -> SetNumReplicas handler
// XXX -> xcontext.WithCloseOnRetCancel
// // NumReplicas: neo/py meaning for n(replica) = `n(real-replica) - 1`
stor.node.OnShutdown = func() {
// if !(accept.NumPartitions == 1 && accept.NumReplicas == 0) {
serveCancel()
// return fmt.Errorf("TODO for 1-storage POC: Npt: %v Nreplica: %v", accept.NumPartitions, accept.NumReplicas)
xio.LClose(ctx, lli)
// }
}
*/
// let master initialize us. If successful this ends with StartOperation command.
reqStart
,
err
:=
stor
.
m1initialize
(
ctx
,
mlink
)
if
err
!=
nil
{
return
err
}
// we got StartOperation command. Let master drive us during service phase.
return
stor
.
m1serve
(
ctx
,
reqStart
)
})
})
wg
.
Add
(
1
)
// serve incoming connections
go
func
(
ctx
context
.
Context
)
(
err
error
)
{
wg
.
Go
(
func
(
ctx
context
.
Context
)
(
err
error
)
{
defer
wg
.
Done
()
defer
task
.
Running
(
&
ctx
,
"accept"
)(
&
err
)
defer
task
.
Running
(
&
ctx
,
"accept"
)(
&
err
)
serveWG
:=
sync
.
WaitGroup
{}
defer
serveWG
.
Wait
()
// XXX dup from master -> Node.Listen() -> Accept() ?
// XXX dup from master -> Node.Listen() -> Accept() ?
// XXX ? -> Node.Accept(lli) (it will verify IdTime against Node.nodeTab[nid])
// XXX ? -> Node.Accept(lli) (it will verify IdTime against Node.nodeTab[nid])
// XXX ? -> Node.Serve(lli -> func(idReq))
// XXX ? -> Node.Serve(lli -> func(idReq))
...
@@ -131,41 +141,15 @@ func (stor *Storage) Run(ctx context.Context, l xnet.Listener) (err error) {
...
@@ -131,41 +141,15 @@ func (stor *Storage) Run(ctx context.Context, l xnet.Listener) (err error) {
continue
continue
}
}
wg
.
Add
(
1
)
serveWG
.
Add
(
1
)
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
serveWG
.
Done
()
stor
.
serveLink
(
ctx
,
req
,
idReq
)
// XXX ignore err? -> logged
stor
.
serveLink
(
ctx
,
req
,
idReq
)
// XXX ignore err? -> logged
}()
}()
}
}
// }(serveCtx)
}(
ctx
)
// connect to master and get commands and updates from it
// err = stor.talkMaster(ctx)
// err = stor.talkMaster(serveCtx) // XXX hack for shutdown
// XXX log err?
err
=
stor
.
node
.
TalkMaster
(
ctx
,
func
(
ctx
context
.
Context
,
mlink
*
neonet
.
NodeLink
)
error
{
// XXX move -> SetNumReplicas handler
// // NumReplicas: neo/py meaning for n(replica) = `n(real-replica) - 1`
// if !(accept.NumPartitions == 1 && accept.NumReplicas == 0) {
// return fmt.Errorf("TODO for 1-storage POC: Npt: %v Nreplica: %v", accept.NumPartitions, accept.NumReplicas)
// }
// let master initialize us. If successful this ends with StartOperation command.
reqStart
,
err
:=
stor
.
m1initialize
(
ctx
,
mlink
)
if
err
!=
nil
{
return
err
}
// we got StartOperation command. Let master drive us during service phase.
return
stor
.
m1serve
(
ctx
,
reqStart
)
})
})
// we are done - shutdown
err
=
wg
.
Wait
()
// serveCancel()
wg
.
Wait
()
// XXX should Storage do it, or should it leave back non-closed?
// XXX should Storage do it, or should it leave back non-closed?
// TODO -> Storage should not close backend.
// TODO -> Storage should not close backend.
...
...
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