From 43cab1eb8c16c044c3d552c81161154c290df000 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov <kirr@nexedi.com> Date: Thu, 4 May 2017 12:53:31 +0300 Subject: [PATCH] . --- go/NOTES | 2 +- go/neo/master.go | 11 +++++++-- go/neo/proto.go | 18 +-------------- go/nodetab.go | 31 ++++++++++++++++++++++++++ go/parttab.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 20 deletions(-) create mode 100644 go/nodetab.go create mode 100644 go/parttab.go diff --git a/go/NOTES b/go/NOTES index 89bca1a3..1a774fbd 100644 --- a/go/NOTES +++ b/go/NOTES @@ -381,7 +381,7 @@ Partition Table (general & current-py) #Np (how-many partitions) #R (replication factor) Cell .node (-> .nodeid, .addr) - .state + .cell_state .backup_tid # last tid this cell has all data for .replicating # currently replicating up to this (.replicating) tid diff --git a/go/neo/master.go b/go/neo/master.go index 1cc554e9..6f1dae7d 100644 --- a/go/neo/master.go +++ b/go/neo/master.go @@ -34,11 +34,18 @@ type Master struct { } func NewMaster(clusterName string) *Master { - return &Master{clusterName} - // XXX .clusterState = RECOVERING ? + m := &Master{clusterName} + m.SetClusterState(RECOVERING) // XXX no elections - we are the only master + return m } + +func (m *Master) SetClusterState(state ClusterState) { + m.clusterState = state + // XXX actions ? +} + // ServeLink serves incoming node-node link connection // XXX +error return? func (m *Master) ServeLink(ctx context.Context, link *NodeLink) { diff --git a/go/neo/proto.go b/go/neo/proto.go index da36e35d..0a6032d4 100644 --- a/go/neo/proto.go +++ b/go/neo/proto.go @@ -222,7 +222,7 @@ func float64_NEODecode(b []byte) float64 { return math.Float64frombits(fu) } -// NOTE original NodeList = []NodeInfo +// NodeInfo is information about a node type NodeInfo struct { NodeType Address @@ -244,22 +244,6 @@ type RowInfo struct { } -type XXXTest struct { - qqq uint32 - aaa uint32 - Zzz map[int32]string -} - - - -// // XXX link request <-> answer ? -// // XXX naming -> PktHeader ? -// type PktHead struct { -// ConnId be32 // NOTE is .msgid in py -// MsgCode be16 -// Len be32 // whole packet length (including header) -// } - // General purpose notification (remote logging) type Notify struct { diff --git a/go/nodetab.go b/go/nodetab.go new file mode 100644 index 00000000..6b6c9278 --- /dev/null +++ b/go/nodetab.go @@ -0,0 +1,31 @@ +// Copyright (C) 2017 Nexedi SA and Contributors. +// Kirill Smelkov <kirr@nexedi.com> +// +// This program is free software: you can Use, Study, Modify and Redistribute +// it under the terms of the GNU General Public License version 3, or (at your +// option) any later version, as published by the Free Software Foundation. +// +// You can also Link and Combine this program with other software covered by +// the terms of any of the Open Source Initiative approved licenses and Convey +// the resulting work. Corresponding source of such a combination shall include +// the source code for all other software used. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the implied +// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// +// See COPYING file for full licensing terms. + +package neo +// node management & node table + +// Node represents a node from local-node point of view +type Node struct { + Info NodeInfo + + Link *NodeLink // link to this node; =nil if not connected +} + + +// NodeTable represents all known nodes in a cluster from local-node point of view +type NodeTable struct { +} diff --git a/go/parttab.go b/go/parttab.go new file mode 100644 index 00000000..2543f1b4 --- /dev/null +++ b/go/parttab.go @@ -0,0 +1,58 @@ +// Copyright (C) 2017 Nexedi SA and Contributors. +// Kirill Smelkov <kirr@nexedi.com> +// +// This program is free software: you can Use, Study, Modify and Redistribute +// it under the terms of the GNU General Public License version 3, or (at your +// option) any later version, as published by the Free Software Foundation. +// +// You can also Link and Combine this program with other software covered by +// the terms of any of the Open Source Initiative approved licenses and Convey +// the resulting work. Corresponding source of such a combination shall include +// the source code for all other software used. +// +// This program is distributed WITHOUT ANY WARRANTY; without even the implied +// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// +// See COPYING file for full licensing terms. + +package neo +// partition table + +// PartitionTable represents object space partitioning in a cluster +// +// XXX description: +// +// #Np (how-many partitions) #R (replication factor) +// Cell +// .node (-> .nodeid, .addr) +// .cell_state +// +// .backup_tid # last tid this cell has all data for +// .replicating # currently replicating up to this (.replicating) tid +// +// PT +// .id↑ +// .partition_list [#Np] of []Cell +// .count_dict {} node -> #node_used_in_pt +// +// +// Pt +// +-+ +// | | +// +-+ +----------+ +------------+ +-----+ +// | | |node,state| |node2,state2| |cell3| ... +// +-+ +----------+ +------------+ +-----+ +// Np | | +// +-+ +// | | +// +-+ oid -> PTentry (as PT[oid % Np] +// | | tid +// +-+ +type PartitionTable struct { + ptTab []... +} + + +// Operational returns whether all object space is covered by at least some ready-to-serve nodes +func (pt *PartitionalTable) Operational() bool { +} -- 2.30.9