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
71c356e4
Commit
71c356e4
authored
Jan 17, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
c298adbd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
140 additions
and
105 deletions
+140
-105
t/neo/proto.go
t/neo/proto.go
+101
-101
t/neo/proto_test.go
t/neo/proto_test.go
+39
-4
No files found.
t/neo/proto.go
View file @
71c356e4
...
@@ -60,7 +60,7 @@ const (
...
@@ -60,7 +60,7 @@ const (
type
NodeState
int32
type
NodeState
int32
const
(
const
(
RUNNING
NodeState
=
iota
//short: R // XXX tag prefix name ?
RUNNING
NodeState
=
iota
//short: R // XXX tag prefix name ?
TEMPORARILY_DOWN
//short: T
TEMPORARILY_DOWN
//short: T
DOWN
//short: D
DOWN
//short: D
BROKEN
//short: B
BROKEN
//short: B
HIDDEN
//short: H
HIDDEN
//short: H
...
@@ -283,35 +283,35 @@ type PartitionTable struct {
...
@@ -283,35 +283,35 @@ type PartitionTable struct {
}
}
type
AnswerPartitionTable
struct
{
type
AnswerPartitionTable
struct
{
PTid
PTid
RowList
[]
RowInfo
RowList
[]
RowInfo
}
}
// Send rows in a partition table to update other nodes. PM -> S, C.
// Send rows in a partition table to update other nodes. PM -> S, C.
type
NotifyPartitionTable
struct
{
type
NotifyPartitionTable
struct
{
PTid
PTid
RowList
[]
RowInfo
RowList
[]
RowInfo
}
}
// Notify a subset of a partition table. This is used to notify changes.
// Notify a subset of a partition table. This is used to notify changes.
// PM -> S, C.
// PM -> S, C.
type
PartitionChanges
struct
{
type
PartitionChanges
struct
{
PTid
PTid
CellList
[]
struct
{
CellList
[]
struct
{
// XXX does below correlate with Cell inside top-level CellList ?
// XXX does below correlate with Cell inside top-level CellList ?
Offset
uint32
// PNumber
Offset
uint32
// PNumber
UUID
UUID
UUID
UUID
CellState
CellState
CellState
CellState
}
}
}
}
// Tell a storage nodes to start an operation. Until a storage node receives
// Tell a storage nodes to start an operation. Until a storage node receives
// this message, it must not serve client nodes. PM -> S.
// this message, it must not serve client nodes. PM -> S.
type
StartOperation
struct
{
type
StartOperation
struct
{
// XXX: Is this boolean needed ? Maybe this
// XXX: Is this boolean needed ? Maybe this
// can be deduced from cluster state.
// can be deduced from cluster state.
Backup
bool
Backup
bool
}
}
// Tell a storage node to stop an operation. Once a storage node receives
// Tell a storage node to stop an operation. Once a storage node receives
...
@@ -346,13 +346,13 @@ type FinalTID struct {
...
@@ -346,13 +346,13 @@ type FinalTID struct {
}
}
type
AnswerFinalTID
struct
{
type
AnswerFinalTID
struct
{
Tid
Tid
Tid
Tid
}
}
// Commit a transaction. PM -> S.
// Commit a transaction. PM -> S.
type
ValidateTransaction
struct
{
type
ValidateTransaction
struct
{
TTID
Tid
TTID
Tid
Tid
Tid
Tid
Tid
}
}
...
@@ -369,45 +369,45 @@ type AnswerBeginTransaction struct {
...
@@ -369,45 +369,45 @@ type AnswerBeginTransaction struct {
// Finish a transaction. C -> PM.
// Finish a transaction. C -> PM.
// Answer when a transaction is finished. PM -> C.
// Answer when a transaction is finished. PM -> C.
type
FinishTransaction
struct
{
type
FinishTransaction
struct
{
Tid
Tid
Tid
Tid
OIDList
[]
Oid
OIDList
[]
Oid
CheckedList
[]
Oid
CheckedList
[]
Oid
}
}
type
AnswerFinishTransaction
struct
{
type
AnswerFinishTransaction
struct
{
TTID
Tid
TTID
Tid
Tid
Tid
Tid
Tid
}
}
// Notify that a transaction blocking a replication is now finished
// Notify that a transaction blocking a replication is now finished
// M -> S
// M -> S
type
NotifyTransactionFinished
struct
{
type
NotifyTransactionFinished
struct
{
TTID
Tid
TTID
Tid
MaxTID
Tid
MaxTID
Tid
}
}
// Lock information on a transaction. PM -> S.
// Lock information on a transaction. PM -> S.
// Notify information on a transaction locked. S -> PM.
// Notify information on a transaction locked. S -> PM.
type
LockInformation
struct
{
type
LockInformation
struct
{
Ttid
Tid
Ttid
Tid
Tid
Tid
Tid
Tid
}
}
// XXX AnswerInformationLocked ?
// XXX AnswerInformationLocked ?
type
AnswerLockInformation
struct
{
type
AnswerLockInformation
struct
{
Ttid
Tid
Ttid
Tid
}
}
// Invalidate objects. PM -> C.
// Invalidate objects. PM -> C.
// XXX ask_finish_transaction ?
// XXX ask_finish_transaction ?
type
InvalidateObjects
struct
{
type
InvalidateObjects
struct
{
Tid
Tid
Tid
Tid
OidList
[]
Oid
OidList
[]
Oid
}
}
// Unlock information on a transaction. PM -> S.
// Unlock information on a transaction. PM -> S.
type
UnlockInformation
struct
{
type
UnlockInformation
struct
{
TTID
Tid
TTID
Tid
}
}
// Ask new object IDs. C -> PM.
// Ask new object IDs. C -> PM.
...
@@ -418,7 +418,7 @@ type GenerateOIDs struct {
...
@@ -418,7 +418,7 @@ type GenerateOIDs struct {
// XXX answer_new_oids ?
// XXX answer_new_oids ?
type
AnswerGenerateOIDs
struct
{
type
AnswerGenerateOIDs
struct
{
OidList
[]
Oid
OidList
[]
Oid
}
}
...
@@ -429,14 +429,14 @@ type AnswerGenerateOIDs struct {
...
@@ -429,14 +429,14 @@ type AnswerGenerateOIDs struct {
// if this serial is newer than the current transaction ID, a client
// if this serial is newer than the current transaction ID, a client
// node must not try to resolve the conflict. S -> C.
// node must not try to resolve the conflict. S -> C.
type
StoreObject
struct
{
type
StoreObject
struct
{
Oid
Oid
Oid
Oid
Serial
Tid
Serial
Tid
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// XXX or string ?
Data
[]
byte
// XXX or string ?
DataSerial
Tid
DataSerial
Tid
Tid
Tid
Tid
Tid
Unlock
bool
Unlock
bool
}
}
type
AnswerStoreObject
struct
{
type
AnswerStoreObject
struct
{
...
@@ -453,18 +453,18 @@ type AbortTransaction struct {
...
@@ -453,18 +453,18 @@ type AbortTransaction struct {
// Ask to store a transaction. C -> S.
// Ask to store a transaction. C -> S.
// Answer if transaction has been stored. S -> C.
// Answer if transaction has been stored. S -> C.
type
StoreTransaction
struct
{
type
StoreTransaction
struct
{
Tid
Tid
Tid
Tid
User
string
User
string
Description
string
Description
string
Extension
string
Extension
string
OidList
[]
Oid
OidList
[]
Oid
// TODO _answer = PFEmpty
// TODO _answer = PFEmpty
}
}
// Ask to store a transaction. C -> S.
// Ask to store a transaction. C -> S.
// Answer if transaction has been stored. S -> C.
// Answer if transaction has been stored. S -> C.
type
VoteTransaction
struct
{
type
VoteTransaction
struct
{
Tid
Tid
Tid
Tid
// TODO _answer = PFEmpty
// TODO _answer = PFEmpty
}
}
...
@@ -480,13 +480,13 @@ type GetObject struct {
...
@@ -480,13 +480,13 @@ type GetObject struct {
// XXX answer_object ?
// XXX answer_object ?
type
AnswerGetObject
struct
{
type
AnswerGetObject
struct
{
Oid
Oid
Oid
Oid
SerialStart
Tid
SerialStart
Tid
SerialEnd
Tid
SerialEnd
Tid
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// XXX or string ?
Data
[]
byte
// XXX or string ?
DataSerial
Tid
DataSerial
Tid
}
}
// Ask for TIDs between a range of offsets. The order of TIDs is descending,
// Ask for TIDs between a range of offsets. The order of TIDs is descending,
...
@@ -500,7 +500,7 @@ type TIDList struct {
...
@@ -500,7 +500,7 @@ type TIDList struct {
// XXX answer_tids ?
// XXX answer_tids ?
type
AnswerTIDList
struct
{
type
AnswerTIDList
struct
{
TIDList
[]
Tid
TIDList
[]
Tid
}
}
// Ask for length TIDs starting at min_tid. The order of TIDs is ascending.
// Ask for length TIDs starting at min_tid. The order of TIDs is ascending.
...
@@ -525,12 +525,12 @@ type TransactionInformation struct {
...
@@ -525,12 +525,12 @@ type TransactionInformation struct {
}
}
type
AnswerTransactionInformation
struct
{
type
AnswerTransactionInformation
struct
{
Tid
Tid
Tid
Tid
User
string
User
string
Description
string
Description
string
Extension
string
Extension
string
Packed
bool
Packed
bool
OidList
[]
Oid
OidList
[]
Oid
}
}
// Ask history information for a given object. The order of serials is
// Ask history information for a given object. The order of serials is
...
@@ -544,7 +544,7 @@ type ObjectHistory struct {
...
@@ -544,7 +544,7 @@ type ObjectHistory struct {
type
AnswerObjectHistory
struct
{
type
AnswerObjectHistory
struct
{
Oid
Oid
Oid
Oid
HistoryList
[]
struct
{
HistoryList
[]
struct
{
Serial
Tid
Serial
Tid
Size
uint32
// PNumber
Size
uint32
// PNumber
}
}
...
@@ -561,44 +561,44 @@ type PartitionList struct {
...
@@ -561,44 +561,44 @@ type PartitionList struct {
type
AnswerPartitionList
struct
{
type
AnswerPartitionList
struct
{
PTid
PTid
RowList
[]
RowInfo
RowList
[]
RowInfo
}
}
// Ask information about nodes
// Ask information about nodes
// Answer information about nodes
// Answer information about nodes
type
X_NodeList
struct
{
type
X_NodeList
struct
{
NodeType
NodeType
}
}
type
AnswerNodeList
struct
{
type
AnswerNodeList
struct
{
NodeList
[]
NodeInfo
NodeList
[]
NodeInfo
}
}
// Set the node state
// Set the node state
type
SetNodeState
struct
{
type
SetNodeState
struct
{
UUID
UUID
NodeState
NodeState
// XXX _answer = Error ?
// XXX _answer = Error ?
}
}
// Ask the primary to include some pending node in the partition table
// Ask the primary to include some pending node in the partition table
type
AddPendingNodes
struct
{
type
AddPendingNodes
struct
{
UUIDList
[]
UUID
UUIDList
[]
UUID
// XXX _answer = Error
// XXX _answer = Error
}
}
// Ask the primary to optimize the partition table. A -> PM.
// Ask the primary to optimize the partition table. A -> PM.
type
TweakPartitionTable
struct
{
type
TweakPartitionTable
struct
{
UUIDList
[]
UUID
UUIDList
[]
UUID
// XXX _answer = Error
// XXX _answer = Error
}
}
// Notify information about one or more nodes. PM -> Any.
// Notify information about one or more nodes. PM -> Any.
type
NotifyNodeInformation
struct
{
type
NotifyNodeInformation
struct
{
NodeList
[]
NodeInfo
NodeList
[]
NodeInfo
}
}
// Ask node information
// Ask node information
...
@@ -621,7 +621,7 @@ type ClusterInformation struct {
...
@@ -621,7 +621,7 @@ type ClusterInformation struct {
// Ask state of the cluster
// Ask state of the cluster
// Answer state of the cluster
// Answer state of the cluster
type
X_ClusterState
struct
{
// XXX conflicts with ClusterState enum
type
X_ClusterState
struct
{
// XXX conflicts with ClusterState enum
State
ClusterState
State
ClusterState
}
}
...
@@ -640,18 +640,18 @@ type X_ClusterState struct { // XXX conflicts with ClusterState enum
...
@@ -640,18 +640,18 @@ type X_ClusterState struct { // XXX conflicts with ClusterState enum
// If current_serial's data is current on storage.
// If current_serial's data is current on storage.
// S -> C
// S -> C
type
ObjectUndoSerial
struct
{
type
ObjectUndoSerial
struct
{
Tid
Tid
Tid
Tid
LTID
Tid
LTID
Tid
UndoneTID
Tid
UndoneTID
Tid
OidList
[]
Oid
OidList
[]
Oid
}
}
// XXX answer_undo_transaction ?
// XXX answer_undo_transaction ?
type
AnswerObjectUndoSerial
struct
{
type
AnswerObjectUndoSerial
struct
{
ObjectTIDDict
map
[
Oid
]
struct
{
ObjectTIDDict
map
[
Oid
]
struct
{
CurrentSerial
Tid
CurrentSerial
Tid
UndoSerial
Tid
UndoSerial
Tid
IsCurrent
bool
IsCurrent
bool
}
}
}
}
...
@@ -659,13 +659,13 @@ type AnswerObjectUndoSerial struct {
...
@@ -659,13 +659,13 @@ type AnswerObjectUndoSerial struct {
// C -> S
// C -> S
// Answer whether a transaction holds the write lock for requested object.
// Answer whether a transaction holds the write lock for requested object.
type
HasLock
struct
{
type
HasLock
struct
{
Tid
Tid
Tid
Tid
Oid
Oid
Oid
Oid
}
}
type
AnswerHasLock
struct
{
type
AnswerHasLock
struct
{
Oid
Oid
Oid
Oid
LockState
LockState
LockState
LockState
}
}
...
@@ -683,9 +683,9 @@ type CheckCurrentSerial struct {
...
@@ -683,9 +683,9 @@ type CheckCurrentSerial struct {
// XXX answer_store_object ?
// XXX answer_store_object ?
type
AnswerCheckCurrentSerial
struct
{
type
AnswerCheckCurrentSerial
struct
{
Conflicting
bool
Conflicting
bool
Oid
Oid
Oid
Oid
Serial
Tid
Serial
Tid
}
}
// Request a pack at given TID.
// Request a pack at given TID.
...
@@ -695,7 +695,7 @@ type AnswerCheckCurrentSerial struct {
...
@@ -695,7 +695,7 @@ type AnswerCheckCurrentSerial struct {
// S -> M
// S -> M
// M -> C
// M -> C
type
Pack
struct
{
type
Pack
struct
{
Tid
Tid
Tid
Tid
}
}
type
AnswerPack
struct
{
type
AnswerPack
struct
{
...
@@ -734,16 +734,16 @@ type CheckPartition struct {
...
@@ -734,16 +734,16 @@ type CheckPartition struct {
// reference node.
// reference node.
// S -> S
// S -> S
type
CheckTIDRange
struct
{
type
CheckTIDRange
struct
{
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Length
uint32
// PNumber
Length
uint32
// PNumber
MinTID
Tid
MinTID
Tid
MaxTID
Tid
MaxTID
Tid
}
}
type
AnswerCheckTIDRange
struct
{
type
AnswerCheckTIDRange
struct
{
Count
uint32
// PNumber
Count
uint32
// PNumber
Checksum
Checksum
Checksum
Checksum
MaxTID
Tid
MaxTID
Tid
}
}
// Ask some stats about a range of object history.
// Ask some stats about a range of object history.
...
@@ -755,25 +755,25 @@ type AnswerCheckTIDRange struct {
...
@@ -755,25 +755,25 @@ type AnswerCheckTIDRange struct {
// reference node.
// reference node.
// S -> S
// S -> S
type
CheckSerialRange
struct
{
type
CheckSerialRange
struct
{
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Length
uint32
// PNumber
Length
uint32
// PNumber
MinTID
Tid
MinTID
Tid
MaxTID
Tid
MaxTID
Tid
MinOID
Oid
MinOID
Oid
}
}
type
AnswerCheckSerialRange
struct
{
type
AnswerCheckSerialRange
struct
{
Count
uint32
// PNumber
Count
uint32
// PNumber
TidChecksum
Checksum
TidChecksum
Checksum
MaxTID
Tid
MaxTID
Tid
OidChecksum
Checksum
OidChecksum
Checksum
MaxOID
Oid
MaxOID
Oid
}
}
// S -> M
// S -> M
type
PartitionCorrupted
struct
{
type
PartitionCorrupted
struct
{
Partition
uint32
// PNumber
Partition
uint32
// PNumber
CellList
[]
UUID
CellList
[]
UUID
}
}
...
...
t/neo/proto_test.go
View file @
71c356e4
...
@@ -16,6 +16,7 @@ package neo
...
@@ -16,6 +16,7 @@ package neo
import
(
import
(
hexpkg
"encoding/hex"
hexpkg
"encoding/hex"
"encoding/binary"
"reflect"
"reflect"
"testing"
"testing"
"unsafe"
"unsafe"
...
@@ -30,6 +31,20 @@ func hex(s string) string {
...
@@ -30,6 +31,20 @@ func hex(s string) string {
return
string
(
b
)
return
string
(
b
)
}
}
// uint32 -> string as encoded on the wire
func
u32
(
v
uint32
)
string
{
var
b
[
4
]
byte
binary
.
BigEndian
.
PutUint32
(
b
[
:
],
v
)
return
string
(
b
[
:
])
}
// uint64 -> string as encoded on the wire
func
u64
(
v
uint64
)
string
{
var
b
[
8
]
byte
binary
.
BigEndian
.
PutUint64
(
b
[
:
],
v
)
return
string
(
b
[
:
])
}
func
TestPktHeader
(
t
*
testing
.
T
)
{
func
TestPktHeader
(
t
*
testing
.
T
)
{
// make sure PktHeader is really packed
// make sure PktHeader is really packed
if
unsafe
.
Sizeof
(
PktHead
{})
!=
10
{
if
unsafe
.
Sizeof
(
PktHead
{})
!=
10
{
...
@@ -86,7 +101,7 @@ func TestPktMarshal(t *testing.T) {
...
@@ -86,7 +101,7 @@ func TestPktMarshal(t *testing.T) {
// empty
// empty
{
&
Ping
{},
""
},
{
&
Ping
{},
""
},
// uint32, string
XXX string -> Notify?
// uint32, string
{
&
Error
{
Code
:
0x01020304
,
Message
:
"hello"
},
"
\x01\x02\x03\x04\x00\x00\x00\x05
hello"
},
{
&
Error
{
Code
:
0x01020304
,
Message
:
"hello"
},
"
\x01\x02\x03\x04\x00\x00\x00\x05
hello"
},
// Oid, Tid, bool, Checksum, []byte
// Oid, Tid, bool, Checksum, []byte
...
@@ -106,7 +121,7 @@ func TestPktMarshal(t *testing.T) {
...
@@ -106,7 +121,7 @@ func TestPktMarshal(t *testing.T) {
hex
(
"0000000b"
)
+
"hello world"
+
hex
(
"0000000b"
)
+
"hello world"
+
hex
(
"0a0b0c0d0e0f01030a0b0c0d0e0f010401"
)},
hex
(
"0a0b0c0d0e0f01030a0b0c0d0e0f010401"
)},
// PTid, [] (of [] of
...
)
// PTid, [] (of [] of
{UUID, CellState}
)
{
&
AnswerPartitionTable
{
{
&
AnswerPartitionTable
{
PTid
:
0x0102030405060708
,
PTid
:
0x0102030405060708
,
RowList
:
[]
RowInfo
{
RowList
:
[]
RowInfo
{
...
@@ -123,14 +138,34 @@ func TestPktMarshal(t *testing.T) {
...
@@ -123,14 +138,34 @@ func TestPktMarshal(t *testing.T) {
hex
(
"00000007000000030000000b000000040000000f000000030000001700000000"
),
hex
(
"00000007000000030000000b000000040000000f000000030000001700000000"
),
},
},
// map[Oid]struct {Tid,Tid,bool}
{
&
AnswerObjectUndoSerial
{
ObjectTIDDict
:
map
[
Oid
]
struct
{
CurrentSerial
Tid
UndoSerial
Tid
IsCurrent
bool
}
{
1
:
{
1
,
0
,
false
},
2
:
{
7
,
1
,
true
},
8
:
{
7
,
1
,
false
},
5
:
{
4
,
3
,
true
},
}},
u32
(
4
)
+
u64
(
1
)
+
u64
(
1
)
+
u64
(
0
)
+
hex
(
"00"
)
+
u64
(
2
)
+
u64
(
7
)
+
u64
(
1
)
+
hex
(
"01"
)
+
u64
(
8
)
+
u64
(
7
)
+
u64
(
1
)
+
hex
(
"00"
)
+
u64
(
5
)
+
u64
(
4
)
+
u64
(
3
)
+
hex
(
"01"
),
},
/*
/*
// uint32, Address, string, float64
// uint32, Address, string, float64
{&RequestIdentification{...}}, // TODO
{&RequestIdentification{...}}, // TODO
*/
*/
// TODO float64 (+ nan !nan ...)
// TODO float64 (+ nan !nan ...)
// TODO
[](!byte), map
// TODO
map <- AnswerLockedTransactions, AnswerObjectUndoSerial, CheckReplicas
// TODO Address,
PTid
// TODO Address,
}
}
for
_
,
tt
:=
range
testv
{
for
_
,
tt
:=
range
testv
{
...
...
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