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
a73a1f6b
Commit
a73a1f6b
authored
May 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
4b697c4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
33 deletions
+22
-33
go/neo/master.go
go/neo/master.go
+22
-33
No files found.
go/neo/master.go
View file @
a73a1f6b
...
@@ -49,9 +49,9 @@ type Master struct {
...
@@ -49,9 +49,9 @@ type Master struct {
clusterState
ClusterState
clusterState
ClusterState
// channels controlling main driver
// channels controlling main driver
ctlStart
chan
c
tlStart
// request to start cluster
ctlStart
chan
c
han
error
// request to start cluster
ctlStop
chan
c
tlStop
// request to stop cluster
ctlStop
chan
c
han
error
// request to stop cluster
ctlShutdown
chan
chan
error
// request to shutdown cluster XXX with ctx
too
?
ctlShutdown
chan
chan
error
// request to shutdown cluster XXX with ctx ?
wantToStart
chan
chan
error
// main -> recovery
wantToStart
chan
chan
error
// main -> recovery
...
@@ -60,15 +60,6 @@ type Master struct {
...
@@ -60,15 +60,6 @@ type Master struct {
nodeLeave
chan
nodeLeave
// node disconnected
nodeLeave
chan
nodeLeave
// node disconnected
}
}
type
ctlStart
struct
{
// XXX +ctx ?
resp
chan
error
}
type
ctlStop
struct
{
// XXX +ctx ?
resp
chan
error
}
// node connects
// node connects
type
nodeCome
struct
{
type
nodeCome
struct
{
...
@@ -96,8 +87,6 @@ func NewMaster(clusterName string) *Master {
...
@@ -96,8 +87,6 @@ func NewMaster(clusterName string) *Master {
// XXX NotifyNodeInformation to all nodes whenever nodetab changes
// XXX NotifyNodeInformation to all nodes whenever nodetab changes
// XXX -> Start(), Stop()
// Start requests cluster to eventually transition into running state
// Start requests cluster to eventually transition into running state
// it returns an error if such transition is not currently possible (e.g. partition table is not operational)
// it returns an error if such transition is not currently possible (e.g. partition table is not operational)
// it returns nil if the transition began.
// it returns nil if the transition began.
...
@@ -105,17 +94,17 @@ func NewMaster(clusterName string) *Master {
...
@@ -105,17 +94,17 @@ func NewMaster(clusterName string) *Master {
// take time and could be also automatically aborted due to cluster environment change (e.g.
// take time and could be also automatically aborted due to cluster environment change (e.g.
// a storage node goes down)
// a storage node goes down)
func
(
m
*
Master
)
Start
()
error
{
func
(
m
*
Master
)
Start
()
error
{
ch
:=
make
(
chan
error
)
e
ch
:=
make
(
chan
error
)
m
.
ctlStart
<-
ctlStart
{
ch
}
m
.
ctlStart
<-
ech
return
<-
ch
return
<-
e
ch
}
}
// Stop requests cluster to eventually transition into recovery state
// Stop requests cluster to eventually transition into recovery state
// XXX should be always possible ?
// XXX should be always possible ?
func
(
m
*
Master
)
Stop
()
error
{
func
(
m
*
Master
)
Stop
()
error
{
ch
:=
make
(
chan
error
)
e
ch
:=
make
(
chan
error
)
m
.
ctlStop
<-
ctlStop
{
ch
}
m
.
ctlStop
<-
ech
return
<-
ch
return
<-
e
ch
}
}
// Shutdown requests all known nodes in the cluster to stop
// Shutdown requests all known nodes in the cluster to stop
...
@@ -281,7 +270,7 @@ loop:
...
@@ -281,7 +270,7 @@ loop:
// request to start the cluster - if ok we exit replying ok
// request to start the cluster - if ok we exit replying ok
// if not ok - we just reply not ok
// if not ok - we just reply not ok
case
c
:=
<-
m
.
ctlStart
:
case
ech
:=
<-
m
.
ctlStart
:
if
m
.
partTab
.
OperationalWith
(
&
m
.
nodeTab
)
{
if
m
.
partTab
.
OperationalWith
(
&
m
.
nodeTab
)
{
// reply "ok to start" after whole recovery finishes
// reply "ok to start" after whole recovery finishes
...
@@ -292,15 +281,15 @@ loop:
...
@@ -292,15 +281,15 @@ loop:
rcancel
()
rcancel
()
defer
func
()
{
defer
func
()
{
c
.
resp
<-
nil
ech
<-
nil
}()
}()
break
loop
break
loop
}
}
c
.
resp
<-
fmt
.
Errorf
(
"start: cluster is non-operational"
)
ech
<-
fmt
.
Errorf
(
"start: cluster is non-operational"
)
case
c
:=
<-
m
.
ctlStop
:
case
ech
:=
<-
m
.
ctlStop
:
c
.
resp
<-
nil
// we are already recovering
ech
<-
nil
// we are already recovering
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
err
=
ctx
.
Err
()
err
=
ctx
.
Err
()
...
@@ -450,11 +439,11 @@ loop:
...
@@ -450,11 +439,11 @@ loop:
}
}
case
c
:=
<-
m
.
ctlStart
:
case
ech
:=
<-
m
.
ctlStart
:
c
.
resp
<-
nil
// we are already starting
ech
<-
nil
// we are already starting
case
c
:=
<-
m
.
ctlStop
:
case
ech
:=
<-
m
.
ctlStop
:
c
.
resp
<-
nil
// ok
ech
<-
nil
// ok
err
=
fmt
.
Errorf
(
"stop requested"
)
err
=
fmt
.
Errorf
(
"stop requested"
)
break
loop
break
loop
...
@@ -552,11 +541,11 @@ loop:
...
@@ -552,11 +541,11 @@ loop:
// XXX what else ? (-> txn control at least)
// XXX what else ? (-> txn control at least)
case
c
:=
<-
m
.
ctlStart
:
case
ech
:=
<-
m
.
ctlStart
:
c
.
resp
<-
nil
// we are already started
ech
<-
nil
// we are already started
case
c
:=
<-
m
.
ctlStop
:
case
ech
:=
<-
m
.
ctlStop
:
c
.
resp
<-
nil
// ok
ech
<-
nil
// ok
err
=
fmt
.
Errorf
(
"stop requested"
)
err
=
fmt
.
Errorf
(
"stop requested"
)
break
loop
break
loop
...
...
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