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

.

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