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

.

parent 221be50a
......@@ -135,7 +135,7 @@ func (nt *NodeTable) Get(nid proto.NodeID) *PeerNode {
func (nt *NodeTable) Update(nodeInfo proto.NodeInfo) *PeerNode {
node := nt.Get(nodeInfo.NID)
if node == nil {
node = &PeerNode{nodeTab: nt}
node = &PeerNode{localNode: nt.localNode}
nt.nodev = append(nt.nodev, node)
}
......@@ -173,9 +173,9 @@ func (nt *NodeTable) String() string {
// 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_.nodev = append([]*PeerNode(nil), nt.nodev)
nt_.nodev = append([]*PeerNode(nil), nt.nodev...)
return nt_
}
......@@ -236,16 +236,16 @@ func (p *PeerNode) ResetLink(ctx context.Context) {
// dial does low-level work to dial peer
// XXX p.* reading without lock - ok?
func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) {
node := p.nodeTab.localNode
mynid := node.MyInfo.NID // XXX locking
node := p.localNode
var s *NodeState // XXX stub
defer task.Runningf(&ctx, "dial %s", p.NID)(&err)
reqID := &proto.RequestIdentification{
NodeType: node.MyInfo.Type,
NID: mynid,
Address: node.MyInfo.Addr,
NodeType: node.Type,
NID: s.MyNID,
Address: node.Addr,
ClusterName: node.ClusterName,
IdTime: node.MyInfo.IdTime,
IdTime: s.IdTime,
DevPath: nil, // XXX stub
NewNID: nil, // XXX stub
}
......@@ -261,8 +261,8 @@ func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) {
case accept.MyNID != p.NID:
err = fmt.Errorf("connected, but peer's nid is not %s (identifies as %s)", p.NID, accept.MyNID)
case accept.YourNID != mynid:
err = fmt.Errorf("connected, but peer gives us nid %s (our is %s)", accept.YourNID, mynid)
case accept.YourNID != s.MyNID:
err = fmt.Errorf("connected, but peer gives us nid %s (our is %s)", accept.YourNID, s.MyNID)
}
if err != nil {
......
......@@ -30,8 +30,10 @@ import (
)
// NodeState represent state maintained on a Node.
//
// XXX text about imaginary transactional log of state changes originated from master.
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
NodeTab *NodeTable // nodes in the cluster
......@@ -48,8 +50,8 @@ func (s *NodeState) Clone() *NodeState {
// TODO ? if cloning full nodeTab/partTab becomes slow (for large
// tables) -> change to create COW reference.
NodeTab: s.NodeTab.Clone()
PaetTab: s.PartTab.Clone()
NodeTab: s.NodeTab.Clone(),
PaetTab: s.PartTab.Clone(),
}
}
......@@ -105,6 +107,8 @@ func (cs *ClusterState) Snapshot() *ClusterStateSnapshot {
// - current cluster state.
type Node struct {
// 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
// XXX type, laddr
ClusterName string
......@@ -122,14 +126,15 @@ type Node struct {
// NewNode creates new node.
func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterAddr string) *Node {
node := &Node{
State {
Type: typ,
State: {
NID: proto.NID(typ, 0), // temp, e.g. S? TODO use "temp" bit in NodeID
IdTime: proto.IdTimeNone,
NodeTab: &NodeTable{},
PartTab: &PartitionTable{},
ClusterState: -1, // invalid
}
},
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