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
5c24c361
Commit
5c24c361
authored
Jun 07, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
505cf34b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
52 deletions
+55
-52
go/neo/parttab.go
go/neo/parttab.go
+5
-5
go/neo/proto.go
go/neo/proto.go
+1
-1
go/neo/server/master.go
go/neo/server/master.go
+6
-6
go/neo/server/server.go
go/neo/server/server.go
+0
-37
go/neo/server/storage.go
go/neo/server/storage.go
+1
-1
go/neo/x_connection.go
go/neo/x_connection.go
+42
-2
No files found.
go/neo/parttab.go
View file @
5c24c361
...
...
@@ -29,7 +29,7 @@ package neo
//
// Oid space is divided (partitioned) into Np parts via
//
// p
tid(oid) = oid % Np XXX ptid -> pid ?
// p
id(oid) = oid % Np
//
// rule. The `oid % Np` is known as partition identifier of oid.
//
...
...
@@ -38,7 +38,7 @@ package neo
//
// Given Np, R and []Storage PartitionTable tries to organize
//
// P
t
id -> []Storage
// Pid -> []Storage
//
// mapping so that
//
...
...
@@ -107,9 +107,9 @@ package neo
type
PartitionTable
struct
{
// XXX do we need sync.Mutex here for updates ?
ptTab
[][]
PartitionCell
// [#Np]
PtTab
[][]
PartitionCell
// [#Np] XXX naming
pt
id
PTid
// ↑ for versioning XXX -> ver ?
PT
id
PTid
// ↑ for versioning XXX -> ver ?
}
// PartitionCell describes one storage in a ptid entry in partition table
...
...
@@ -140,7 +140,7 @@ type PartitionCell struct {
//
// XXX or keep not only NodeUUID in PartitionCell - add *Node ?
func
(
pt
*
PartitionTable
)
OperationalWith
(
nt
*
NodeTable
)
bool
{
for
_
,
ptEntry
:=
range
pt
.
p
tTab
{
for
_
,
ptEntry
:=
range
pt
.
P
tTab
{
if
len
(
ptEntry
)
==
0
{
return
false
}
...
...
go/neo/proto.go
View file @
5c24c361
...
...
@@ -208,7 +208,7 @@ type Checksum [20]byte
// Partition Table identifier
// Zero value means "invalid id" (<-> None in py.PPTID)
type
PTid
uint64
// XXX move to common place ?
type
PTid
uint64
// XXX move -> marshalutil.go ?
...
...
go/neo/server/master.go
View file @
5c24c361
...
...
@@ -227,7 +227,7 @@ loop:
// we are interested in latest partTab
// NOTE during recovery no one must be subscribed to
// partTab so it is ok to simply change whole m.partTab
if
r
.
partTab
.
ptid
>
m
.
partTab
.
pt
id
{
if
r
.
partTab
.
PTid
>
m
.
partTab
.
PT
id
{
m
.
partTab
=
r
.
partTab
}
...
...
@@ -324,16 +324,16 @@ func storCtlRecovery(ctx context.Context, link *neo.NodeLink, res chan storRecov
// reconstruct partition table from response
pt
:=
neo
.
PartitionTable
{}
pt
.
pt
id
=
resp
.
PTid
pt
.
PT
id
=
resp
.
PTid
for
_
,
row
:=
range
resp
.
RowList
{
i
:=
row
.
Offset
for
i
>=
uint32
(
len
(
pt
.
p
tTab
))
{
pt
.
ptTab
=
append
(
pt
.
p
tTab
,
[]
neo
.
PartitionCell
{})
for
i
>=
uint32
(
len
(
pt
.
P
tTab
))
{
pt
.
PtTab
=
append
(
pt
.
P
tTab
,
[]
neo
.
PartitionCell
{})
}
//pt.
ptTab[i] = append(pt.p
tTab[i], row.CellList...)
//pt.
PtTab[i] = append(pt.P
tTab[i], row.CellList...)
for
_
,
cell
:=
range
row
.
CellList
{
pt
.
ptTab
[
i
]
=
append
(
pt
.
p
tTab
[
i
],
neo
.
PartitionCell
{
pt
.
PtTab
[
i
]
=
append
(
pt
.
P
tTab
[
i
],
neo
.
PartitionCell
{
NodeUUID
:
cell
.
NodeUUID
,
CellState
:
cell
.
CellState
,
})
...
...
go/neo/server/server.go
View file @
5c24c361
...
...
@@ -136,40 +136,3 @@ func IdentifyPeer(link *neo.NodeLink, myNodeType neo.NodeType) (nodeInfo neo.Req
return
req
,
nil
}
// IdentifyWith identifies local node with remote peer
// it also verifies peer's node type to what caller expects
// XXX place != ok (this is client, not server ?)
func
IdentifyWith
(
expectPeerType
neo
.
NodeType
,
link
*
neo
.
NodeLink
,
myInfo
neo
.
NodeInfo
,
clusterName
string
)
(
accept
*
neo
.
AcceptIdentification
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%s: request identification"
,
link
)
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
err2
:=
conn
.
Close
()
if
err
==
nil
&&
err2
!=
nil
{
err
=
err2
}
}()
accept
=
&
neo
.
AcceptIdentification
{}
err
=
neo
.
Ask
(
conn
,
&
neo
.
RequestIdentification
{
NodeType
:
myInfo
.
NodeType
,
NodeUUID
:
myInfo
.
NodeUUID
,
Address
:
myInfo
.
Address
,
ClusterName
:
clusterName
,
IdTimestamp
:
myInfo
.
IdTimestamp
,
// XXX ok?
},
accept
)
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx ?
}
if
accept
.
NodeType
!=
expectPeerType
{
return
nil
,
fmt
.
Errorf
(
"accepted, but peer is not %v (identifies as %v)"
,
expectPeerType
,
accept
.
NodeType
)
}
return
accept
,
nil
}
go/neo/server/storage.go
View file @
5c24c361
...
...
@@ -138,7 +138,7 @@ func (stor *Storage) talkMaster1(ctx context.Context) error {
// TODO Mlink.Close() on return / cancel
// request identification this way registering our node to master
accept
,
err
:=
IdentifyWith
(
neo
.
MASTER
,
Mlink
,
stor
.
myInfo
,
stor
.
clusterName
)
accept
,
err
:=
neo
.
IdentifyWith
(
neo
.
MASTER
,
Mlink
,
stor
.
myInfo
,
stor
.
clusterName
)
if
err
!=
nil
{
return
err
}
...
...
go/neo/x_connection.go
View file @
5c24c361
...
...
@@ -6,6 +6,8 @@ import (
"reflect"
"../zodb"
"lab.nexedi.com/kirr/go123/xerr"
)
// RecvAndDecode receives packet from conn and decodes it
...
...
@@ -124,8 +126,7 @@ func Expect(conn *Conn, msg Pkt) (err error) {
// ------------------------------------------
// XXX vvv place = ok ?
// XXX place=?
// errEncode translates an error into Error packet
// XXX more text describing relation with zodb errors
...
...
@@ -156,3 +157,42 @@ func ErrDecode(e *Error) error {
return
e
}
// ------------------------------------------
// XXX place=?
// IdentifyWith identifies local node with remote peer
// it also verifies peer's node type to what caller expects
func
IdentifyWith
(
expectPeerType
NodeType
,
link
*
NodeLink
,
myInfo
NodeInfo
,
clusterName
string
)
(
accept
*
AcceptIdentification
,
err
error
)
{
defer
xerr
.
Contextf
(
&
err
,
"%s: request identification"
,
link
)
conn
,
err
:=
link
.
NewConn
()
if
err
!=
nil
{
return
nil
,
err
}
defer
func
()
{
err2
:=
conn
.
Close
()
if
err
==
nil
&&
err2
!=
nil
{
err
=
err2
}
}()
accept
=
&
AcceptIdentification
{}
err
=
Ask
(
conn
,
&
RequestIdentification
{
NodeType
:
myInfo
.
NodeType
,
NodeUUID
:
myInfo
.
NodeUUID
,
Address
:
myInfo
.
Address
,
ClusterName
:
clusterName
,
IdTimestamp
:
myInfo
.
IdTimestamp
,
// XXX ok?
},
accept
)
if
err
!=
nil
{
return
nil
,
err
// XXX err ctx ?
}
if
accept
.
NodeType
!=
expectPeerType
{
return
nil
,
fmt
.
Errorf
(
"accepted, but peer is not %v (identifies as %v)"
,
expectPeerType
,
accept
.
NodeType
)
}
return
accept
,
nil
}
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