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

.

parent 8be71aec
......@@ -24,14 +24,13 @@ import (
"time"
)
// Mono returns time passed since program start.
// It uses monothonic time for measurments and is robust to OS clock adjustments
// Mono returns monotonically increasing time.
// It uses monotonic time for measurements and is robust to OS clock adjustments
//
// XXX better return time.Duration?
func Mono() float64 {
// time.Sub uses monotonic clock readings for the difference
// FIXME py retruns it since epoch, not since start
return time.Now().Sub(tstart).Seconds()
return time.Now().Sub(epoch).Seconds()
}
var tstart time.Time = time.Now()
var epoch time.Time // zero value is epoch
......@@ -156,7 +156,8 @@ func (t IdTime) String() string {
sec := int64(t)
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 (
"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
//
// NID -> *PeerNode ; = (.laddr, .state, ...) + .link
//
// 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:
//
......@@ -60,20 +60,18 @@ import (
// 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
// or UNKNOWN ?) node state.
//
// NodeTable zero value is valid empty node table. XXX recheck
//
// XXX users have to care locking explicitly
type NodeTable struct {
// XXX for PeerNode.Dial to work. see also comments vvv near "peer link"
localNode *Node
nodev []*PeerNode // all nodes
nodev []*PeerNode // all known peers
}
//trace:event traceNodeChanged(nt *NodeTable, n *PeerNode)
// PeerNode represents a peer node in the cluster.
//
// XXX = peer's nodeinfo + link
type PeerNode struct {
nodeTab *NodeTable // this node is part of
......@@ -120,7 +118,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
return nil
}
// XXX GetByAddress ?
// TODO GetByAddress ?
// Update updates information about a node.
//
......
......@@ -31,7 +31,7 @@ func TestPartTabOperational(t *testing.T) {
// create nodeinfo for nid/state
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)
......
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