Commit 0af56694 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent f3510fde
...@@ -61,10 +61,11 @@ import ( ...@@ -61,10 +61,11 @@ import (
// //
// XXX update after introduction of _MasterLink // XXX update after introduction of _MasterLink
type _MasteredNode struct { type _MasteredNode struct {
myInfo proto.NodeInfo // type, laddr, nid, state, idtime node *xneo.Node
ClusterName string // myInfo proto.NodeInfo // type, laddr, nid, state, idtime
Net xnet.Networker // network AP we are sending/receiving on // ClusterName string
MasterAddr string // address of current master TODO -> masterRegistry // Net xnet.Networker // network AP we are sending/receiving on
// MasterAddr string // address of current master TODO -> masterRegistry
// operational state is maintained by TalkMaster. // operational state is maintained by TalkMaster.
// users retrieve it via WithOperational(). // users retrieve it via WithOperational().
...@@ -74,7 +75,7 @@ type _MasteredNode struct { ...@@ -74,7 +75,7 @@ type _MasteredNode struct {
// - state of partTab/nodeTab is operational // - state of partTab/nodeTab is operational
opMu sync.RWMutex opMu sync.RWMutex
mlink *neonet.NodeLink // link to master mlink *neonet.NodeLink // link to master
state xneo.ClusterState // nodeTab/partTab/clusterState // state xneo.ClusterState // nodeTab/partTab/clusterState
opReady chan struct{} // reinitialized each time state becomes non-operational opReady chan struct{} // reinitialized each time state becomes non-operational
operational bool // cache for state.IsOperational() operational bool // cache for state.IsOperational()
...@@ -113,6 +114,8 @@ const ( ...@@ -113,6 +114,8 @@ const (
// XXX doc // XXX doc
func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterAddr string) *_MasteredNode { func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterAddr string) *_MasteredNode {
node := &_MasteredNode{ node := &_MasteredNode{
node: xneo.NewNode(typ, clusterName, net, masterAddr),
/*
myInfo: proto.NodeInfo{ myInfo: proto.NodeInfo{
Type: typ, Type: typ,
Addr: proto.Address{}, Addr: proto.Address{},
...@@ -129,7 +132,7 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker, ...@@ -129,7 +132,7 @@ func newMasteredNode(typ proto.NodeType, clusterName string, net xnet.Networker,
PartTab: &xneo.PartitionTable{}, PartTab: &xneo.PartitionTable{},
Code: -1, // invalid Code: -1, // invalid
}, },
*/
opReady: make(chan struct{}), opReady: make(chan struct{}),
} }
......
...@@ -49,34 +49,42 @@ func (cs *ClusterState) IsOperational() bool { ...@@ -49,34 +49,42 @@ func (cs *ClusterState) IsOperational() bool {
// - current partition table (how data is split around storage nodes), // - current partition table (how data is split around storage nodes),
// - current cluster state. // - current cluster state.
type Node struct { type Node struct {
MyInfo proto.NodeInfo MyInfo proto.NodeInfo // type, laddr, nid, state, idtime
ClusterName string ClusterName string
Net xnet.Networker // network AP we are sending/receiving on Net xnet.Networker // network AP we are sending/receiving on
MasterAddr string // address of current master XXX put under StateMu ? MasterAddr string // address of current master TODO -> masterRegistry
StateMu sync.RWMutex // <- XXX just embed? StateMu sync.RWMutex // <- XXX unexport
NodeTab *NodeTable // information about nodes in the cluster state ClusterState // nodeTab/partTab/stateCode
PartTab *PartitionTable // information about data distribution in the cluster // NodeTab *NodeTable // information about nodes in the cluster
ClusterState proto.ClusterState // master idea about cluster state // PartTab *PartitionTable // information about data distribution in the cluster
// ClusterState proto.ClusterState // master idea about cluster state
// should be set by user so Node can notify when master tells this node to shutdown // // should be set by user so Node can notify when master tells this node to shutdown
OnShutdown func() // OnShutdown func()
} }
// NewNode creates new node. // NewNode creates new node.
func NewNode(net xnet.Networker, typ proto.NodeType, clusterName, masterAddr string) *Node { func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterAddr string) *Node {
node := &Node{ node := &Node{
MyInfo: proto.NodeInfo{Type: typ, Addr: proto.Address{}, NID: 0, IdTime: proto.IdTimeNone}, MyInfo: proto.NodeInfo{
Type: typ,
Addr: proto.Address{},
NID: 0,
IdTime: proto.IdTimeNone,
},
ClusterName: clusterName, ClusterName: clusterName,
Net: net, Net: net,
MasterAddr: masterAddr, MasterAddr: masterAddr,
state: ClusterState{
NodeTab: &NodeTable{}, NodeTab: &NodeTable{},
PartTab: &PartitionTable{}, PartTab: &PartitionTable{},
ClusterState: -1, // invalid Code: -1, // invalid
},
} }
node.NodeTab.localNode = node node.state.NodeTab.localNode = node
return node 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