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
622ee617
Commit
622ee617
authored
May 30, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
2b8c87d4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
7 deletions
+48
-7
go/neo/master.go
go/neo/master.go
+48
-7
No files found.
go/neo/master.go
View file @
622ee617
...
...
@@ -41,6 +41,10 @@ type Master struct {
partTab
PartitionTable
clusterState
ClusterState
// channels controlling main driver
ctlStart
chan
ctlStart
// request to start cluster
ctlStop
chan
ctlStop
// request to stop cluster
// channels from various workers to main driver
nodeCome
chan
nodeCome
// node connected
nodeLeave
chan
nodeLeave
// node disconnected
...
...
@@ -48,6 +52,15 @@ type Master struct {
storRecovery
chan
storRecovery
// storage node passed recovery XXX better explicitly pass to worker as arg?
}
type
ctlStart
struct
{
// XXX +ctx ?
resp
chan
error
}
type
ctlStop
struct
{
// XXX +ctx ?
resp
chan
error
}
// node connects
type
nodeCome
struct
{
...
...
@@ -72,7 +85,8 @@ type storRecovery struct {
func
NewMaster
(
clusterName
string
)
*
Master
{
m
:=
&
Master
{
clusterName
:
clusterName
}
m
.
SetClusterState
(
RECOVERING
)
// XXX no elections - we are the only master
m
.
clusterState
=
RECOVERING
// XXX no elections - we are the only master
go
m
.
run
(
context
.
TODO
())
// XXX ctx
return
m
}
...
...
@@ -80,9 +94,11 @@ func NewMaster(clusterName string) *Master {
// XXX NotifyNodeInformation to all nodes whenever nodetab changes
func
(
m
*
Master
)
SetClusterState
(
state
ClusterState
)
{
m
.
clusterState
=
state
// XXX actions ?
// XXX -> Start(), Stop()
func
(
m
*
Master
)
SetClusterState
(
state
ClusterState
)
error
{
ch
:=
make
(
chan
error
)
m
.
ctlState
<-
ctlState
{
state
,
ch
}
return
<-
ch
}
// run implements main master cluster management logic: node tracking, cluster
...
...
@@ -100,6 +116,29 @@ func (m *Master) run(ctx context.Context) {
case
<-
ctx
.
Done
()
:
panic
(
"TODO"
)
// command to start cluster
case
c
:=
<-
m
.
ctlStart
:
if
c
.
state
==
m
.
clusterState
{
// already there
m
.
resp
<-
nil
break
}
switch
c
.
state
{
case
RECOVERING
:
case
VERIFYING
:
// = RUNNING
case
CLUSTER_RUNNING
:
case
STOPPING
:
default
:
// TODO
}
// command to stop cluster
case
c
:=
<-
m
.
ctlStop
:
// TODO
// node connects & requests identification
case
n
:=
<-
m
.
nodeCome
:
nodeInfo
,
ok
:=
m
.
accept
(
n
)
...
...
@@ -334,8 +373,8 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
idResp
:=
<-
idRespCh
// if master accepted this node - don't forget to notify when it leaves
_
,
noaccept
:=
idResp
.
(
error
)
if
!
noaccept
{
_
,
rejected
:=
idResp
.
(
error
)
if
!
rejected
{
defer
func
()
{
m
.
nodeLeave
<-
nodeLeave
{
link
}
}()
...
...
@@ -348,7 +387,7 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
}
// nothing to do more here if identification was not accepted
if
noaccept
{
if
rejected
{
logf
(
"identify: %v"
,
idResp
)
return
}
...
...
@@ -358,6 +397,8 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
// ----------------------------------------
// XXX recheck vvv
// XXX temp hack
connNotify
:=
conn
// subscribe to nodeTab/partTab/clusterState and notify peer with updates
m
.
stateMu
.
Lock
()
...
...
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