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
20b124bb
Commit
20b124bb
authored
Feb 22, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
8be71aec
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
15 deletions
+13
-15
go/neo/internal/xtime/xtime.go
go/neo/internal/xtime/xtime.go
+4
-5
go/neo/proto/proto-misc.go
go/neo/proto/proto-misc.go
+2
-1
go/neo/xneo/nodetab.go
go/neo/xneo/nodetab.go
+6
-8
go/neo/xneo/parttab_test.go
go/neo/xneo/parttab_test.go
+1
-1
No files found.
go/neo/internal/xtime/xtime.go
View file @
20b124bb
...
@@ -24,14 +24,13 @@ import (
...
@@ -24,14 +24,13 @@ import (
"time"
"time"
)
)
// Mono returns
time passed since program start
.
// Mono returns
monotonically increasing time
.
// It uses monot
honic time for measur
ments and is robust to OS clock adjustments
// It uses monot
onic time for measure
ments and is robust to OS clock adjustments
//
//
// XXX better return time.Duration?
// XXX better return time.Duration?
func
Mono
()
float64
{
func
Mono
()
float64
{
// time.Sub uses monotonic clock readings for the difference
// time.Sub uses monotonic clock readings for the difference
// FIXME py retruns it since epoch, not since start
return
time
.
Now
()
.
Sub
(
epoch
)
.
Seconds
()
return
time
.
Now
()
.
Sub
(
tstart
)
.
Seconds
()
}
}
var
tstart
time
.
Time
=
time
.
Now
()
var
epoch
time
.
Time
// zero value is epoch
go/neo/proto/proto-misc.go
View file @
20b124bb
...
@@ -156,7 +156,8 @@ func (t IdTime) String() string {
...
@@ -156,7 +156,8 @@ func (t IdTime) String() string {
sec
:=
int64
(
t
)
sec
:=
int64
(
t
)
nsec
:=
int64
((
float64
(
t
)
-
float64
(
sec
))
*
1E9
)
nsec
:=
int64
((
float64
(
t
)
-
float64
(
sec
))
*
1E9
)
return
time
.
Unix
(
sec
,
nsec
)
.
String
()
tt
:=
time
.
Unix
(
sec
,
nsec
)
.
UTC
()
return
tt
.
Format
(
"2006-01-02T15:04:05.999999999"
)
// RFC3339Nano without zone
}
}
// ----------------------------------------
// ----------------------------------------
...
...
go/neo/xneo/nodetab.go
View file @
20b124bb
...
@@ -35,14 +35,14 @@ import (
...
@@ -35,14 +35,14 @@ import (
"lab.nexedi.com/kirr/neo/go/internal/xio"
"lab.nexedi.com/kirr/neo/go/internal/xio"
)
)
// NodeTable represents known
nodes in a cluster. XXX + "containing" parent node
// NodeTable represents known
peer nodes in a cluster.
//
//
// It is
// It is
//
//
// NID -> *PeerNode ; = (.laddr, .state, ...) + .link
// NID -> *PeerNode ; = (.laddr, .state, ...) + .link
//
//
// mapping listing known nodes and associating their node ID with information
// mapping listing known nodes and associating their node ID with information
// about a
node
.
// about a
peer
.
//
//
// Master maintains such table and provides it to its peers to know each other:
// Master maintains such table and provides it to its peers to know each other:
//
//
...
@@ -60,20 +60,18 @@ import (
...
@@ -60,20 +60,18 @@ import (
// NOTE once a node was added to NodeTable its entry is never deleted: if e.g.
// NOTE once a node was added to NodeTable its entry is never deleted: if e.g.
// a connection to node is lost associated entry is marked as having DOWN (XXX
// a connection to node is lost associated entry is marked as having DOWN (XXX
// or UNKNOWN ?) node state.
// or UNKNOWN ?) node state.
//
// NodeTable zero value is valid empty node table. XXX recheck
//
// XXX users have to care locking explicitly
type
NodeTable
struct
{
type
NodeTable
struct
{
// XXX for PeerNode.Dial to work. see also comments vvv near "peer link"
// XXX for PeerNode.Dial to work. see also comments vvv near "peer link"
localNode
*
Node
localNode
*
Node
nodev
[]
*
PeerNode
// all
node
s
nodev
[]
*
PeerNode
// all
known peer
s
}
}
//trace:event traceNodeChanged(nt *NodeTable, n *PeerNode)
//trace:event traceNodeChanged(nt *NodeTable, n *PeerNode)
// PeerNode represents a peer node in the cluster.
// PeerNode represents a peer node in the cluster.
//
// XXX = peer's nodeinfo + link
type
PeerNode
struct
{
type
PeerNode
struct
{
nodeTab
*
NodeTable
// this node is part of
nodeTab
*
NodeTable
// this node is part of
...
@@ -120,7 +118,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
...
@@ -120,7 +118,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
return
nil
return
nil
}
}
//
XXX
GetByAddress ?
//
TODO
GetByAddress ?
// Update updates information about a node.
// Update updates information about a node.
//
//
...
...
go/neo/xneo/parttab_test.go
View file @
20b124bb
...
@@ -31,7 +31,7 @@ func TestPartTabOperational(t *testing.T) {
...
@@ -31,7 +31,7 @@ func TestPartTabOperational(t *testing.T) {
// create nodeinfo for nid/state
// create nodeinfo for nid/state
n
:=
func
(
nid
proto
.
NodeID
,
state
proto
.
NodeState
)
proto
.
NodeInfo
{
n
:=
func
(
nid
proto
.
NodeID
,
state
proto
.
NodeState
)
proto
.
NodeInfo
{
return
proto
.
NodeInfo
{
NID
:
nid
,
State
:
state
}
// XXX .Type
?
return
proto
.
NodeInfo
{
NID
:
nid
,
State
:
state
}
// TODO .Type - extract from NID
?
}
}
// create nodetab with [](nid, state)
// create nodetab with [](nid, 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