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
0a7b04d6
Commit
0a7b04d6
authored
Feb 23, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d9882191
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
4 deletions
+26
-4
go/neo/client.go
go/neo/client.go
+2
-2
go/neo/mastered.go
go/neo/mastered.go
+23
-2
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+1
-0
No files found.
go/neo/client.go
View file @
0a7b04d6
...
...
@@ -262,7 +262,7 @@ func (c *Client) flushEventq0() {
// Sync implements zodb.IStorageDriver.
func
(
c
*
Client
)
Sync
(
ctx
context
.
Context
)
(
head
zodb
.
Tid
,
err
error
)
{
c
.
WithState
/*XXX Snapshot ?*/
(
func
(
s
*
xneo
.
State
)
{
c
.
node
.
WithState
(
func
(
s
*
xneo
.
Node
State
)
{
ctx
=
taskctx
.
Runningf
(
ctx
,
"%s: zsync"
,
s
.
MyNID
)
})
if
glog
.
V
(
2
)
{
...
...
@@ -291,7 +291,7 @@ func (c *Client) Sync(ctx context.Context) (head zodb.Tid, err error) {
// Load implements zodb.IStorageDriver.
func
(
c
*
Client
)
Load
(
ctx
context
.
Context
,
xid
zodb
.
Xid
)
(
buf
*
mem
.
Buf
,
serial
zodb
.
Tid
,
err
error
)
{
c
.
WithState
(
func
(
s
*
xneo
.
State
)
{
c
.
node
.
WithState
(
func
(
s
*
xneo
.
State
)
{
ctx
=
taskctx
.
Runningf
(
ctx
,
"%s: zload %s"
,
s
.
MyNID
,
xid
)
})
if
glog
.
V
(
2
)
{
...
...
go/neo/mastered.go
View file @
0a7b04d6
...
...
@@ -341,17 +341,36 @@ func (node *_MasteredNode) updateOperational(δf func()) {
}
}
/*
// WithState runs f with the guarantee that cluster state is not changed during the run.
func (node *_MasteredNode) WithState(f func(cs *xneo.ClusterState) error) {
node.opMu.RLock()
defer node.opMu.RUnlock()
return f(&node.State)
}
*/
// WithOperationalState runs f during when cluster state is/becomes operational.
// The cluster state is guaranteed not to change during f run.
func
(
node
*
_MasteredNode
)
WithOperationalState
(
ctx
context
.
Context
,
f
func
(
mlink
*
neonet
.
NodeLink
,
cs
*
xneo
.
Cluster
State
)
error
)
error
{
func
(
node
*
_MasteredNode
)
WithOperationalState
(
ctx
context
.
Context
,
f
func
(
mlink
*
neonet
.
NodeLink
,
s
*
xneo
.
State
)
error
)
error
{
for
{
done
:=
false
node
.
WithState
(
func
(
s
*
xneo
.
State
)
{
if
!
s
.
operational
{
ready
=
node
.
opReady
return
}
//fmt.Printf("withOperation -> ready\n");
done
=
true
err
=
f
(
/*XXX -> s.mlink ?*/
node
.
mlink
,
s
)
})
if
done
{
return
err
}
/*
node.opMu.RLock()
if node.operational {
//fmt.Printf("withOperation -> ready\n");
...
...
@@ -360,9 +379,9 @@ func (node *_MasteredNode) WithOperationalState(ctx context.Context, f func(mlin
ready := node.opReady
node.opMu.RUnlock()
*/
//fmt.Printf("withOperational - waiting on %v\n", ready)
select
{
case
<-
ctx
.
Done
()
:
return
fmt
.
Errorf
(
"wait operational: %w"
,
ctx
.
Err
())
...
...
@@ -372,9 +391,11 @@ func (node *_MasteredNode) WithOperationalState(ctx context.Context, f func(mlin
}
}
/*
// node.operational=y and node.opMu is rlocked
defer node.opMu.RUnlock()
return f(node.mlink, &node.State)
*/
}
...
...
go/neo/xneo/xneo.go
View file @
0a7b04d6
...
...
@@ -153,6 +153,7 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
// XXX doc, naming
// XXX WithStateHead ? WithStateSnapshot ?
func
(
node
*
Node
)
WithState
(
f
func
(
*
/*readonly*/
State
))
{
node
.
stateLogMu
.
Lock
()
s
:=
node
.
state
...
...
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