Commit 3340f3a3 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent edc38c9d
......@@ -228,7 +228,9 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
}
// recvMaster receives and handles notifications from master
func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) (err error) {
defer task.Running(&ctx, "rx")(&err)
// XXX .nodeTab.Reset()
for {
......@@ -286,15 +288,18 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
}
}
func (c *Client) initFromMaster(ctx context.Context, mlink *neo.NodeLink) error {
func (c *Client) initFromMaster(ctx context.Context, mlink *neo.NodeLink) (err error) {
defer task.Running(&ctx, "init")(&err)
// ask M for PT
rpt := neo.AnswerPartitionTable{}
err := mlink.Ask1(&neo.AskPartitionTable{}, &rpt)
err = mlink.Ask1(&neo.AskPartitionTable{}, &rpt)
if err != nil {
return err
}
pt := neo.PartTabFromDump(rpt.PTid, rpt.RowList)
log.Infof(ctx, "master initialized us with nex parttab:\n%s", pt)
c.node.StateMu.Lock()
c.node.PartTab = pt
c.node.StateMu.Unlock()
......
......@@ -330,7 +330,7 @@ func (l *listener) Addr() net.Addr {
func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformation) {
// XXX msg.IdTime ?
for _, nodeInfo := range msg.NodeList {
log.Infof(ctx, "rx node update: %v", nodeInfo)
log.Infof(ctx, "node update: %v", nodeInfo)
app.NodeTab.Update(nodeInfo)
// XXX we have to provide IdTime when requesting identification to other peers
......@@ -357,13 +357,13 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
func (app *NodeApp) UpdatePartTab(ctx context.Context, msg *SendPartitionTable) {
pt := PartTabFromDump(msg.PTid, msg.RowList)
// XXX logging under lock
log.Infof(ctx, "rx parttab: %v", pt)
log.Infof(ctx, "parttab update: %v", pt)
app.PartTab = pt
}
// UpdateClusterState applies update to .ClusterState from message and logs change appropriately.
func (app *NodeApp) UpdateClusterState(ctx context.Context, msg *NotifyClusterState) {
// XXX loging under lock
log.Infof(ctx, "rx state update: %v", msg.State)
log.Infof(ctx, "state update: %v", msg.State)
app.ClusterState.Set(msg.State)
}
......@@ -21,6 +21,7 @@ package neo
// partition table
import (
"bytes"
"fmt"
"lab.nexedi.com/kirr/neo/go/zodb"
......@@ -218,6 +219,26 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
// ---- encode / decode PT to / from messages
// XXX naming
func (pt *PartitionTable) String() string {
buf := &bytes.Buffer{}
fmt.Fprintf(buf, "PT.%d[%d]\n", pt.PTid, len(pt.tab))
for i, cellv := range pt.tab {
fmt.Fprintf(buf, "%d:\t", i)
if len(cellv) == 0 {
fmt.Fprintf(buf, \n")
continue
}
for _, cell := range cellv {
fmt.Fprintf(buf, " %s(%s)", cell.UUID, cell.State)
}
fmt.Fprintf(buf, "\n")
}
return buf.String()
}
// XXX -> RowList() ?
func (pt *PartitionTable) Dump() []RowInfo { // XXX also include .ptid? -> struct ?
rowv := make([]RowInfo, len(pt.tab))
......
......@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
//go:generate stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState proto.go packed.go
//go:generate stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState,CellState proto.go packed.go
package neo
// supporting code for types defined in proto.go
......
// Code generated by "stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState proto.go packed.go"; DO NOT EDIT.
// Code generated by "stringer -output zproto-str.go -type ErrorCode,ClusterState,NodeType,NodeState,CellState proto.go packed.go"; DO NOT EDIT.
package neo
......@@ -47,3 +47,14 @@ func (i NodeState) String() string {
}
return _NodeState_name[_NodeState_index[i]:_NodeState_index[i+1]]
}
const _CellState_name = "UP_TO_DATEOUT_OF_DATEFEEDINGDISCARDEDCORRUPTED"
var _CellState_index = [...]uint8{0, 10, 21, 28, 37, 46}
func (i CellState) String() string {
if i < 0 || i >= CellState(len(_CellState_index)-1) {
return fmt.Sprintf("CellState(%d)", i)
}
return _CellState_name[_CellState_index[i]:_CellState_index[i+1]]
}
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