Commit 32928af7 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 221be50a
...@@ -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() *NodeTable {
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 {
......
...@@ -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 ?) MyNID 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,
......
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