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
6b35dbe6
Commit
6b35dbe6
authored
May 29, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
affb271c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
36 deletions
+78
-36
go/neo/master.go
go/neo/master.go
+77
-35
go/neo/parttab.go
go/neo/parttab.go
+1
-1
No files found.
go/neo/master.go
View file @
6b35dbe6
...
...
@@ -42,18 +42,31 @@ type Master struct {
partTab
PartitionTable
clusterState
ClusterState
nodeCome
chan
nodeCome
// node connected
//nodeLeave chan nodeLeave // node disconnected
// channels from various workers to main driver
nodeCome
chan
nodeCome
// node connected
nodeLeave
chan
nodeLeave
// node disconnected
storRecovery
chan
storRecovery
// storage node passed recovery
}
//
a new node connect
//
node connects
type
nodeCome
struct
{
link
*
NodeLink
idReq
RequestIdentification
// we received this identification request
idResp
chan
NEOEncoder
// what we reply (AcceptIdentification | Error)
}
// node disconnects
type
nodeLeave
struct
{
// TODO
}
// storage node passed recovery phase
type
storRecovery
struct
{
parttab
PartitionTable
// XXX + lastOid, lastTid, backup_tid, truncate_tid ?
}
func
NewMaster
(
clusterName
string
)
*
Master
{
m
:=
&
Master
{
clusterName
:
clusterName
}
m
.
SetClusterState
(
RECOVERING
)
// XXX no elections - we are the only master
...
...
@@ -85,7 +98,7 @@ func (m *Master) run(ctx context.Context) {
// current function to ask/control a storage depending on current cluster state and master idea
// + associated context covering all storage nodes
storCtl
:=
m
.
storRecovery
storCtl
:=
m
.
stor
Ctl
Recovery
storCtlCtx
,
storCtlCancel
:=
context
.
WithCancel
(
ctx
)
for
{
...
...
@@ -115,42 +128,16 @@ func (m *Master) run(ctx context.Context) {
// node disconnects
//case link := <-m.nodeLeave:
}
}
_
=
storCtlCancel
// XXX
}
// a storage node came through recovery - let's see whether
// ptid ↑ and if so we should take partition table from there
case
r
:=
<-
m
.
storRecovery
:
_
=
r
// storRecovery drives a storage node during cluster recoving state
// TODO text
func
(
m
*
Master
)
storRecovery
(
ctx
context
.
Context
,
link
*
NodeLink
)
{
var
err
error
defer
func
()
{
if
err
==
nil
{
return
}
fmt
.
Printf
(
"master: %v"
,
err
)
// this must interrupt everything connected to stor node and
// thus eventually to result in nodeLeave event to main driver
link
.
Close
()
}()
defer
errcontextf
(
&
err
,
"%s: stor recovery"
,
link
)
conn
,
err
:=
link
.
NewConn
()
// FIXME bad
if
err
!=
nil
{
return
}
recovery
:=
AnswerRecovery
{}
err
=
Ask
(
conn
,
&
Recovery
{},
&
recovery
)
if
err
!=
nil
{
return
}
ptid
:=
recovery
.
PTid
_
=
ptid
// XXX temp
_
=
storCtlCancel
// XXX
}
// accept processes identification request of just connected node and either accepts or declines it
...
...
@@ -222,6 +209,61 @@ func (m *Master) accept(n nodeCome) (nodeInfo NodeInfo, ok bool) {
return
nodeInfo
,
true
}
// storCtlRecovery drives a storage node during cluster recoving state
// TODO text
func
(
m
*
Master
)
storCtlRecovery
(
ctx
context
.
Context
,
link
*
NodeLink
)
{
var
err
error
defer
func
()
{
if
err
==
nil
{
return
}
fmt
.
Printf
(
"master: %v"
,
err
)
// this must interrupt everything connected to stor node and
// thus eventually result in nodeLeave event to main driver
link
.
Close
()
}()
defer
errcontextf
(
&
err
,
"%s: stor recovery"
,
link
)
conn
,
err
:=
link
.
NewConn
()
// FIXME bad
if
err
!=
nil
{
return
}
recovery
:=
AnswerRecovery
{}
err
=
Ask
(
conn
,
&
Recovery
{},
&
recovery
)
if
err
!=
nil
{
return
}
resp
:=
AnswerPartitionTable
{}
err
=
Ask
(
conn
,
&
X_PartitionTable
{},
&
resp
)
if
err
!=
nil
{
return
}
// reconstruct partition table from response
pt
:=
PartitionTable
{}
pt
.
ptId
=
resp
.
PTid
for
_
,
row
:=
range
resp
.
RowList
{
i
:=
row
.
Offset
for
i
>=
uint32
(
len
(
pt
.
ptTab
))
{
pt
.
ptTab
=
append
(
pt
.
ptTab
,
[]
PartitionCell
{})
}
//pt.ptTab[i] = append(pt.ptTab[i], row.CellList...)
for
_
,
cell
:=
range
row
.
CellList
{
pt
.
ptTab
[
i
]
=
append
(
pt
.
ptTab
[
i
],
PartitionCell
{
NodeUUID
:
cell
.
NodeUUID
,
CellState
:
cell
.
CellState
,
})
}
}
m
.
storRecovery
<-
storRecovery
{
parttab
:
pt
}
}
// allocUUID allocates new node uuid for a node of kind nodeType
// XXX it is bad idea for master to assign uuid to coming node
// -> better nodes generate really uniquie UUID themselves and always show with them
...
...
go/neo/parttab.go
View file @
6b35dbe6
...
...
@@ -109,7 +109,7 @@ type PartitionTable struct {
ptTab
[][]
PartitionCell
// [#Np]
ptId
int
// ↑ for versioning XXX -> ver ?
ptId
PTid
// ↑ for versioning XXX -> ver ?
}
// PartitionCell describes one storage in a ptid entry in partition table
...
...
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