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
08a54443
Commit
08a54443
authored
Jun 09, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
89309b93
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
19 deletions
+26
-19
go/neo/neotools/master.go
go/neo/neotools/master.go
+13
-8
go/neo/neotools/storage.go
go/neo/neotools/storage.go
+1
-4
go/neo/server/master.go
go/neo/server/master.go
+10
-7
go/neo/server/server.go
go/neo/server/server.go
+2
-0
No files found.
go/neo/neotools/master.go
View file @
08a54443
...
...
@@ -45,22 +45,28 @@ Run NEO master node.
}
func
masterMain
(
argv
[]
string
)
{
var
bind
string
var
cluster
string
flags
:=
flag
.
NewFlagSet
(
""
,
flag
.
ExitOnError
)
flags
.
Usage
=
func
()
{
masterUsage
(
os
.
Stderr
);
flags
.
PrintDefaults
()
}
// XXX prettify
flags
.
StringVar
(
&
bind
,
"bind"
,
bind
,
"address to serve on"
)
flags
.
StringVar
(
&
cluster
,
"cluster"
,
cluster
,
"cluster name"
)
cluster
:=
flags
.
String
(
"cluster"
,
""
,
"cluster name"
)
// XXX masters here too?
bind
:=
flags
.
String
(
"bind"
,
""
,
"address to serve on"
)
flags
.
Parse
(
argv
[
1
:
])
if
*
cluster
==
""
{
// XXX vvv -> die or log.Fatalf ?
log
.
Fatal
(
os
.
Stderr
,
"cluster name must be provided"
)
os
.
Exit
(
2
)
}
argv
=
flags
.
Args
()
if
len
(
argv
)
<
1
{
flags
.
Usage
()
os
.
Exit
(
2
)
}
masterSrv
:=
server
.
NewMaster
(
cluster
)
net
:=
neo
.
NetPlain
(
"tcp"
)
// TODO + TLS; not only "tcp" ?
masterSrv
:=
server
.
NewMaster
(
*
cluster
,
*
bind
,
net
)
ctx
:=
context
.
Background
()
/*
...
...
@@ -71,8 +77,7 @@ func masterMain(argv []string) {
}()
*/
net
:=
neo
.
NetPlain
(
"tcp"
)
// TODO + TLS; not only "tcp" ?
err
:=
server
.
ListenAndServe
(
ctx
,
net
,
bind
,
masterSrv
)
err
:=
masterSrv
.
Run
(
ctx
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
...
...
go/neo/neotools/storage.go
View file @
08a54443
...
...
@@ -34,9 +34,6 @@ import (
const
storageSummary
=
"run storage node"
// TODO options:
// cluster, masterv ...
func
storageUsage
(
w
io
.
Writer
)
{
fmt
.
Fprintf
(
w
,
`Usage: neo storage [options] zstor XXX
...
...
@@ -56,7 +53,7 @@ func storageMain(argv []string) {
if
*
cluster
==
""
{
// XXX vvv -> die or log.Fatalf ?
fmt
.
Fprintf
(
os
.
Stderr
,
"cluster name must be provided"
)
log
.
Fatal
(
os
.
Stderr
,
"cluster name must be provided"
)
os
.
Exit
(
2
)
}
...
...
go/neo/server/master.go
View file @
08a54443
...
...
@@ -73,12 +73,14 @@ type nodeLeave struct {
}
// NewMaster TODO ...
func
NewMaster
(
clusterName
string
)
*
Master
{
func
NewMaster
(
clusterName
,
serveAddr
string
,
net
neo
.
Network
)
*
Master
{
// XXX serveAddr + net
m
:=
&
Master
{
clusterName
:
clusterName
}
m
.
nodeUUID
=
m
.
allocUUID
(
neo
.
MASTER
)
// TODO update nodeTab with self
m
.
clusterState
=
neo
.
ClusterRecovering
// XXX no elections - we are the only master
go
m
.
run
(
context
.
TODO
())
// XXX ctx
//
go m.run(context.TODO()) // XXX ctx
return
m
}
...
...
@@ -122,17 +124,18 @@ func (m *Master) setClusterState(state neo.ClusterState) {
}
//
r
un is the process which implements main master cluster management logic: node tracking, cluster
//
R
un is the process which implements main master cluster management logic: node tracking, cluster
// state updates, scheduling data movement between storage nodes etc
func
(
m
*
Master
)
run
(
ctx
context
.
Context
)
{
func
(
m
*
Master
)
Run
(
ctx
context
.
Context
)
(
err
error
)
{
//defer xerr.Context(&err, "master: run")
// NOTE
r
un's goroutine is the only mutator of nodeTab, partTab and other cluster state
// NOTE
R
un's goroutine is the only mutator of nodeTab, partTab and other cluster state
for
ctx
.
Err
()
==
nil
{
err
:=
m
.
recovery
(
ctx
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
return
// recovery cancelled
return
err
// recovery cancelled
}
// successful recovery -> verify
...
...
@@ -154,7 +157,7 @@ func (m *Master) run(ctx context.Context) {
// XXX shutdown ?
}
fmt
.
Print
f
(
"master: run: %v
\n
"
,
ctx
.
Err
())
return
fmt
.
Error
f
(
"master: run: %v
\n
"
,
ctx
.
Err
())
}
...
...
go/neo/server/server.go
View file @
08a54443
...
...
@@ -78,6 +78,7 @@ func Serve(ctx context.Context, l net.Listener, srv Server) error {
}
}
/*
// ListenAndServe listens on network address and then calls Serve to handle incoming connections
// XXX unused -> goes away ?
func ListenAndServe(ctx context.Context, net neo.Network, laddr string, srv Server) error {
...
...
@@ -88,6 +89,7 @@ func ListenAndServe(ctx context.Context, net neo.Network, laddr string, srv Serv
// TODO set keepalive on l
return Serve(ctx, l, srv)
}
*/
// ----------------------------------------
...
...
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