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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
9f2bb7b3
Commit
9f2bb7b3
authored
Sep 05, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
12a2af21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
30 deletions
+30
-30
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+23
-23
go/neo/server/master.go
go/neo/server/master.go
+7
-7
No files found.
go/neo/server/cluster_test.go
View file @
9f2bb7b3
...
@@ -203,21 +203,21 @@ func TestMasterStorage(t *testing.T) {
...
@@ -203,21 +203,21 @@ func TestMasterStorage(t *testing.T) {
}
}
// shortcut for NodeInfo
// shortcut for NodeInfo
nodei
:=
func
(
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idt
stamp
float64
)
neo
.
NodeInfo
{
nodei
:=
func
(
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idt
ime
neo
.
IdTime
)
neo
.
NodeInfo
{
return
neo
.
NodeInfo
{
return
neo
.
NodeInfo
{
Type
:
typ
,
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
Addr
:
xnaddr
(
laddr
),
UUID
:
neo
.
UUID
(
typ
,
num
),
UUID
:
neo
.
UUID
(
typ
,
num
),
State
:
state
,
State
:
state
,
IdTime
stamp
:
idtstamp
,
IdTime
:
idtime
,
}
}
}
}
// shortcut for nodetab change
// shortcut for nodetab change
node
:=
func
(
x
*
neo
.
NodeApp
,
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idt
stamp
float64
)
*
traceNode
{
node
:=
func
(
x
*
neo
.
NodeApp
,
laddr
string
,
typ
neo
.
NodeType
,
num
int32
,
state
neo
.
NodeState
,
idt
ime
neo
.
IdTime
)
*
traceNode
{
return
&
traceNode
{
return
&
traceNode
{
NodeTab
:
unsafe
.
Pointer
(
x
.
NodeTab
),
NodeTab
:
unsafe
.
Pointer
(
x
.
NodeTab
),
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idt
stamp
),
NodeInfo
:
nodei
(
laddr
,
typ
,
num
,
state
,
idt
ime
),
}
}
}
}
...
@@ -229,7 +229,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -229,7 +229,7 @@ func TestMasterStorage(t *testing.T) {
gwg
:=
&
xsync
.
WorkGroup
{}
gwg
:=
&
xsync
.
WorkGroup
{}
// start master
// start master
Mclock
:=
&
vclock
{
100
}
Mclock
:=
&
vclock
{}
M
:=
NewMaster
(
"abc1"
,
":1"
,
Mhost
)
M
:=
NewMaster
(
"abc1"
,
":1"
,
Mhost
)
M
.
monotime
=
Mclock
.
monotime
M
.
monotime
=
Mclock
.
monotime
Mctx
,
Mcancel
:=
context
.
WithCancel
(
bg
)
Mctx
,
Mcancel
:=
context
.
WithCancel
(
bg
)
...
@@ -241,7 +241,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -241,7 +241,7 @@ func TestMasterStorage(t *testing.T) {
// M starts listening
// M starts listening
tc
.
Expect
(
netlisten
(
"m:1"
))
tc
.
Expect
(
netlisten
(
"m:1"
))
tc
.
Expect
(
node
(
M
.
node
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
0
))
tc
.
Expect
(
node
(
M
.
node
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
neo
.
IdTimeNone
))
tc
.
Expect
(
clusterState
(
&
M
.
node
.
ClusterState
,
neo
.
ClusterRecovering
))
tc
.
Expect
(
clusterState
(
&
M
.
node
.
ClusterState
,
neo
.
ClusterRecovering
))
// TODO create C; C tries connect to master - rejected ("not yet operational")
// TODO create C; C tries connect to master - rejected ("not yet operational")
...
@@ -266,10 +266,10 @@ func TestMasterStorage(t *testing.T) {
...
@@ -266,10 +266,10 @@ func TestMasterStorage(t *testing.T) {
UUID
:
0
,
UUID
:
0
,
Address
:
xnaddr
(
"s:1"
),
Address
:
xnaddr
(
"s:1"
),
ClusterName
:
"abc1"
,
ClusterName
:
"abc1"
,
IdTime
stamp
:
0
,
IdTime
:
neo
.
IdTimeNone
,
}))
}))
tc
.
Expect
(
node
(
M
.
node
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
PENDING
,
10
0.01
))
tc
.
Expect
(
node
(
M
.
node
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
PENDING
,
0.01
))
tc
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
neo
.
AcceptIdentification
{
tc
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
neo
.
AcceptIdentification
{
NodeType
:
neo
.
MASTER
,
NodeType
:
neo
.
MASTER
,
...
@@ -306,7 +306,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -306,7 +306,7 @@ func TestMasterStorage(t *testing.T) {
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
})
})
tc
.
Expect
(
node
(
M
.
node
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
10
0.01
))
tc
.
Expect
(
node
(
M
.
node
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
))
xwait
(
wg
)
xwait
(
wg
)
// XXX M.partTab <- S1
// XXX M.partTab <- S1
...
@@ -364,10 +364,10 @@ func TestMasterStorage(t *testing.T) {
...
@@ -364,10 +364,10 @@ func TestMasterStorage(t *testing.T) {
UUID
:
0
,
UUID
:
0
,
Address
:
xnaddr
(
""
),
Address
:
xnaddr
(
""
),
ClusterName
:
"abc1"
,
ClusterName
:
"abc1"
,
IdTime
stamp
:
0
,
IdTime
:
neo
.
IdTimeNone
,
}))
}))
tc
.
Expect
(
node
(
M
.
node
,
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
10
0.02
))
tc
.
Expect
(
node
(
M
.
node
,
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
0.02
))
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
neo
.
AcceptIdentification
{
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
1
,
&
neo
.
AcceptIdentification
{
NodeType
:
neo
.
MASTER
,
NodeType
:
neo
.
MASTER
,
...
@@ -390,18 +390,18 @@ func TestMasterStorage(t *testing.T) {
...
@@ -390,18 +390,18 @@ func TestMasterStorage(t *testing.T) {
// C <- M NotifyNodeInformation C1,M1,S1
// C <- M NotifyNodeInformation C1,M1,S1
// FIXME this might come in parallel with ^^^ "C asks M about PT"
// FIXME this might come in parallel with ^^^ "C asks M about PT"
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
neo
.
NotifyNodeInformation
{
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
neo
.
NotifyNodeInformation
{
IdTime
stamp
:
0
,
// XXX ?
IdTime
:
neo
.
IdTimeNone
,
// XXX ?
NodeList
:
[]
neo
.
NodeInfo
{
NodeList
:
[]
neo
.
NodeInfo
{
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
0
),
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
neo
.
IdTimeNone
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
10
0.01
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
10
0.02
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
0.02
),
},
},
}))
}))
Cnode
:=
*
(
**
neo
.
NodeApp
)(
unsafe
.
Pointer
(
C
))
// XXX hack, fragile
Cnode
:=
*
(
**
neo
.
NodeApp
)(
unsafe
.
Pointer
(
C
))
// XXX hack, fragile
tc
.
Expect
(
node
(
Cnode
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
0
))
tc
.
Expect
(
node
(
Cnode
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
neo
.
IdTimeNone
))
tc
.
Expect
(
node
(
Cnode
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
10
0.01
))
tc
.
Expect
(
node
(
Cnode
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
))
tc
.
Expect
(
node
(
Cnode
,
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
10
0.02
))
tc
.
Expect
(
node
(
Cnode
,
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
0.02
))
// C asks M about last tid XXX better master sends it itself on new client connected
// C asks M about last tid XXX better master sends it itself on new client connected
...
@@ -444,7 +444,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -444,7 +444,7 @@ func TestMasterStorage(t *testing.T) {
UUID
:
neo
.
UUID
(
neo
.
CLIENT
,
1
),
UUID
:
neo
.
UUID
(
neo
.
CLIENT
,
1
),
Address
:
xnaddr
(
""
),
Address
:
xnaddr
(
""
),
ClusterName
:
"abc1"
,
ClusterName
:
"abc1"
,
IdTime
stamp
:
0
,
// XXX ?
IdTime
:
0.02
,
}))
}))
tc
.
Expect
(
conntx
(
"s:3"
,
"c:2"
,
1
,
&
neo
.
AcceptIdentification
{
tc
.
Expect
(
conntx
(
"s:3"
,
"c:2"
,
1
,
&
neo
.
AcceptIdentification
{
...
...
go/neo/server/master.go
View file @
9f2bb7b3
...
@@ -147,7 +147,7 @@ func (m *Master) Run(ctx context.Context) (err error) {
...
@@ -147,7 +147,7 @@ func (m *Master) Run(ctx context.Context) (err error) {
Addr
:
naddr
,
Addr
:
naddr
,
UUID
:
m
.
allocUUID
(
neo
.
MASTER
),
UUID
:
m
.
allocUUID
(
neo
.
MASTER
),
State
:
neo
.
RUNNING
,
State
:
neo
.
RUNNING
,
IdTime
stamp
:
0
,
// XXX ok?
IdTime
:
neo
.
IdTimeNone
,
// XXX ok?
}
}
// update nodeTab with self
// update nodeTab with self
...
@@ -979,8 +979,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -979,8 +979,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// XXX +ClusterState
// XXX +ClusterState
err
=
link
.
Send1
(
&
neo
.
NotifyNodeInformation
{
err
=
link
.
Send1
(
&
neo
.
NotifyNodeInformation
{
IdTime
stamp
:
0
,
// XXX what here?
IdTime
:
neo
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
NodeList
:
nodeiv
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -998,8 +998,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -998,8 +998,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
case
nodeiv
=
<-
nodech
:
case
nodeiv
=
<-
nodech
:
msg
=
&
neo
.
NotifyNodeInformation
{
msg
=
&
neo
.
NotifyNodeInformation
{
IdTime
stamp
:
0
,
// XXX what here?
IdTime
:
neo
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
NodeList
:
nodeiv
,
}
}
}
}
...
@@ -1023,7 +1023,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
...
@@ -1023,7 +1023,7 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
func
(
m
*
Master
)
identify
(
ctx
context
.
Context
,
n
nodeCome
)
(
node
*
neo
.
Node
,
resp
neo
.
Msg
)
{
func
(
m
*
Master
)
identify
(
ctx
context
.
Context
,
n
nodeCome
)
(
node
*
neo
.
Node
,
resp
neo
.
Msg
)
{
// XXX also verify ? :
// XXX also verify ? :
// - NodeType valid
// - NodeType valid
// - IdTime
stamp
?
// - IdTime ?
uuid
:=
n
.
idReq
.
UUID
uuid
:=
n
.
idReq
.
UUID
nodeType
:=
n
.
idReq
.
NodeType
nodeType
:=
n
.
idReq
.
NodeType
...
@@ -1098,7 +1098,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -1098,7 +1098,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
Addr
:
n
.
idReq
.
Address
,
Addr
:
n
.
idReq
.
Address
,
UUID
:
uuid
,
UUID
:
uuid
,
State
:
nodeState
,
State
:
nodeState
,
IdTime
stamp
:
m
.
monotime
(
),
IdTime
:
neo
.
IdTime
(
m
.
monotime
()
),
}
}
node
=
m
.
node
.
NodeTab
.
Update
(
nodeInfo
)
// NOTE this notifies all nodeTab subscribers
node
=
m
.
node
.
NodeTab
.
Update
(
nodeInfo
)
// NOTE this notifies all nodeTab subscribers
...
...
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