Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
b254a74d
Commit
b254a74d
authored
Feb 24, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e0e31499
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
15 deletions
+105
-15
go/neo/xneo/nodetab.go
go/neo/xneo/nodetab.go
+19
-3
go/neo/xneo/parttab.go
go/neo/xneo/parttab.go
+25
-10
go/neo/xneo/statelog.go
go/neo/xneo/statelog.go
+57
-0
go/neo/xneo/xneo.go
go/neo/xneo/xneo.go
+4
-2
No files found.
go/neo/xneo/nodetab.go
View file @
b254a74d
...
...
@@ -106,17 +106,33 @@ type PeerNode struct {
dialing
*
dialed
}
// Len returns N(entries) in the table.
// RONodeTable provides read-only access to NodeTable.
type
RONodeTable
interface
{
// Len returns N(entries) in the table.
Len
()
int
// All returns all entries in the table as one slice.
All
()
[]
*
PeerNode
// Get finds node by node ID.
Get
(
nid
proto
.
NodeID
)
*
PeerNode
// XXX ? StorageList
// XXX ? String
}
// Len implements RONodeTable.
func
(
nt
*
NodeTable
)
Len
()
int
{
return
len
(
nt
.
nodev
)
}
// All
returns all entries in the table as one slic
e.
// All
implements RONodeTabl
e.
func
(
nt
*
NodeTable
)
All
()
[]
*
PeerNode
{
return
nt
.
nodev
}
// Get
finds node by node ID
.
// Get
implements RONodeTable
.
func
(
nt
*
NodeTable
)
Get
(
nid
proto
.
NodeID
)
*
PeerNode
{
// FIXME linear scan
for
_
,
node
:=
range
nt
.
nodev
{
...
...
go/neo/xneo/parttab.go
View file @
b254a74d
...
...
@@ -137,10 +137,31 @@ type Cell struct {
}
// R returns n(replica) for partition table.
// ROPartitionTable provides read-only access to PartitionTable.
type
ROPartitionTable
interface
{
// R returns n(replica) for partition table.
R
()
int
// Get returns cells oid is associated with.
Get
(
oid
zodb
.
Oid
)
[]
Cell
// OperationalWith checks whether all object space is covered by at least some ready-to-serve nodes.
//
// for all partitions it checks both:
// - whether there are up-to-date entries in the partition table, and
// - whether there are corresponding storage nodes that are up
//
// information about nodes being up or down is obtained from supplied NodeTable
OperationalWith
(
nt
RONodeTable
)
bool
// XXX String ?
// XXX ToMsg ?
}
// R implements ROPartitionTable.
func
(
pt
*
PartitionTable
)
R
()
int
{
return
pt
.
r_
+
1
}
// Get
returns cells oid is associated with
.
// Get
implements ROPartitionTable
.
func
(
pt
*
PartitionTable
)
Get
(
oid
zodb
.
Oid
)
[]
Cell
{
if
len
(
pt
.
tab
)
==
0
{
return
nil
...
...
@@ -178,14 +199,8 @@ func MakePartTab(np int, nreplica int, nodev []*PeerNode) *PartitionTable {
}
// OperationalWith checks whether all object space is covered by at least some ready-to-serve nodes.
//
// for all partitions it checks both:
// - whether there are up-to-date entries in the partition table, and
// - whether there are corresponding storage nodes that are up
//
// information about nodes being up or down is obtained from supplied NodeTable
func
(
pt
*
PartitionTable
)
OperationalWith
(
nt
*
NodeTable
)
bool
{
// OperationalWith implements ROPartitionTable.
func
(
pt
*
PartitionTable
)
OperationalWith
(
nt
RONodeTable
)
bool
{
// empty partition table is never operational
if
len
(
pt
.
tab
)
==
0
{
return
false
...
...
go/neo/xneo/statelog.go
0 → 100644
View file @
b254a74d
// Copyright (C) 2016-2021 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 Free Software licenses or 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.
// See https://www.nexedi.com/licensing for rationale and options.
package
xneo
// transactional log of states
// XXX ...
type
State
struct
{
NodeTab
*
NodeTable
// nodes in the cluster
PartTab
*
PartitionTable
// on which nodes which data is located
ClusterState
proto
.
ClusterState
// code for cluster state
}
type
StateSnapshot
interface
{
NodeTab
()
RONodeTable
PartTab
()
ROPartitionTable
ClusterState
()
proto
.
ClusterState
}
// XXX transactional journal ...
type
StateLog
struct
{
mu
sync
.
Mutex
head
*
State
}
// ReadHead returns state from head of the log.
func
(
l
*
StateLog
)
ReadHead
()
StateSnapshot
{
l
.
mu
.
Lock
()
defer
l
.
mu
.
Unlock
()
return
l
.
head
}
// CommitUpdate creates new entry in the log with state updated by δf's changes.
func
(
l
*
StateLog
)
CommitUpdate
(
δf
func
(
*
State
))
{
l
.
mu
.
Lock
()
defer
l
.
mu
.
Unlock
()
s
:=
l
.
head
.
Clone
()
δf
(
s
)
l
.
head
=
s
}
go/neo/xneo/xneo.go
View file @
b254a74d
...
...
@@ -151,10 +151,11 @@ func NewNode(typ proto.NodeType, clusterName string, net xnet.Networker, masterA
}
// XXX -> use statelog instead
/*
// XXX doc, naming
// XXX WithStateHead ? WithStateSnapshot ? -> ReadState ?
func
(
node
*
Node
)
WithState
(
f
func
(
*
/*readonly*/
State
))
{
func (node *Node) WithState(f func(*
readonly
State)) {
node.stateLogMu.Lock()
s := node.state
node.stateLogMu.Unlock()
...
...
@@ -169,3 +170,4 @@ func (node *Node) ModifyState(δf func(*State)) {
δf(s)
node.state = s
}
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment