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

.

parent 1cc74a85
...@@ -146,7 +146,7 @@ HasLock C -> S ...@@ -146,7 +146,7 @@ HasLock C -> S
AnswerHasLock S -> C AnswerHasLock S -> C
oid OID oid OID
lock_state LockState // not_locket, granted, granted_to_other:w lock_state LockState // not_locket, granted, granted_to_other
CheckCurrentSerial C -> S AnswerCheckCurrentSerial S -> C CheckCurrentSerial C -> S AnswerCheckCurrentSerial S -> C
tid TID conflicting bool tid TID conflicting bool
......
...@@ -41,6 +41,7 @@ type Master struct { ...@@ -41,6 +41,7 @@ type Master struct {
func NewMaster(clusterName string) *Master { func NewMaster(clusterName string) *Master {
m := &Master{clusterName: clusterName} m := &Master{clusterName: clusterName}
m.SetClusterState(RECOVERING) // XXX no elections - we are the only master m.SetClusterState(RECOVERING) // XXX no elections - we are the only master
return m return m
} }
...@@ -75,6 +76,7 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) { ...@@ -75,6 +76,7 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
}() }()
// identify // identify
// XXX add logic to verify/assign nodeID and do other requested identification checks
nodeInfo, err := IdentifyPeer(link, MASTER) nodeInfo, err := IdentifyPeer(link, MASTER)
if err != nil { if err != nil {
fmt.Printf("master: %v\n", err) fmt.Printf("master: %v\n", err)
...@@ -86,12 +88,59 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) { ...@@ -86,12 +88,59 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
m.nodeTab.Add(&Node{nodeInfo, link}) m.nodeTab.Add(&Node{nodeInfo, link})
m.nodeTab.Unlock() m.nodeTab.Unlock()
// TODO subscribe to nodeTab and broadcast updates // TODO subscribe to nodeTab and broadcast updates:
//
// NotifyPartitionTable PM -> S, C
// PartitionChanges PM -> S, C // subset of NotifyPartitionTable (?)
// NotifyNodeIntormation PM -> *
// TODO notify about cluster state changes
// ClusterInformation (PM -> * ?)
// identification passed, now serve other requests // identification passed, now serve other requests
// client: notify + serve requests // client: notify + serve requests
// storage: notify + ? // storage: notify + ?
//
// >Recovery
// <AnswerRecovery
//
// >PartitionTable
// <AnswerPartitionTable
//
// # neoctl start
// # (via changing nodeTab and relying on broadcast distribution ?)
// >NotifyNodeInformation (S1.state=RUNNING)
// # S: "I was told I'm RUNNING"
//
// # (via changing m.clusterState and relying on broadcast ?)
// >NotifyClusterInformation (cluster_state=VERIFYING)
//
// # (via changing partTab and relying on broadcast ?)
// >NotifyPartitionTable (ptid=1, `node 0: S1, R`)
// # S saves PT info locally
//
// # M asks about unfinished transactions
// >AskLockedTransactions
// <AnswerLockedTransactions {} ttid -> tid # in example we have empty
//
// >LastIDs
// <AnswerLastIDs (last_oid, last_tid)
//
// # (via changing m.clusterState and relying on broadcast ?)
// >NotifyClusterInformation (cluster_state=RUNNING)
//
// >StartOperation
// <NotifyReady
// XXX only here we can update nodeTab with S1.state=RUNNING
//
// ...
//
// StopOperation PM -> S
} }
......
...@@ -27,6 +27,8 @@ import ( ...@@ -27,6 +27,8 @@ import (
// Usually Master maintains such table and provides it to other nodes to know // Usually Master maintains such table and provides it to other nodes to know
// each other but in general use-cases can be different. // each other but in general use-cases can be different.
// //
// XXX vvv is about Master=main use-case:
//
// - Primary Master view of cluster // - Primary Master view of cluster
// - M tracks changes to nodeTab as nodes appear (connected to M) and go (disconnected from M) // - M tracks changes to nodeTab as nodes appear (connected to M) and go (disconnected from M)
// - M regularly broadcasts nodeTab content updates(?) to all nodes // - M regularly broadcasts nodeTab content updates(?) to all nodes
...@@ -59,6 +61,7 @@ import ( ...@@ -59,6 +61,7 @@ import (
// sure not to accept new connections -> XXX not needed - just stop listening // sure not to accept new connections -> XXX not needed - just stop listening
// first. // first.
// //
// NodeTable zero value is valid empty node table.
type NodeTable struct { type NodeTable struct {
// users have to care locking explicitly // users have to care locking explicitly
sync.RWMutex sync.RWMutex
...@@ -88,6 +91,8 @@ func (nt *NodeTable) Add(node *Node) { ...@@ -88,6 +91,8 @@ func (nt *NodeTable) Add(node *Node) {
// XXX check node is already there // XXX check node is already there
// XXX pass/store node by pointer ? // XXX pass/store node by pointer ?
nt.nodev = append(nt.nodev, *node) nt.nodev = append(nt.nodev, *node)
// TODO notify all nodelink subscribers about new info
} }
// TODO subscribe for changes on Add ? (notification via channel) // TODO subscribe for changes on Add ? (notification via channel)
......
...@@ -29,7 +29,7 @@ package neo ...@@ -29,7 +29,7 @@ package neo
// //
// Oid space is divided (partitioned) into Np parts via // Oid space is divided (partitioned) into Np parts via
// //
// ptid(oid) = oid % Np // ptid(oid) = oid % Np XXX ptid -> pid ?
// //
// rule. The `oid % Np` is known as partition identifier of oid. // rule. The `oid % Np` is known as partition identifier of oid.
// //
...@@ -102,6 +102,8 @@ package neo ...@@ -102,6 +102,8 @@ package neo
// Usually Master maintains partition table, plans partition updates and tells // Usually Master maintains partition table, plans partition updates and tells
// storages to executed them, and broadcasts partition table updates to all // storages to executed them, and broadcasts partition table updates to all
// nodes in the cluster. // nodes in the cluster.
//
// PartitionTable zero value is valid empty partition table.
type PartitionTable struct { type PartitionTable struct {
// XXX do we need sync.Mutex here for updates ? // XXX do we need sync.Mutex here for updates ?
......
...@@ -135,6 +135,8 @@ func IdentifyPeer(link *NodeLink, myNodeType NodeType) (nodeInfo RequestIdentifi ...@@ -135,6 +135,8 @@ func IdentifyPeer(link *NodeLink, myNodeType NodeType) (nodeInfo RequestIdentifi
case *RequestIdentification: case *RequestIdentification:
// TODO (.NodeType, .UUID, .Address, .Name, .IdTimestamp) -> check + register to NM // TODO (.NodeType, .UUID, .Address, .Name, .IdTimestamp) -> check + register to NM
// TODO hook here in logic to check identification request, assign nodeID etc
err = EncodeAndSend(conn, &AcceptIdentification{ err = EncodeAndSend(conn, &AcceptIdentification{
NodeType: myNodeType, NodeType: myNodeType,
MyNodeID: 0, // XXX MyNodeID: 0, // XXX
......
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