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

.

parent 1cc74a85
......@@ -146,7 +146,7 @@ HasLock C -> S
AnswerHasLock S -> C
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
tid TID conflicting bool
......
......@@ -41,6 +41,7 @@ type Master struct {
func NewMaster(clusterName string) *Master {
m := &Master{clusterName: clusterName}
m.SetClusterState(RECOVERING) // XXX no elections - we are the only master
return m
}
......@@ -75,6 +76,7 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
}()
// identify
// XXX add logic to verify/assign nodeID and do other requested identification checks
nodeInfo, err := IdentifyPeer(link, MASTER)
if err != nil {
fmt.Printf("master: %v\n", err)
......@@ -86,12 +88,59 @@ func (m *Master) ServeLink(ctx context.Context, link *NodeLink) {
m.nodeTab.Add(&Node{nodeInfo, link})
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
// client: notify + serve requests
// 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 (
// Usually Master maintains such table and provides it to other nodes to know
// each other but in general use-cases can be different.
//
// XXX vvv is about Master=main use-case:
//
// - Primary Master view of cluster
// - 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
......@@ -59,6 +61,7 @@ import (
// sure not to accept new connections -> XXX not needed - just stop listening
// first.
//
// NodeTable zero value is valid empty node table.
type NodeTable struct {
// users have to care locking explicitly
sync.RWMutex
......@@ -88,6 +91,8 @@ func (nt *NodeTable) Add(node *Node) {
// XXX check node is already there
// XXX pass/store node by pointer ?
nt.nodev = append(nt.nodev, *node)
// TODO notify all nodelink subscribers about new info
}
// TODO subscribe for changes on Add ? (notification via channel)
......
......@@ -29,7 +29,7 @@ package neo
//
// 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.
//
......@@ -102,6 +102,8 @@ package neo
// Usually Master maintains partition table, plans partition updates and tells
// storages to executed them, and broadcasts partition table updates to all
// nodes in the cluster.
//
// PartitionTable zero value is valid empty partition table.
type PartitionTable struct {
// XXX do we need sync.Mutex here for updates ?
......
......@@ -135,6 +135,8 @@ func IdentifyPeer(link *NodeLink, myNodeType NodeType) (nodeInfo RequestIdentifi
case *RequestIdentification:
// 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{
NodeType: myNodeType,
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