Commit 94746190 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c8565988
......@@ -83,7 +83,12 @@ type NodeTable struct {
type PeerNode struct {
proto.NodeInfo // (.type, .laddr, .nid, .state, .idtime) XXX also protect by mu?
// XXX -> *peerLink
link *_PeerLink
}
// _PeerLink provides PeerNode's link implementation.
// It is shared between several PeerNode clones.
type _PeerLink struct {
localNode *Node // link is for peer of .localNode
linkMu sync.Mutex
......@@ -158,6 +163,7 @@ func (nt *NodeTable) Update(nodeInfo proto.NodeInfo) *PeerNode {
node.NodeInfo = nodeInfo
// XXX close link if .state becomes DOWN ?
// XXX ----//---- if .Type or .Addr changes ?
traceNodeChanged(nt, node)
return node
......@@ -191,7 +197,12 @@ func (nt *NodeTable) String() string {
// Clone creates new instance of NodeTable initialized with previous content.
func (nt *NodeTable) Clone() *NodeTable {
nt_ := &NodeTable{localNode: nt.localNode}
nt_.nodev = append([]*PeerNode(nil), nt.nodev...)
for _, node := range nt.nodev {
nt_.nodev = append(nt_.nodev, &PeerNode{
NodeInfo: node.NodeInfo,
link: node.link,
})
}
return nt_
}
......@@ -253,7 +264,7 @@ func (p *PeerNode) ResetLink(ctx context.Context) {
// XXX p.* reading without lock - ok?
func (p *PeerNode) dial(ctx context.Context) (_ *neonet.NodeLink, err error) {
node := p.localNode
var s *NodeState // XXX stub
s := node.stateLog.ReadHead() // XXX better Dial gets the state from the caller? (as here it can be different from the context in which caller thinks it operates)
defer task.Runningf(&ctx, "dial %s", p.NID)(&err)
reqID := &proto.RequestIdentification{
......
......@@ -30,6 +30,7 @@ type State struct {
}
// StateRO provides read-only access to a State.
// XXX -> StateSnapshot ?
type StateRO interface {
NodeTab() NodeTableRO
PartTab() PartitionTableRO
......
......@@ -29,6 +29,7 @@ import (
"lab.nexedi.com/kirr/neo/go/neo/proto"
)
/*
// NodeState represent state maintained on a Node.
//
// XXX text about imaginary transactional log of state changes originated from master.
......@@ -56,6 +57,7 @@ func (s *NodeState) Clone() *NodeState {
PartTab: s.PartTab.Clone(),
}
}
*/
/*
......@@ -112,8 +114,7 @@ type Node struct {
Type proto.NodeType
Addr proto.Address // listening address XXX -> LAddr ?
stateLogMu sync.Mutex
state *NodeState
stateLog StateLog // log of [](mynid, myidtime, nodeTab, partTab, clusterState)
ClusterName string
Net xnet.Networker // network AP we are sending/receiving on
......@@ -131,6 +132,7 @@ type Node struct {
func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterAddr string) *Node {
node := &Node{
Type: typ,
/*
state: &NodeState{
MyNID: proto.NID(typ, 0), // temp, e.g. S? TODO use "temp" bit in NodeID
IdTime: proto.IdTimeNone,
......@@ -139,6 +141,7 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
PartTab: &PartitionTable{},
ClusterState: -1, // invalid
},
*/
ClusterName: clusterName,
......@@ -146,7 +149,15 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
MasterAddr: masterAddr,
}
node.state.NodeTab.localNode = node
s := &State{
NodeTab: &NodeTable{},
PartTab: &PartitionTable{},
ClusterState: -1, // invalid
}
s.NodeTab.localNode = node
node.stateLog.head = s
return node
}
......
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