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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
neoppod
Commits
ca0ffd62
Commit
ca0ffd62
authored
Aug 16, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a6684c9c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
123 additions
and
95 deletions
+123
-95
go/neo/neo.go
go/neo/neo.go
+5
-5
go/neo/nodetab.go
go/neo/nodetab.go
+8
-8
go/neo/parttab.go
go/neo/parttab.go
+29
-14
go/neo/proto.go
go/neo/proto.go
+5
-5
go/neo/server/cluster_test.go
go/neo/server/cluster_test.go
+6
-7
go/neo/server/master.go
go/neo/server/master.go
+31
-17
go/neo/server/storage.go
go/neo/server/storage.go
+3
-3
go/neo/zproto-marshal.go
go/neo/zproto-marshal.go
+36
-36
No files found.
go/neo/neo.go
View file @
ca0ffd62
...
@@ -87,9 +87,9 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
...
@@ -87,9 +87,9 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
}
}
req
:=
&
RequestIdentification
{
req
:=
&
RequestIdentification
{
NodeType
:
n
.
MyInfo
.
Node
Type
,
NodeType
:
n
.
MyInfo
.
Type
,
NodeUUID
:
n
.
MyInfo
.
Node
UUID
,
NodeUUID
:
n
.
MyInfo
.
UUID
,
Address
:
n
.
MyInfo
.
Addr
ess
,
Address
:
n
.
MyInfo
.
Addr
,
ClusterName
:
n
.
ClusterName
,
ClusterName
:
n
.
ClusterName
,
IdTimestamp
:
n
.
MyInfo
.
IdTimestamp
,
// XXX ok?
IdTimestamp
:
n
.
MyInfo
.
IdTimestamp
,
// XXX ok?
}
}
...
@@ -116,7 +116,7 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
...
@@ -116,7 +116,7 @@ func (n *NodeCommon) Dial(ctx context.Context, peerType NodeType, addr string) (
// The node information about where it listens at is appropriately updated.
// The node information about where it listens at is appropriately updated.
func
(
n
*
NodeCommon
)
Listen
()
(
Listener
,
error
)
{
func
(
n
*
NodeCommon
)
Listen
()
(
Listener
,
error
)
{
// start listening
// start listening
ll
,
err
:=
ListenLink
(
n
.
Net
,
n
.
MyInfo
.
Addr
ess
.
String
())
ll
,
err
:=
ListenLink
(
n
.
Net
,
n
.
MyInfo
.
Addr
.
String
())
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx
return
nil
,
err
// XXX err ctx
}
}
...
@@ -132,7 +132,7 @@ func (n *NodeCommon) Listen() (Listener, error) {
...
@@ -132,7 +132,7 @@ func (n *NodeCommon) Listen() (Listener, error) {
return
nil
,
err
// XXX err ctx
return
nil
,
err
// XXX err ctx
}
}
n
.
MyInfo
.
Addr
ess
=
addr
n
.
MyInfo
.
Addr
=
addr
l
:=
&
listener
{
l
:=
&
listener
{
l
:
ll
,
l
:
ll
,
...
...
go/neo/nodetab.go
View file @
ca0ffd62
...
@@ -45,9 +45,9 @@ import (
...
@@ -45,9 +45,9 @@ import (
//
//
//
//
// XXX [] of
// XXX [] of
// .
node
UUID
// .UUID
// .
node
Type
// .Type
// .
node
State
// .State
// .listenAt ip:port | ø // ø - if client or down(?)
// .listenAt ip:port | ø // ø - if client or down(?)
//
//
// - - - - - - -
// - - - - - - -
...
@@ -103,7 +103,7 @@ type Node struct {
...
@@ -103,7 +103,7 @@ type Node struct {
func
(
nt
*
NodeTable
)
Get
(
uuid
NodeUUID
)
*
Node
{
func
(
nt
*
NodeTable
)
Get
(
uuid
NodeUUID
)
*
Node
{
// FIXME linear scan
// FIXME linear scan
for
_
,
node
:=
range
nt
.
nodev
{
for
_
,
node
:=
range
nt
.
nodev
{
if
node
.
Node
UUID
==
uuid
{
if
node
.
UUID
==
uuid
{
return
node
return
node
}
}
}
}
...
@@ -115,7 +115,7 @@ func (nt *NodeTable) Get(uuid NodeUUID) *Node {
...
@@ -115,7 +115,7 @@ func (nt *NodeTable) Get(uuid NodeUUID) *Node {
// Update updates information about a node
// Update updates information about a node
// it returns corresponding node entry for convenience
// it returns corresponding node entry for convenience
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
NodeInfo
,
conn
*
Conn
/*XXX better link *NodeLink*/
)
*
Node
{
func
(
nt
*
NodeTable
)
Update
(
nodeInfo
NodeInfo
,
conn
*
Conn
/*XXX better link *NodeLink*/
)
*
Node
{
node
:=
nt
.
Get
(
nodeInfo
.
Node
UUID
)
node
:=
nt
.
Get
(
nodeInfo
.
UUID
)
if
node
==
nil
{
if
node
==
nil
{
node
=
&
Node
{}
node
=
&
Node
{}
nt
.
nodev
=
append
(
nt
.
nodev
,
node
)
nt
.
nodev
=
append
(
nt
.
nodev
,
node
)
...
@@ -148,7 +148,7 @@ func (nt *NodeTable) GetByLink(link *NodeLink) *Node {
...
@@ -148,7 +148,7 @@ func (nt *NodeTable) GetByLink(link *NodeLink) *Node {
// XXX doc
// XXX doc
func
(
nt
*
NodeTable
)
SetNodeState
(
node
*
Node
,
state
NodeState
)
{
func
(
nt
*
NodeTable
)
SetNodeState
(
node
*
Node
,
state
NodeState
)
{
node
.
Node
State
=
state
node
.
State
=
state
traceNodeChanged
(
nt
,
node
)
traceNodeChanged
(
nt
,
node
)
nt
.
notify
(
node
.
NodeInfo
)
nt
.
notify
(
node
.
NodeInfo
)
}
}
...
@@ -173,7 +173,7 @@ func (nt *NodeTable) StorageList() []*Node {
...
@@ -173,7 +173,7 @@ func (nt *NodeTable) StorageList() []*Node {
// FIXME linear scan
// FIXME linear scan
sl
:=
[]
*
Node
{}
sl
:=
[]
*
Node
{}
for
_
,
node
:=
range
nt
.
nodev
{
for
_
,
node
:=
range
nt
.
nodev
{
if
node
.
Node
Type
==
STORAGE
{
if
node
.
Type
==
STORAGE
{
sl
=
append
(
sl
,
node
)
sl
=
append
(
sl
,
node
)
}
}
}
}
...
@@ -189,7 +189,7 @@ func (nt *NodeTable) String() string {
...
@@ -189,7 +189,7 @@ func (nt *NodeTable) String() string {
// XXX also for .storv
// XXX also for .storv
for
_
,
n
:=
range
nt
.
nodev
{
for
_
,
n
:=
range
nt
.
nodev
{
// XXX recheck output
// XXX recheck output
fmt
.
Fprintf
(
&
buf
,
"%s (%s)
\t
%s
\t
%s
\n
"
,
n
.
NodeUUID
,
n
.
NodeType
,
n
.
NodeState
,
n
.
Address
)
fmt
.
Fprintf
(
&
buf
,
"%s (%s)
\t
%s
\t
%s
\n
"
,
n
.
UUID
,
n
.
Type
,
n
.
State
,
n
.
Addr
)
}
}
return
buf
.
String
()
return
buf
.
String
()
...
...
go/neo/parttab.go
View file @
ca0ffd62
...
@@ -40,12 +40,12 @@ package neo
...
@@ -40,12 +40,12 @@ package neo
//
//
// Given Np, R and []Storage PartitionTable tries to organize
// Given Np, R and []Storage PartitionTable tries to organize
//
//
//
P
id -> []Storage
//
p
id -> []Storage
//
//
// mapping so that
// mapping so that
//
//
// - redundancy level set by R is met
// - redundancy level set by R is met
// - storages associated with adjacent
Pt
ids are different
// - storages associated with adjacent
p
ids are different
//
//
// when such organization is reached the partition table is called operational
// when such organization is reached the partition table is called operational
// and non-operational otherwise. XXX and if storages are ready
// and non-operational otherwise. XXX and if storages are ready
...
@@ -109,12 +109,12 @@ package neo
...
@@ -109,12 +109,12 @@ package neo
type
PartitionTable
struct
{
type
PartitionTable
struct
{
// XXX do we need sync.Mutex here for updates ?
// XXX do we need sync.Mutex here for updates ?
PtTab
[][]
PartitionCell
// [#Np] XXX naming
tab
[][]
PartitionCell
// [#Np] pid -> []Cell
PTid
PTid
// ↑ for versioning XXX -> ver ?
PTid
PTid
// ↑ for versioning XXX -> ver ?
XXX move out of here?
}
}
// PartitionCell describes one storage in a p
t
id entry in partition table
// PartitionCell describes one storage in a pid entry in partition table
type
PartitionCell
struct
{
type
PartitionCell
struct
{
NodeUUID
NodeUUID
CellState
CellState
...
@@ -131,8 +131,23 @@ type PartitionCell struct {
...
@@ -131,8 +131,23 @@ type PartitionCell struct {
//
//
}
}
// MakePartTab creates new partition with uniformly distributed nodes
// The partition table created will be of len=np
// FIXME R=1 hardcoded
func
MakePartTab
(
np
int
,
nodev
[]
*
Node
)
*
PartitionTable
{
// XXX stub, not tested
tab
:=
make
([][]
PartitionCell
,
np
)
for
i
,
j
:=
0
,
0
;
i
<
np
;
i
,
j
=
i
+
1
,
j
+
1
%
len
(
nodev
)
{
node
:=
nodev
[
j
]
// XXX assert node.State > DOWN
tab
[
i
]
=
[]
PartitionCell
{{
node
.
UUID
,
UP_TO_DATE
/*XXX ok?*/
}}
}
return
&
PartitionTable
{
tab
:
tab
}
}
// OperationalWith
return
s whether all object space is covered by at least some ready-to-serve nodes
// OperationalWith
check
s whether all object space is covered by at least some ready-to-serve nodes
//
//
// for all partitions it checks both:
// for all partitions it checks both:
// - whether there are up-to-date entries in the partition table, and
// - whether there are up-to-date entries in the partition table, and
...
@@ -142,7 +157,7 @@ type PartitionCell struct {
...
@@ -142,7 +157,7 @@ type PartitionCell struct {
//
//
// XXX or keep not only NodeUUID in PartitionCell - add *Node ?
// XXX or keep not only NodeUUID in PartitionCell - add *Node ?
func
(
pt
*
PartitionTable
)
OperationalWith
(
nt
*
NodeTable
)
bool
{
func
(
pt
*
PartitionTable
)
OperationalWith
(
nt
*
NodeTable
)
bool
{
for
_
,
ptEntry
:=
range
pt
.
PtT
ab
{
for
_
,
ptEntry
:=
range
pt
.
t
ab
{
if
len
(
ptEntry
)
==
0
{
if
len
(
ptEntry
)
==
0
{
return
false
return
false
}
}
...
@@ -159,7 +174,7 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
...
@@ -159,7 +174,7 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
//
//
// We leave it as is for now.
// We leave it as is for now.
node
:=
nt
.
Get
(
cell
.
NodeUUID
)
node
:=
nt
.
Get
(
cell
.
NodeUUID
)
if
node
==
nil
||
node
.
Node
State
!=
RUNNING
{
// XXX PENDING is also ok ?
if
node
==
nil
||
node
.
State
!=
RUNNING
{
// XXX PENDING is also ok ?
continue
continue
}
}
...
@@ -181,8 +196,8 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
...
@@ -181,8 +196,8 @@ func (pt *PartitionTable) OperationalWith(nt *NodeTable) bool {
// XXX naming
// XXX naming
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
.
PtT
ab
))
rowv
:=
make
([]
RowInfo
,
len
(
pt
.
t
ab
))
for
i
,
row
:=
range
pt
.
PtT
ab
{
for
i
,
row
:=
range
pt
.
t
ab
{
cellv
:=
make
([]
CellInfo
,
len
(
row
))
cellv
:=
make
([]
CellInfo
,
len
(
row
))
for
j
,
cell
:=
range
cellv
{
for
j
,
cell
:=
range
cellv
{
cellv
[
j
]
=
CellInfo
{
NodeUUID
:
cell
.
NodeUUID
,
CellState
:
cell
.
CellState
}
cellv
[
j
]
=
CellInfo
{
NodeUUID
:
cell
.
NodeUUID
,
CellState
:
cell
.
CellState
}
...
@@ -199,13 +214,13 @@ func PartTabFromDump(ptid PTid, rowv []RowInfo) *PartitionTable {
...
@@ -199,13 +214,13 @@ func PartTabFromDump(ptid PTid, rowv []RowInfo) *PartitionTable {
for
_
,
row
:=
range
rowv
{
for
_
,
row
:=
range
rowv
{
i
:=
row
.
Offset
i
:=
row
.
Offset
for
i
>=
uint32
(
len
(
pt
.
PtT
ab
))
{
for
i
>=
uint32
(
len
(
pt
.
t
ab
))
{
pt
.
PtTab
=
append
(
pt
.
PtT
ab
,
[]
PartitionCell
{})
pt
.
tab
=
append
(
pt
.
t
ab
,
[]
PartitionCell
{})
}
}
//pt.
PtTab[i] = append(pt.PtT
ab[i], row.CellList...)
//pt.
tab[i] = append(pt.t
ab[i], row.CellList...)
for
_
,
cell
:=
range
row
.
CellList
{
for
_
,
cell
:=
range
row
.
CellList
{
pt
.
PtTab
[
i
]
=
append
(
pt
.
PtT
ab
[
i
],
PartitionCell
{
pt
.
tab
[
i
]
=
append
(
pt
.
t
ab
[
i
],
PartitionCell
{
NodeUUID
:
cell
.
NodeUUID
,
NodeUUID
:
cell
.
NodeUUID
,
CellState
:
cell
.
CellState
,
CellState
:
cell
.
CellState
,
})
})
...
...
go/neo/proto.go
View file @
ca0ffd62
...
@@ -232,11 +232,11 @@ func float64_NEODecode(b []byte) float64 {
...
@@ -232,11 +232,11 @@ func float64_NEODecode(b []byte) float64 {
// NodeInfo is information about a node
// NodeInfo is information about a node
// XXX -> nodetab.go ?
// XXX -> nodetab.go ?
type
NodeInfo
struct
{
type
NodeInfo
struct
{
NodeType
Type
NodeType
Address
// serving address
Addr
Addr
ess
// serving address
NodeUUID
UUID
NodeUUID
NodeState
State
NodeState
IdTimestamp
float64
// FIXME clarify semantic where it is used
IdTimestamp
float64
// FIXME clarify semantic where it is used
}
}
// XXX -> parttab.go ?
// XXX -> parttab.go ?
...
...
go/neo/server/cluster_test.go
View file @
ca0ffd62
...
@@ -198,10 +198,10 @@ func TestMasterStorage(t *testing.T) {
...
@@ -198,10 +198,10 @@ func TestMasterStorage(t *testing.T) {
return
&
traceNode
{
return
&
traceNode
{
NodeTab
:
unsafe
.
Pointer
(
nt
),
NodeTab
:
unsafe
.
Pointer
(
nt
),
NodeInfo
:
neo
.
NodeInfo
{
NodeInfo
:
neo
.
NodeInfo
{
Node
Type
:
typ
,
Type
:
typ
,
Addr
ess
:
xnaddr
(
laddr
),
Addr
:
xnaddr
(
laddr
),
Node
UUID
:
neo
.
UUID
(
typ
,
num
),
UUID
:
neo
.
UUID
(
typ
,
num
),
Node
State
:
state
,
State
:
state
,
IdTimestamp
:
idtstamp
,
IdTimestamp
:
idtstamp
,
},
},
}
}
...
@@ -284,16 +284,15 @@ func TestMasterStorage(t *testing.T) {
...
@@ -284,16 +284,15 @@ func TestMasterStorage(t *testing.T) {
// M ready to start: new cluster, no in-progress S recovery
// M ready to start: new cluster, no in-progress S recovery
tc
.
Expect
(
masterStartReady
(
M
,
true
))
tc
.
Expect
(
masterStartReady
(
M
,
true
))
// M <- start cmd
err
:=
M
.
Start
()
err
:=
M
.
Start
()
exc
.
Raiseif
(
err
)
exc
.
Raiseif
(
err
)
// XXX M.partTab <- S1
// XXX M.partTab = ø
// XXX M can start -> writes parttab to S and goes to verification
// XXX M can start -> writes parttab to S and goes to verification
// XXX M.partTab <- ...
// XXX M.partTab <- ...
// XXX updated something cluster currently can be operational
// XXX temp
// XXX temp
return
return
...
...
go/neo/server/master.go
View file @
ca0ffd62
...
@@ -93,7 +93,7 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
...
@@ -93,7 +93,7 @@ func NewMaster(clusterName, serveAddr string, net xnet.Networker) *Master {
m
:=
&
Master
{
m
:=
&
Master
{
node
:
neo
.
NodeCommon
{
node
:
neo
.
NodeCommon
{
MyInfo
:
neo
.
NodeInfo
{
NodeType
:
neo
.
MASTER
,
Address
:
addr
},
MyInfo
:
neo
.
NodeInfo
{
Type
:
neo
.
MASTER
,
Addr
:
addr
},
ClusterName
:
clusterName
,
ClusterName
:
clusterName
,
Net
:
net
,
Net
:
net
,
MasterAddr
:
serveAddr
,
// XXX ok?
MasterAddr
:
serveAddr
,
// XXX ok?
...
@@ -169,10 +169,10 @@ func (m *Master) Run(ctx context.Context) (err error) {
...
@@ -169,10 +169,10 @@ func (m *Master) Run(ctx context.Context) (err error) {
}
}
m
.
node
.
MyInfo
=
neo
.
NodeInfo
{
m
.
node
.
MyInfo
=
neo
.
NodeInfo
{
Node
Type
:
neo
.
MASTER
,
Type
:
neo
.
MASTER
,
Addr
ess
:
naddr
,
Addr
:
naddr
,
Node
UUID
:
m
.
allocUUID
(
neo
.
MASTER
),
UUID
:
m
.
allocUUID
(
neo
.
MASTER
),
Node
State
:
neo
.
RUNNING
,
State
:
neo
.
RUNNING
,
IdTimestamp
:
0
,
// XXX ok?
IdTimestamp
:
0
,
// XXX ok?
}
}
...
@@ -301,7 +301,7 @@ func (m *Master) recovery(ctx context.Context) (err error) {
...
@@ -301,7 +301,7 @@ func (m *Master) recovery(ctx context.Context) (err error) {
// start recovery on all storages we are currently in touch with
// start recovery on all storages we are currently in touch with
// XXX close links to clients
// XXX close links to clients
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
if
stor
.
Node
State
>
neo
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
if
stor
.
State
>
neo
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
inprogress
++
inprogress
++
wg
.
Add
(
1
)
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
...
@@ -377,7 +377,7 @@ loop:
...
@@ -377,7 +377,7 @@ loop:
// recovery and there is no in-progress recovery running
// recovery and there is no in-progress recovery running
nup
:=
0
nup
:=
0
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
if
stor
.
Node
State
>
neo
.
DOWN
{
if
stor
.
State
>
neo
.
DOWN
{
nup
++
nup
++
}
}
}
}
...
@@ -434,6 +434,7 @@ loop:
...
@@ -434,6 +434,7 @@ loop:
close
(
done
)
close
(
done
)
}()
}()
loop2
:
for
{
for
{
select
{
select
{
case
r
:=
<-
recovery
:
case
r
:=
<-
recovery
:
...
@@ -442,14 +443,27 @@ loop:
...
@@ -442,14 +443,27 @@ loop:
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
if
!
xcontext
.
Canceled
(
errors
.
Cause
(
r
.
err
))
{
// XXX not so ok
// XXX not so ok
// FIXME log / close node link; update NT
// log / close node link; update NT
}
}
case
<-
done
:
case
<-
done
:
return
err
break
loop2
}
}
}
}
// if we are starting for new cluster - create partition table
if
err
!=
nil
&&
m
.
partTab
.
PTid
==
0
{
// XXX -> m.nodeTab.StorageList(State > DOWN)
storv
:=
[]
*
neo
.
Node
{}
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
if
stor
.
State
>
neo
.
DOWN
{
storv
=
append
(
storv
,
stor
)
}
}
m
.
partTab
=
neo
.
MakePartTab
(
1
/* XXX hardcoded */
,
storv
)
}
return
err
}
}
// storCtlRecovery drives a storage node during cluster recovering state
// storCtlRecovery drives a storage node during cluster recovering state
...
@@ -537,7 +551,7 @@ func (m *Master) verify(ctx context.Context) (err error) {
...
@@ -537,7 +551,7 @@ func (m *Master) verify(ctx context.Context) (err error) {
// start verification on all storages we are currently in touch with
// start verification on all storages we are currently in touch with
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
for
_
,
stor
:=
range
m
.
nodeTab
.
StorageList
()
{
if
stor
.
Node
State
>
neo
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
if
stor
.
State
>
neo
.
DOWN
{
// XXX state cmp ok ? XXX or stor.Link != nil ?
inprogress
++
inprogress
++
go
storCtlVerify
(
vctx
,
stor
,
verify
)
go
storCtlVerify
(
vctx
,
stor
,
verify
)
}
}
...
@@ -721,7 +735,7 @@ loop:
...
@@ -721,7 +735,7 @@ loop:
// XXX
// XXX
}
}
switch node.
Node
Type {
switch node.Type {
case STORAGE:
case STORAGE:
switch state {
switch state {
case ClusterRecovery:
case ClusterRecovery:
...
@@ -918,7 +932,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -918,7 +932,7 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
accept
:=
&
neo
.
AcceptIdentification
{
accept
:=
&
neo
.
AcceptIdentification
{
NodeType
:
neo
.
MASTER
,
NodeType
:
neo
.
MASTER
,
MyNodeUUID
:
m
.
node
.
MyInfo
.
Node
UUID
,
MyNodeUUID
:
m
.
node
.
MyInfo
.
UUID
,
NumPartitions
:
1
,
// FIXME hardcoded
NumPartitions
:
1
,
// FIXME hardcoded
NumReplicas
:
1
,
// FIXME hardcoded
NumReplicas
:
1
,
// FIXME hardcoded
YourNodeUUID
:
uuid
,
YourNodeUUID
:
uuid
,
...
@@ -936,10 +950,10 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
...
@@ -936,10 +950,10 @@ func (m *Master) identify(ctx context.Context, n nodeCome) (node *neo.Node, resp
}
}
nodeInfo
:=
neo
.
NodeInfo
{
nodeInfo
:=
neo
.
NodeInfo
{
Node
Type
:
nodeType
,
Type
:
nodeType
,
Addr
ess
:
n
.
idReq
.
Address
,
Addr
:
n
.
idReq
.
Address
,
Node
UUID
:
uuid
,
UUID
:
uuid
,
Node
State
:
nodeState
,
State
:
nodeState
,
IdTimestamp
:
m
.
monotime
(),
IdTimestamp
:
m
.
monotime
(),
}
}
...
...
go/neo/server/storage.go
View file @
ca0ffd62
...
@@ -67,7 +67,7 @@ func NewStorage(cluster, masterAddr, serveAddr string, net xnet.Networker, zstor
...
@@ -67,7 +67,7 @@ func NewStorage(cluster, masterAddr, serveAddr string, net xnet.Networker, zstor
stor
:=
&
Storage
{
stor
:=
&
Storage
{
node
:
neo
.
NodeCommon
{
node
:
neo
.
NodeCommon
{
MyInfo
:
neo
.
NodeInfo
{
NodeType
:
neo
.
STORAGE
,
Address
:
addr
},
MyInfo
:
neo
.
NodeInfo
{
Type
:
neo
.
STORAGE
,
Addr
:
addr
},
ClusterName
:
cluster
,
ClusterName
:
cluster
,
Net
:
net
,
Net
:
net
,
MasterAddr
:
masterAddr
,
MasterAddr
:
masterAddr
,
...
@@ -193,9 +193,9 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
...
@@ -193,9 +193,9 @@ func (stor *Storage) talkMaster1(ctx context.Context) (err error) {
}
}
// XXX -> node.Dial ?
// XXX -> node.Dial ?
if
accept
.
YourNodeUUID
!=
stor
.
node
.
MyInfo
.
Node
UUID
{
if
accept
.
YourNodeUUID
!=
stor
.
node
.
MyInfo
.
UUID
{
log
.
Infof
(
ctx
,
"master told us to have uuid=%v"
,
accept
.
YourNodeUUID
)
log
.
Infof
(
ctx
,
"master told us to have uuid=%v"
,
accept
.
YourNodeUUID
)
stor
.
node
.
MyInfo
.
Node
UUID
=
accept
.
YourNodeUUID
stor
.
node
.
MyInfo
.
UUID
=
accept
.
YourNodeUUID
}
}
...
...
go/neo/zproto-marshal.go
View file @
ca0ffd62
...
@@ -64,21 +64,21 @@ func (*NodeInfo) neoMsgCode() uint16 {
...
@@ -64,21 +64,21 @@ func (*NodeInfo) neoMsgCode() uint16 {
}
}
func
(
p
*
NodeInfo
)
neoMsgEncodedLen
()
int
{
func
(
p
*
NodeInfo
)
neoMsgEncodedLen
()
int
{
return
26
+
len
(
p
.
Addr
ess
.
Host
)
return
26
+
len
(
p
.
Addr
.
Host
)
}
}
func
(
p
*
NodeInfo
)
neoMsgEncode
(
data
[]
byte
)
{
func
(
p
*
NodeInfo
)
neoMsgEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
Node
Type
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
(
p
.
Type
)))
{
{
l
:=
uint32
(
len
(
p
.
Addr
ess
.
Host
))
l
:=
uint32
(
len
(
p
.
Addr
.
Host
))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
data
=
data
[
8
:
]
data
=
data
[
8
:
]
copy
(
data
,
p
.
Addr
ess
.
Host
)
copy
(
data
,
p
.
Addr
.
Host
)
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
binary
.
BigEndian
.
PutUint16
(
data
[
0
:
],
p
.
Addr
ess
.
Port
)
binary
.
BigEndian
.
PutUint16
(
data
[
0
:
],
p
.
Addr
.
Port
)
binary
.
BigEndian
.
PutUint32
(
data
[
2
:
],
uint32
(
int32
(
p
.
Node
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
2
:
],
uint32
(
int32
(
p
.
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
6
:
],
uint32
(
int32
(
p
.
Node
State
)))
binary
.
BigEndian
.
PutUint32
(
data
[
6
:
],
uint32
(
int32
(
p
.
State
)))
float64_NEOEncode
(
data
[
10
:
],
p
.
IdTimestamp
)
float64_NEOEncode
(
data
[
10
:
],
p
.
IdTimestamp
)
}
}
...
@@ -87,7 +87,7 @@ func (p *NodeInfo) neoMsgDecode(data []byte) (int, error) {
...
@@ -87,7 +87,7 @@ func (p *NodeInfo) neoMsgDecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
p
.
Node
Type
=
NodeType
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])))
p
.
Type
=
NodeType
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
data
=
data
[
8
:
]
...
@@ -95,12 +95,12 @@ func (p *NodeInfo) neoMsgDecode(data []byte) (int, error) {
...
@@ -95,12 +95,12 @@ func (p *NodeInfo) neoMsgDecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
18
+
l
nread
+=
18
+
l
p
.
Addr
ess
.
Host
=
string
(
data
[
:
l
])
p
.
Addr
.
Host
=
string
(
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
p
.
Addr
ess
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
p
.
Addr
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
p
.
Node
UUID
=
NodeUUID
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
2
:
])))
p
.
UUID
=
NodeUUID
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
2
:
])))
p
.
Node
State
=
NodeState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
6
:
])))
p
.
State
=
NodeState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
6
:
])))
p
.
IdTimestamp
=
float64_NEODecode
(
data
[
10
:
])
p
.
IdTimestamp
=
float64_NEODecode
(
data
[
10
:
])
return
8
+
int
(
nread
),
nil
return
8
+
int
(
nread
),
nil
...
@@ -2546,7 +2546,7 @@ func (p *AnswerNodeList) neoMsgEncodedLen() int {
...
@@ -2546,7 +2546,7 @@ func (p *AnswerNodeList) neoMsgEncodedLen() int {
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
size
+=
len
((
*
a
)
.
Addr
ess
.
Host
)
size
+=
len
((
*
a
)
.
Addr
.
Host
)
}
}
return
4
+
len
(
p
.
NodeList
)
*
26
+
size
return
4
+
len
(
p
.
NodeList
)
*
26
+
size
}
}
...
@@ -2558,17 +2558,17 @@ func (p *AnswerNodeList) neoMsgEncode(data []byte) {
...
@@ -2558,17 +2558,17 @@ func (p *AnswerNodeList) neoMsgEncode(data []byte) {
data
=
data
[
4
:
]
data
=
data
[
4
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
((
*
a
)
.
Node
Type
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
((
*
a
)
.
Type
)))
{
{
l
:=
uint32
(
len
((
*
a
)
.
Addr
ess
.
Host
))
l
:=
uint32
(
len
((
*
a
)
.
Addr
.
Host
))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
data
=
data
[
8
:
]
data
=
data
[
8
:
]
copy
(
data
,
(
*
a
)
.
Addr
ess
.
Host
)
copy
(
data
,
(
*
a
)
.
Addr
.
Host
)
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
binary
.
BigEndian
.
PutUint16
(
data
[
0
:
],
(
*
a
)
.
Addr
ess
.
Port
)
binary
.
BigEndian
.
PutUint16
(
data
[
0
:
],
(
*
a
)
.
Addr
.
Port
)
binary
.
BigEndian
.
PutUint32
(
data
[
2
:
],
uint32
(
int32
((
*
a
)
.
Node
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
2
:
],
uint32
(
int32
((
*
a
)
.
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
6
:
],
uint32
(
int32
((
*
a
)
.
Node
State
)))
binary
.
BigEndian
.
PutUint32
(
data
[
6
:
],
uint32
(
int32
((
*
a
)
.
State
)))
float64_NEOEncode
(
data
[
10
:
],
(
*
a
)
.
IdTimestamp
)
float64_NEOEncode
(
data
[
10
:
],
(
*
a
)
.
IdTimestamp
)
data
=
data
[
18
:
]
data
=
data
[
18
:
]
}
}
...
@@ -2589,7 +2589,7 @@ func (p *AnswerNodeList) neoMsgDecode(data []byte) (int, error) {
...
@@ -2589,7 +2589,7 @@ func (p *AnswerNodeList) neoMsgDecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
(
*
a
)
.
Node
Type
=
NodeType
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])))
(
*
a
)
.
Type
=
NodeType
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
data
=
data
[
8
:
]
...
@@ -2597,12 +2597,12 @@ func (p *AnswerNodeList) neoMsgDecode(data []byte) (int, error) {
...
@@ -2597,12 +2597,12 @@ func (p *AnswerNodeList) neoMsgDecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
18
+
l
nread
+=
18
+
l
(
*
a
)
.
Addr
ess
.
Host
=
string
(
data
[
:
l
])
(
*
a
)
.
Addr
.
Host
=
string
(
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
(
*
a
)
.
Addr
ess
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
(
*
a
)
.
Addr
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
(
*
a
)
.
Node
UUID
=
NodeUUID
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
2
:
])))
(
*
a
)
.
UUID
=
NodeUUID
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
2
:
])))
(
*
a
)
.
Node
State
=
NodeState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
6
:
])))
(
*
a
)
.
State
=
NodeState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
6
:
])))
(
*
a
)
.
IdTimestamp
=
float64_NEODecode
(
data
[
10
:
])
(
*
a
)
.
IdTimestamp
=
float64_NEODecode
(
data
[
10
:
])
data
=
data
[
18
:
]
data
=
data
[
18
:
]
}
}
...
@@ -2747,7 +2747,7 @@ func (p *NotifyNodeInformation) neoMsgEncodedLen() int {
...
@@ -2747,7 +2747,7 @@ func (p *NotifyNodeInformation) neoMsgEncodedLen() int {
var
size
int
var
size
int
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
for
i
:=
0
;
i
<
len
(
p
.
NodeList
);
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
size
+=
len
((
*
a
)
.
Addr
ess
.
Host
)
size
+=
len
((
*
a
)
.
Addr
.
Host
)
}
}
return
12
+
len
(
p
.
NodeList
)
*
26
+
size
return
12
+
len
(
p
.
NodeList
)
*
26
+
size
}
}
...
@@ -2760,17 +2760,17 @@ func (p *NotifyNodeInformation) neoMsgEncode(data []byte) {
...
@@ -2760,17 +2760,17 @@ func (p *NotifyNodeInformation) neoMsgEncode(data []byte) {
data
=
data
[
12
:
]
data
=
data
[
12
:
]
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
for
i
:=
0
;
uint32
(
i
)
<
l
;
i
++
{
a
:=
&
p
.
NodeList
[
i
]
a
:=
&
p
.
NodeList
[
i
]
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
((
*
a
)
.
Node
Type
)))
binary
.
BigEndian
.
PutUint32
(
data
[
0
:
],
uint32
(
int32
((
*
a
)
.
Type
)))
{
{
l
:=
uint32
(
len
((
*
a
)
.
Addr
ess
.
Host
))
l
:=
uint32
(
len
((
*
a
)
.
Addr
.
Host
))
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
binary
.
BigEndian
.
PutUint32
(
data
[
4
:
],
l
)
data
=
data
[
8
:
]
data
=
data
[
8
:
]
copy
(
data
,
(
*
a
)
.
Addr
ess
.
Host
)
copy
(
data
,
(
*
a
)
.
Addr
.
Host
)
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
binary
.
BigEndian
.
PutUint16
(
data
[
0
:
],
(
*
a
)
.
Addr
ess
.
Port
)
binary
.
BigEndian
.
PutUint16
(
data
[
0
:
],
(
*
a
)
.
Addr
.
Port
)
binary
.
BigEndian
.
PutUint32
(
data
[
2
:
],
uint32
(
int32
((
*
a
)
.
Node
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
2
:
],
uint32
(
int32
((
*
a
)
.
UUID
)))
binary
.
BigEndian
.
PutUint32
(
data
[
6
:
],
uint32
(
int32
((
*
a
)
.
Node
State
)))
binary
.
BigEndian
.
PutUint32
(
data
[
6
:
],
uint32
(
int32
((
*
a
)
.
State
)))
float64_NEOEncode
(
data
[
10
:
],
(
*
a
)
.
IdTimestamp
)
float64_NEOEncode
(
data
[
10
:
],
(
*
a
)
.
IdTimestamp
)
data
=
data
[
18
:
]
data
=
data
[
18
:
]
}
}
...
@@ -2792,7 +2792,7 @@ func (p *NotifyNodeInformation) neoMsgDecode(data []byte) (int, error) {
...
@@ -2792,7 +2792,7 @@ func (p *NotifyNodeInformation) neoMsgDecode(data []byte) (int, error) {
if
uint32
(
len
(
data
))
<
8
{
if
uint32
(
len
(
data
))
<
8
{
goto
overflow
goto
overflow
}
}
(
*
a
)
.
Node
Type
=
NodeType
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])))
(
*
a
)
.
Type
=
NodeType
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
0
:
])))
{
{
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
l
:=
binary
.
BigEndian
.
Uint32
(
data
[
4
:
])
data
=
data
[
8
:
]
data
=
data
[
8
:
]
...
@@ -2800,12 +2800,12 @@ func (p *NotifyNodeInformation) neoMsgDecode(data []byte) (int, error) {
...
@@ -2800,12 +2800,12 @@ func (p *NotifyNodeInformation) neoMsgDecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
nread
+=
18
+
l
nread
+=
18
+
l
(
*
a
)
.
Addr
ess
.
Host
=
string
(
data
[
:
l
])
(
*
a
)
.
Addr
.
Host
=
string
(
data
[
:
l
])
data
=
data
[
l
:
]
data
=
data
[
l
:
]
}
}
(
*
a
)
.
Addr
ess
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
(
*
a
)
.
Addr
.
Port
=
binary
.
BigEndian
.
Uint16
(
data
[
0
:
])
(
*
a
)
.
Node
UUID
=
NodeUUID
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
2
:
])))
(
*
a
)
.
UUID
=
NodeUUID
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
2
:
])))
(
*
a
)
.
Node
State
=
NodeState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
6
:
])))
(
*
a
)
.
State
=
NodeState
(
int32
(
binary
.
BigEndian
.
Uint32
(
data
[
6
:
])))
(
*
a
)
.
IdTimestamp
=
float64_NEODecode
(
data
[
10
:
])
(
*
a
)
.
IdTimestamp
=
float64_NEODecode
(
data
[
10
:
])
data
=
data
[
18
:
]
data
=
data
[
18
:
]
}
}
...
...
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