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
94746190
Commit
94746190
authored
Feb 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c8565988
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
go/neo/xneo/nodetab.go
go/neo/xneo/nodetab.go
+14
-3
go/neo/xneo/statelog.go
go/neo/xneo/statelog.go
+1
-0
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+14
-3
No files found.
go/neo/xneo/nodetab.go
View file @
94746190
...
...
@@ -83,7 +83,12 @@ type NodeTable struct {
type
PeerNode
struct
{
proto
.
NodeInfo
// (.type, .laddr, .nid, .state, .idtime) XXX also protect by mu?
// XXX -> *peerLink
link
*
_PeerLink
}
// _PeerLink provides PeerNode's link implementation.
// It is shared between several PeerNode clones.
type
_PeerLink
struct
{
localNode
*
Node
// link is for peer of .localNode
linkMu
sync
.
Mutex
...
...
@@ -158,6 +163,7 @@ func (nt *NodeTable) Update(nodeInfo proto.NodeInfo) *PeerNode {
node
.
NodeInfo
=
nodeInfo
// XXX close link if .state becomes DOWN ?
// XXX ----//---- if .Type or .Addr changes ?
traceNodeChanged
(
nt
,
node
)
return
node
...
...
@@ -191,7 +197,12 @@ func (nt *NodeTable) String() string {
// Clone creates new instance of NodeTable initialized with previous content.
func
(
nt
*
NodeTable
)
Clone
()
*
NodeTable
{
nt_
:=
&
NodeTable
{
localNode
:
nt
.
localNode
}
nt_
.
nodev
=
append
([]
*
PeerNode
(
nil
),
nt
.
nodev
...
)
for
_
,
node
:=
range
nt
.
nodev
{
nt_
.
nodev
=
append
(
nt_
.
nodev
,
&
PeerNode
{
NodeInfo
:
node
.
NodeInfo
,
link
:
node
.
link
,
})
}
return
nt_
}
...
...
@@ -253,7 +264,7 @@ func (p *PeerNode) ResetLink(ctx context.Context) {
// XXX p.* reading without lock - ok?
func
(
p
*
PeerNode
)
dial
(
ctx
context
.
Context
)
(
_
*
neonet
.
NodeLink
,
err
error
)
{
node
:=
p
.
localNode
var
s
*
NodeState
// XXX stub
s
:=
node
.
stateLog
.
ReadHead
()
// XXX better Dial gets the state from the caller? (as here it can be different from the context in which caller thinks it operates)
defer
task
.
Runningf
(
&
ctx
,
"dial %s"
,
p
.
NID
)(
&
err
)
reqID
:=
&
proto
.
RequestIdentification
{
...
...
go/neo/xneo/statelog.go
View file @
94746190
...
...
@@ -30,6 +30,7 @@ type State struct {
}
// StateRO provides read-only access to a State.
// XXX -> StateSnapshot ?
type
StateRO
interface
{
NodeTab
()
NodeTableRO
PartTab
()
PartitionTableRO
...
...
go/neo/xneo/xneo.go
View file @
94746190
...
...
@@ -29,6 +29,7 @@ import (
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
/*
// NodeState represent state maintained on a Node.
//
// XXX text about imaginary transactional log of state changes originated from master.
...
...
@@ -56,6 +57,7 @@ func (s *NodeState) Clone() *NodeState {
PartTab: s.PartTab.Clone(),
}
}
*/
/*
...
...
@@ -112,8 +114,7 @@ type Node struct {
Type
proto
.
NodeType
Addr
proto
.
Address
// listening address XXX -> LAddr ?
stateLogMu
sync
.
Mutex
state
*
NodeState
stateLog
StateLog
// log of [](mynid, myidtime, nodeTab, partTab, clusterState)
ClusterName
string
Net
xnet
.
Networker
// network AP we are sending/receiving on
...
...
@@ -131,6 +132,7 @@ type Node struct {
func
NewNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
Node
{
node
:=
&
Node
{
Type
:
typ
,
/*
state: &NodeState{
MyNID: proto.NID(typ, 0), // temp, e.g. S? TODO use "temp" bit in NodeID
IdTime: proto.IdTimeNone,
...
...
@@ -139,6 +141,7 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
PartTab: &PartitionTable{},
ClusterState: -1, // invalid
},
*/
ClusterName
:
clusterName
,
...
...
@@ -146,7 +149,15 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
MasterAddr
:
masterAddr
,
}
node
.
state
.
NodeTab
.
localNode
=
node
s
:=
&
State
{
NodeTab
:
&
NodeTable
{},
PartTab
:
&
PartitionTable
{},
ClusterState
:
-
1
,
// invalid
}
s
.
NodeTab
.
localNode
=
node
node
.
stateLog
.
head
=
s
return
node
}
...
...
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