Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
3340f3a3
Commit
3340f3a3
authored
Sep 06, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
edc38c9d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
8 deletions
+45
-8
go/neo/client/client.go
go/neo/client/client.go
+8
-3
go/neo/neo.go
go/neo/neo.go
+3
-3
go/neo/parttab.go
go/neo/parttab.go
+21
-0
go/neo/proto-misc.go
go/neo/proto-misc.go
+1
-1
go/neo/zproto-str.go
go/neo/zproto-str.go
+12
-1
No files found.
go/neo/client/client.go
View file @
3340f3a3
...
@@ -228,7 +228,9 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
...
@@ -228,7 +228,9 @@ func (c *Client) talkMaster1(ctx context.Context) (err error) {
}
}
// recvMaster receives and handles notifications from master
// 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()
// XXX .nodeTab.Reset()
for
{
for
{
...
@@ -286,15 +288,18 @@ func (c *Client) recvMaster(ctx context.Context, mlink *neo.NodeLink) error {
...
@@ -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
// ask M for PT
rpt
:=
neo
.
AnswerPartitionTable
{}
rpt
:=
neo
.
AnswerPartitionTable
{}
err
:
=
mlink
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
err
=
mlink
.
Ask1
(
&
neo
.
AskPartitionTable
{},
&
rpt
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
pt
:=
neo
.
PartTabFromDump
(
rpt
.
PTid
,
rpt
.
RowList
)
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
.
StateMu
.
Lock
()
c
.
node
.
PartTab
=
pt
c
.
node
.
PartTab
=
pt
c
.
node
.
StateMu
.
Unlock
()
c
.
node
.
StateMu
.
Unlock
()
...
...
go/neo/neo.go
View file @
3340f3a3
...
@@ -330,7 +330,7 @@ func (l *listener) Addr() net.Addr {
...
@@ -330,7 +330,7 @@ func (l *listener) Addr() net.Addr {
func
(
app
*
NodeApp
)
UpdateNodeTab
(
ctx
context
.
Context
,
msg
*
NotifyNodeInformation
)
{
func
(
app
*
NodeApp
)
UpdateNodeTab
(
ctx
context
.
Context
,
msg
*
NotifyNodeInformation
)
{
// XXX msg.IdTime ?
// XXX msg.IdTime ?
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
for
_
,
nodeInfo
:=
range
msg
.
NodeList
{
log
.
Infof
(
ctx
,
"
rx
node update: %v"
,
nodeInfo
)
log
.
Infof
(
ctx
,
"node update: %v"
,
nodeInfo
)
app
.
NodeTab
.
Update
(
nodeInfo
)
app
.
NodeTab
.
Update
(
nodeInfo
)
// XXX we have to provide IdTime when requesting identification to other peers
// 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
...
@@ -357,13 +357,13 @@ func (app *NodeApp) UpdateNodeTab(ctx context.Context, msg *NotifyNodeInformatio
func
(
app
*
NodeApp
)
UpdatePartTab
(
ctx
context
.
Context
,
msg
*
SendPartitionTable
)
{
func
(
app
*
NodeApp
)
UpdatePartTab
(
ctx
context
.
Context
,
msg
*
SendPartitionTable
)
{
pt
:=
PartTabFromDump
(
msg
.
PTid
,
msg
.
RowList
)
pt
:=
PartTabFromDump
(
msg
.
PTid
,
msg
.
RowList
)
// XXX logging under lock
// XXX logging under lock
log
.
Infof
(
ctx
,
"
rx parttab
: %v"
,
pt
)
log
.
Infof
(
ctx
,
"
parttab update
: %v"
,
pt
)
app
.
PartTab
=
pt
app
.
PartTab
=
pt
}
}
// UpdateClusterState applies update to .ClusterState from message and logs change appropriately.
// UpdateClusterState applies update to .ClusterState from message and logs change appropriately.
func
(
app
*
NodeApp
)
UpdateClusterState
(
ctx
context
.
Context
,
msg
*
NotifyClusterState
)
{
func
(
app
*
NodeApp
)
UpdateClusterState
(
ctx
context
.
Context
,
msg
*
NotifyClusterState
)
{
// XXX loging under lock
// 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
)
app
.
ClusterState
.
Set
(
msg
.
State
)
}
}
go/neo/parttab.go
View file @
3340f3a3
...
@@ -21,6 +21,7 @@ package neo
...
@@ -21,6 +21,7 @@ package neo
// partition table
// partition table
import
(
import
(
"bytes"
"fmt"
"fmt"
"lab.nexedi.com/kirr/neo/go/zodb"
"lab.nexedi.com/kirr/neo/go/zodb"
...
@@ -218,6 +219,26 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
...
@@ -218,6 +219,26 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
// ---- encode / decode PT to / from messages
// ---- encode / decode PT to / from messages
// XXX naming
// 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() ?
// XXX -> RowList() ?
func
(
pt
*
PartitionTable
)
Dump
()
[]
RowInfo
{
// XXX also include .ptid? -> struct ?
func
(
pt
*
PartitionTable
)
Dump
()
[]
RowInfo
{
// XXX also include .ptid? -> struct ?
rowv
:=
make
([]
RowInfo
,
len
(
pt
.
tab
))
rowv
:=
make
([]
RowInfo
,
len
(
pt
.
tab
))
...
...
go/neo/proto-misc.go
View file @
3340f3a3
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// 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
package
neo
// supporting code for types defined in proto.go
// supporting code for types defined in proto.go
...
...
go/neo/zproto-str.go
View file @
3340f3a3
// 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
package
neo
...
@@ -47,3 +47,14 @@ func (i NodeState) String() string {
...
@@ -47,3 +47,14 @@ func (i NodeState) String() string {
}
}
return
_NodeState_name
[
_NodeState_index
[
i
]
:
_NodeState_index
[
i
+
1
]]
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
]]
}
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