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
32928af7
Commit
32928af7
authored
Feb 23, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
221be50a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
go/neo/xneo/nodetab.go
go/neo/xneo/nodetab.go
+11
-11
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+10
-5
No files found.
go/neo/xneo/nodetab.go
View file @
32928af7
...
@@ -135,7 +135,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
...
@@ -135,7 +135,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
proto
.
NodeInfo
)
*
PeerNode
{
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
proto
.
NodeInfo
)
*
PeerNode
{
node
:=
nt
.
Get
(
nodeInfo
.
NID
)
node
:=
nt
.
Get
(
nodeInfo
.
NID
)
if
node
==
nil
{
if
node
==
nil
{
node
=
&
PeerNode
{
nodeTab
:
nt
}
node
=
&
PeerNode
{
localNode
:
nt
.
localNode
}
nt
.
nodev
=
append
(
nt
.
nodev
,
node
)
nt
.
nodev
=
append
(
nt
.
nodev
,
node
)
}
}
...
@@ -173,9 +173,9 @@ func (nt *NodeTable) String() string {
...
@@ -173,9 +173,9 @@ func (nt *NodeTable) String() string {
// Clone creates new instance of NodeTable initialized with previous content.
// Clone creates new instance of NodeTable initialized with previous content.
func
(
nt
*
NodeTable
)
Clone
()
*
NodeTab
{
func
(
nt
*
NodeTable
)
Clone
()
*
NodeTab
le
{
nt_
:=
&
NodeTable
{
localNode
:
nt
.
localNode
}
nt_
:=
&
NodeTable
{
localNode
:
nt
.
localNode
}
nt_
.
nodev
=
append
([]
*
PeerNode
(
nil
),
nt
.
nodev
)
nt_
.
nodev
=
append
([]
*
PeerNode
(
nil
),
nt
.
nodev
...
)
return
nt_
return
nt_
}
}
...
@@ -236,16 +236,16 @@ func (p *PeerNode) ResetLink(ctx context.Context) {
...
@@ -236,16 +236,16 @@ func (p *PeerNode) ResetLink(ctx context.Context) {
// dial does low-level work to dial peer
// dial does low-level work to dial peer
// XXX p.* reading without lock - ok?
// XXX p.* reading without lock - ok?
func
(
p
*
PeerNode
)
dial
(
ctx
context
.
Context
)
(
_
*
neonet
.
NodeLink
,
err
error
)
{
func
(
p
*
PeerNode
)
dial
(
ctx
context
.
Context
)
(
_
*
neonet
.
NodeLink
,
err
error
)
{
node
:=
p
.
nodeTab
.
localNode
node
:=
p
.
localNode
mynid
:=
node
.
MyInfo
.
NID
// XXX locking
var
s
*
NodeState
// XXX stub
defer
task
.
Runningf
(
&
ctx
,
"dial %s"
,
p
.
NID
)(
&
err
)
defer
task
.
Runningf
(
&
ctx
,
"dial %s"
,
p
.
NID
)(
&
err
)
reqID
:=
&
proto
.
RequestIdentification
{
reqID
:=
&
proto
.
RequestIdentification
{
NodeType
:
node
.
MyInfo
.
Type
,
NodeType
:
node
.
Type
,
NID
:
mynid
,
NID
:
s
.
MyNID
,
Address
:
node
.
MyInfo
.
Addr
,
Address
:
node
.
Addr
,
ClusterName
:
node
.
ClusterName
,
ClusterName
:
node
.
ClusterName
,
IdTime
:
node
.
MyInfo
.
IdTime
,
IdTime
:
s
.
IdTime
,
DevPath
:
nil
,
// XXX stub
DevPath
:
nil
,
// XXX stub
NewNID
:
nil
,
// XXX stub
NewNID
:
nil
,
// XXX stub
}
}
...
@@ -261,8 +261,8 @@ func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) {
...
@@ -261,8 +261,8 @@ func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) {
case
accept
.
MyNID
!=
p
.
NID
:
case
accept
.
MyNID
!=
p
.
NID
:
err
=
fmt
.
Errorf
(
"connected, but peer's nid is not %s (identifies as %s)"
,
p
.
NID
,
accept
.
MyNID
)
err
=
fmt
.
Errorf
(
"connected, but peer's nid is not %s (identifies as %s)"
,
p
.
NID
,
accept
.
MyNID
)
case
accept
.
YourNID
!=
mynid
:
case
accept
.
YourNID
!=
s
.
MyNID
:
err
=
fmt
.
Errorf
(
"connected, but peer gives us nid %s (our is %s)"
,
accept
.
YourNID
,
mynid
)
err
=
fmt
.
Errorf
(
"connected, but peer gives us nid %s (our is %s)"
,
accept
.
YourNID
,
s
.
MyNID
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
...
...
go/neo/xneo/xneo.go
View file @
32928af7
...
@@ -30,8 +30,10 @@ import (
...
@@ -30,8 +30,10 @@ import (
)
)
// NodeState represent state maintained on a Node.
// NodeState represent state maintained on a Node.
//
// XXX text about imaginary transactional log of state changes originated from master.
type
NodeState
struct
{
type
NodeState
struct
{
NID
proto
.
NodeID
// nid received by node from M XXX -> MasteredState ? (because .mlink is there ?)
My
NID
proto
.
NodeID
// nid received by node from M XXX -> MasteredState ? (because .mlink is there ?)
IdTime
proto
.
IdTime
// when this node last identified to master
IdTime
proto
.
IdTime
// when this node last identified to master
NodeTab
*
NodeTable
// nodes in the cluster
NodeTab
*
NodeTable
// nodes in the cluster
...
@@ -48,8 +50,8 @@ func (s *NodeState) Clone() *NodeState {
...
@@ -48,8 +50,8 @@ func (s *NodeState) Clone() *NodeState {
// TODO ? if cloning full nodeTab/partTab becomes slow (for large
// TODO ? if cloning full nodeTab/partTab becomes slow (for large
// tables) -> change to create COW reference.
// tables) -> change to create COW reference.
NodeTab
:
s
.
NodeTab
.
Clone
()
NodeTab
:
s
.
NodeTab
.
Clone
()
,
PaetTab
:
s
.
PartTab
.
Clone
()
PaetTab
:
s
.
PartTab
.
Clone
()
,
}
}
}
}
...
@@ -105,6 +107,8 @@ func (cs *ClusterState) Snapshot() *ClusterStateSnapshot {
...
@@ -105,6 +107,8 @@ func (cs *ClusterState) Snapshot() *ClusterStateSnapshot {
// - current cluster state.
// - current cluster state.
type
Node
struct
{
type
Node
struct
{
// MyInfo proto.NodeInfo // type, laddr, nid, state, idtime XXX nid is managed by M
// MyInfo proto.NodeInfo // type, laddr, nid, state, idtime XXX nid is managed by M
Type
proto
.
NodeType
Addr
proto
.
Address
// listening address XXX -> LAddr ?
State
NodeState
State
NodeState
// XXX type, laddr
// XXX type, laddr
ClusterName
string
ClusterName
string
...
@@ -122,14 +126,15 @@ type Node struct {
...
@@ -122,14 +126,15 @@ type Node struct {
// NewNode creates new node.
// NewNode creates new node.
func
NewNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
Node
{
func
NewNode
(
typ
proto
.
NodeType
,
clusterName
string
,
net
xnet
.
Networker
,
masterAddr
string
)
*
Node
{
node
:=
&
Node
{
node
:=
&
Node
{
State
{
Type
:
typ
,
State
:
{
NID
:
proto
.
NID
(
typ
,
0
),
// temp, e.g. S? TODO use "temp" bit in NodeID
NID
:
proto
.
NID
(
typ
,
0
),
// temp, e.g. S? TODO use "temp" bit in NodeID
IdTime
:
proto
.
IdTimeNone
,
IdTime
:
proto
.
IdTimeNone
,
NodeTab
:
&
NodeTable
{},
NodeTab
:
&
NodeTable
{},
PartTab
:
&
PartitionTable
{},
PartTab
:
&
PartitionTable
{},
ClusterState
:
-
1
,
// invalid
ClusterState
:
-
1
,
// invalid
}
}
,
ClusterName
:
clusterName
,
ClusterName
:
clusterName
,
...
...
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