Commit a73a1f6b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 4b697c4b
...@@ -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 ctlStart // request to start cluster ctlStart chan chan error // request to start cluster
ctlStop chan ctlStop // request to stop cluster ctlStop chan chan 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) ech := make(chan error)
m.ctlStart <- ctlStart{ch} m.ctlStart <- ech
return <-ch return <-ech
} }
// 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) ech := make(chan error)
m.ctlStop <- ctlStop{ch} m.ctlStop <- ech
return <-ch return <-ech
} }
// 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment