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
eff3e3e4
Commit
eff3e3e4
authored
Aug 16, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3229af24
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
2 deletions
+30
-2
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+23
-1
go/neo/server/master.go
go/neo/server/master.go
+7
-1
No files found.
go/neo/server/cluster_test.go
View file @
eff3e3e4
...
...
@@ -27,6 +27,7 @@ import (
//"bytes"
"context"
//"io"
"math"
"net"
//"reflect"
"testing"
...
...
@@ -107,6 +108,25 @@ func (t *MyTracer) traceNode(nt *neo.NodeTable, n *neo.Node) {
}
// vclock is a virtual clock
// XXX place -> util?
type
vclock
struct
{
t
float64
}
func
(
c
*
vclock
)
monotime
()
float64
{
c
.
t
+=
1E-2
return
c
.
t
}
func
(
c
*
vclock
)
tick
()
{
// XXX do we need tick?
t
:=
math
.
Ceil
(
c
.
t
)
if
!
(
t
>
c
.
t
)
{
t
+=
1
}
c
.
t
=
t
}
//trace:import "lab.nexedi.com/kirr/neo/go/neo"
// M drives cluster with 1 S through recovery -> verification -> service -> shutdown
...
...
@@ -181,7 +201,9 @@ func TestMasterStorage(t *testing.T) {
wg
:=
&
xsync
.
WorkGroup
{}
// start master
Mclock
:=
&
vclock
{}
M
:=
NewMaster
(
"abc1"
,
":1"
,
Mhost
)
M
.
monotime
=
Mclock
.
monotime
Mctx
,
Mcancel
:=
context
.
WithCancel
(
context
.
Background
())
wg
.
Gox
(
func
()
{
err
:=
M
.
Run
(
Mctx
)
...
...
@@ -224,7 +246,7 @@ func TestMasterStorage(t *testing.T) {
IdTimestamp
:
0
,
}))
tc
.
Expect
(
node
(
M
.
nodeTab
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
PENDING
,
0.0
))
// XXX t
tc
.
Expect
(
node
(
M
.
nodeTab
,
"s:1"
,
neo
.
STORAGE
,
1
,
neo
.
PENDING
,
0.0
1
))
tc
.
Expect
(
conntx
(
"m:2"
,
"s:2"
,
1
,
&
neo
.
AcceptIdentification
{
NodeType
:
neo
.
MASTER
,
...
...
go/neo/server/master.go
View file @
eff3e3e4
...
...
@@ -65,6 +65,10 @@ type Master struct {
// channels from workers directly serving peers to main driver
nodeCome
chan
nodeCome
// node connected XXX -> acceptq?
nodeLeave
chan
nodeLeave
// node disconnected XXX -> don't need
// so tests could override
monotime
func
()
float64
}
...
...
@@ -105,6 +109,8 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
nodeCome
:
make
(
chan
nodeCome
),
nodeLeave
:
make
(
chan
nodeLeave
),
monotime
:
monotime
,
}
m
.
clusterState
=
-
1
// invalid
...
...
@@ -905,7 +911,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
Address
:
n
.
idReq
.
Address
,
NodeUUID
:
uuid
,
NodeState
:
nodeState
,
IdTimestamp
:
monotime
(),
IdTimestamp
:
m
.
m
onotime
(),
}
node
=
m
.
nodeTab
.
Update
(
nodeInfo
,
n
.
conn
)
// 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