Commit 20b124bb authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 8be71aec
...@@ -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 monothonic time for measurments and is robust to OS clock adjustments // It uses monotonic time for measurements 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
...@@ -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
} }
// ---------------------------------------- // ----------------------------------------
......
...@@ -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 nodes nodev []*PeerNode // all known peers
} }
//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.
// //
......
...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment