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
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) {
}
// 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
{
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
UUID
:
neo
.
UUID
(
typ
,
num
),
State
:
state
,
IdTime
stamp
:
idtstamp
,
Type
:
typ
,
Addr
:
xnaddr
(
laddr
),
UUID
:
neo
.
UUID
(
typ
,
num
),
State
:
state
,
IdTime
:
idtime
,
}
}
// 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
{
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) {
gwg
:=
&
xsync
.
WorkGroup
{}
// start master
Mclock
:=
&
vclock
{
100
}
Mclock
:=
&
vclock
{}
M
:=
NewMaster
(
"abc1"
,
":1"
,
Mhost
)
M
.
monotime
=
Mclock
.
monotime
Mctx
,
Mcancel
:=
context
.
WithCancel
(
bg
)
...
...
@@ -241,7 +241,7 @@ func TestMasterStorage(t *testing.T) {
// M starts listening
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
))
// TODO create C; C tries connect to master - rejected ("not yet operational")
...
...
@@ -266,10 +266,10 @@ func TestMasterStorage(t *testing.T) {
UUID
:
0
,
Address
:
xnaddr
(
"s:1"
),
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
{
NodeType
:
neo
.
MASTER
,
...
...
@@ -306,7 +306,7 @@ func TestMasterStorage(t *testing.T) {
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
)
// XXX M.partTab <- S1
...
...
@@ -364,10 +364,10 @@ func TestMasterStorage(t *testing.T) {
UUID
:
0
,
Address
:
xnaddr
(
""
),
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
{
NodeType
:
neo
.
MASTER
,
...
...
@@ -390,18 +390,18 @@ func TestMasterStorage(t *testing.T) {
// C <- M NotifyNodeInformation C1,M1,S1
// FIXME this might come in parallel with ^^^ "C asks M about PT"
tc
.
Expect
(
conntx
(
"m:3"
,
"c:1"
,
0
,
&
neo
.
NotifyNodeInformation
{
IdTime
stamp
:
0
,
// XXX ?
IdTime
:
neo
.
IdTimeNone
,
// XXX ?
NodeList
:
[]
neo
.
NodeInfo
{
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
0
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
10
0.01
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
10
0.02
),
nodei
(
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
neo
.
IdTimeNone
),
nodei
(
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
),
nodei
(
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
0.02
),
},
}))
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
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
10
0.01
))
tc
.
Expect
(
node
(
Cnode
,
""
,
neo
.
CLIENT
,
1
,
neo
.
RUNNING
,
10
0.02
))
tc
.
Expect
(
node
(
Cnode
,
"m:1"
,
neo
.
MASTER
,
1
,
neo
.
RUNNING
,
neo
.
IdTimeNone
))
tc
.
Expect
(
node
(
Cnode
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
RUNNING
,
0.01
))
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
...
...
@@ -444,7 +444,7 @@ func TestMasterStorage(t *testing.T) {
UUID
:
neo
.
UUID
(
neo
.
CLIENT
,
1
),
Address
:
xnaddr
(
""
),
ClusterName
:
"abc1"
,
IdTime
stamp
:
0
,
// XXX ?
IdTime
:
0.02
,
}))
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) {
Addr
:
naddr
,
UUID
:
m
.
allocUUID
(
neo
.
MASTER
),
State
:
neo
.
RUNNING
,
IdTime
stamp
:
0
,
// XXX ok?
IdTime
:
neo
.
IdTimeNone
,
// XXX ok?
}
// update nodeTab with self
...
...
@@ -979,8 +979,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
// XXX +ClusterState
err
=
link
.
Send1
(
&
neo
.
NotifyNodeInformation
{
IdTime
stamp
:
0
,
// XXX what here?
NodeList
:
nodeiv
,
IdTime
:
neo
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
})
if
err
!=
nil
{
return
err
...
...
@@ -998,8 +998,8 @@ func (m *Master) keepPeerUpdated(ctx context.Context, link *neo.NodeLink) (err e
case
nodeiv
=
<-
nodech
:
msg
=
&
neo
.
NotifyNodeInformation
{
IdTime
stamp
:
0
,
// XXX what here?
NodeList
:
nodeiv
,
IdTime
:
neo
.
IdTimeNone
,
// XXX what here?
NodeList
:
nodeiv
,
}
}
...
...
@@ -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
)
{
// XXX also verify ? :
// - NodeType valid
// - IdTime
stamp
?
// - IdTime ?
uuid
:=
n
.
idReq
.
UUID
nodeType
:=
n
.
idReq
.
NodeType
...
...
@@ -1098,7 +1098,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
Addr
:
n
.
idReq
.
Address
,
UUID
:
uuid
,
State
:
nodeState
,
IdTime
stamp
:
m
.
monotime
(
),
IdTime
:
neo
.
IdTime
(
m
.
monotime
()
),
}
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