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
8700e53e
Commit
8700e53e
authored
Feb 13, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b55e94bf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
13 deletions
+27
-13
go/neo/client.go
go/neo/client.go
+13
-7
go/neo/cluster_test.go
go/neo/cluster_test.go
+13
-5
go/neo/neo.go
go/neo/neo.go
+1
-1
No files found.
go/neo/client.go
View file @
8700e53e
...
@@ -75,23 +75,29 @@ var _ zodb.IStorageDriver = (*Client)(nil)
...
@@ -75,23 +75,29 @@ var _ zodb.IStorageDriver = (*Client)(nil)
//
//
// It will connect to master @masterAddr and identify with specified cluster name.
// It will connect to master @masterAddr and identify with specified cluster name.
func
NewClient
(
clusterName
,
masterAddr
string
,
net
xnet
.
Networker
)
*
Client
{
func
NewClient
(
clusterName
,
masterAddr
string
,
net
xnet
.
Networker
)
*
Client
{
cli
:=
&
Client
{
cli
:=
newClient
(
clusterName
,
masterAddr
,
net
)
go
cli
.
run
(
context
.
Background
())
// XXX bg hardcoded
return
cli
}
func
newClient
(
clusterName
,
masterAddr
string
,
net
xnet
.
Networker
)
*
Client
{
return
&
Client
{
node
:
NewNodeApp
(
net
,
proto
.
CLIENT
,
clusterName
,
masterAddr
,
""
),
node
:
NewNodeApp
(
net
,
proto
.
CLIENT
,
clusterName
,
masterAddr
,
""
),
mlinkReady
:
make
(
chan
struct
{}),
mlinkReady
:
make
(
chan
struct
{}),
operational
:
false
,
operational
:
false
,
opReady
:
make
(
chan
struct
{}),
opReady
:
make
(
chan
struct
{}),
}
}
}
// spawn background process which performs master talk
// XXX make run public?
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
// XXX bg hardcoded
func
(
cli
*
Client
)
run
(
ctx
context
.
Context
)
error
{
// run process which performs master talk
ctx
,
cancel
:=
context
.
WithCancel
(
ctx
)
cli
.
talkMasterCancel
=
cancel
cli
.
talkMasterCancel
=
cancel
cli
.
node
.
OnShutdown
=
cancel
// XXX ok?
cli
.
node
.
OnShutdown
=
cancel
// XXX ok?
go
cli
.
talkMaster
(
ctx
)
return
cli
.
talkMaster
(
ctx
)
return
cli
}
}
func
(
c
*
Client
)
Close
()
error
{
func
(
c
*
Client
)
Close
()
error
{
c
.
talkMasterCancel
()
c
.
talkMasterCancel
()
// XXX wait talkMaster finishes
// XXX wait talkMaster finishes
...
...
go/neo/cluster_test.go
View file @
8700e53e
...
@@ -468,16 +468,20 @@ func TestMasterStorage(t *testing.T) {
...
@@ -468,16 +468,20 @@ func TestMasterStorage(t *testing.T) {
rt
.
BranchNode
(
"m"
,
cM
)
rt
.
BranchNode
(
"m"
,
cM
)
rt
.
BranchNode
(
"s"
,
cS
)
rt
.
BranchNode
(
"s"
,
cS
)
//rt.BranchNode("c", cC) XXX - no
rt
.
BranchLink
(
"s-m"
,
cSM
,
cMS
)
rt
.
BranchLink
(
"s-m"
,
cSM
,
cMS
)
rt
.
BranchLink
(
"c-m"
,
cCM
,
cMC
)
// cluster nodes
// cluster nodes
M
:=
NewMaster
(
"abc1"
,
":1"
,
Mhost
)
M
:=
NewMaster
(
"abc1"
,
":1"
,
Mhost
)
zstor
:=
xfs1stor
(
"../zodb/storage/fs1/testdata/1.fs"
)
zstor
:=
xfs1stor
(
"../zodb/storage/fs1/testdata/1.fs"
)
S
:=
NewStorage
(
"abc1"
,
"m:1"
,
":1"
,
Shost
,
zstor
)
S
:=
NewStorage
(
"abc1"
,
"m:1"
,
":1"
,
Shost
,
zstor
)
C
:=
newClient
(
"abc1"
,
"m:1"
,
Chost
)
// let tracer know how to map state addresses to node names
// let tracer know how to map state addresses to node names
tracer
.
RegisterNode
(
M
.
node
,
"m"
)
// XXX better Mhost.Name() ?
tracer
.
RegisterNode
(
M
.
node
,
"m"
)
// XXX better Mhost.Name() ?
tracer
.
RegisterNode
(
S
.
node
,
"s"
)
tracer
.
RegisterNode
(
S
.
node
,
"s"
)
tracer
.
RegisterNode
(
C
.
node
,
"c"
)
...
@@ -617,12 +621,15 @@ func TestMasterStorage(t *testing.T) {
...
@@ -617,12 +621,15 @@ func TestMasterStorage(t *testing.T) {
// ----------------------------------------
// ----------------------------------------
// XXX try creating client from the beginning
// XXX try starting client from the beginning
return
// XXX temp
// create client
// start client
C
:=
NewClient
(
"abc1"
,
"m:1"
,
Chost
)
Cctx
,
Ccancel
:=
context
.
WithCancel
(
bg
)
tracer
.
RegisterNode
(
C
.
node
,
"c"
)
gox
(
gwg
,
func
()
{
err
:=
C
.
run
(
Cctx
)
fmt
.
Println
(
"C err: "
,
err
)
exc
.
Raiseif
(
err
)
})
// trace
// trace
...
@@ -692,6 +699,7 @@ func TestMasterStorage(t *testing.T) {
...
@@ -692,6 +699,7 @@ func TestMasterStorage(t *testing.T) {
_
=
Mcancel
_
=
Mcancel
_
=
Scancel
_
=
Scancel
_
=
Ccancel
return
return
}
}
...
...
go/neo/neo.go
View file @
8700e53e
// Copyright (C) 2016-201
7
Nexedi SA and Contributors.
// Copyright (C) 2016-201
8
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
// Kirill Smelkov <kirr@nexedi.com>
//
//
// This program is free software: you can Use, Study, Modify and Redistribute
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
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