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
63875e79
Commit
63875e79
authored
Nov 28, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
69a02de9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
99 deletions
+115
-99
t/neo/pkt.go
t/neo/pkt.go
+86
-83
t/neo/pktgen.go
t/neo/pktgen.go
+0
-0
t/neo/storage.go
t/neo/storage.go
+29
-16
No files found.
t/neo/p
roto/p
kt.go
→
t/neo/pkt.go
View file @
63875e79
package
proto
package
neo
//package proto
/*
import (
import (
. "../"
. "../"
)
)
*/
const
(
const
(
PROTOCOL_VERSION
=
8
PROTOCOL_VERSION
=
8
MIN_PACKET_SIZE
=
10
// XXX link this to len(pkthead) ?
MIN_PACKET_SIZE
=
10
// XXX link this to len(pkthead) ?
PktHeadLen
=
MIN_PACKET_SIZE
// TODO link this to PktHead.Encode/Decode size
MAX_PACKET_SIZE
=
0x4000000
MAX_PACKET_SIZE
=
0x4000000
RESPONSE_MASK
=
0x800
RESPONSE_MASK
=
0x800
...
@@ -122,8 +126,7 @@ type RowList []struct {
...
@@ -122,8 +126,7 @@ type RowList []struct {
// XXX link request <-> answer ?
// XXX link request <-> answer ?
// TODO ensure len(encoded packet header) == 10
// TODO ensure len(encoded packet header) == 10
// XXX -> PktHeader ?
type
PktHead
struct
{
type
Packet
struct
{
Id
uint32
Id
uint32
Code
uint16
// XXX we don't need this as field - this is already encoded in type
Code
uint16
// XXX we don't need this as field - this is already encoded in type
Len
uint32
// XXX we don't need this as field - only on the wire
Len
uint32
// XXX we don't need this as field - only on the wire
...
@@ -133,7 +136,7 @@ type Packet struct {
...
@@ -133,7 +136,7 @@ type Packet struct {
// General purpose notification (remote logging)
// General purpose notification (remote logging)
type
Notify
struct
{
type
Notify
struct
{
P
acket
P
ktHead
Message
string
Message
string
}
}
...
@@ -141,26 +144,26 @@ type Notify struct {
...
@@ -141,26 +144,26 @@ type Notify struct {
// any other message, even if such a message does not expect a reply
// any other message, even if such a message does not expect a reply
// usually. Any -> Any.
// usually. Any -> Any.
type
Error
struct
{
type
Error
struct
{
P
acket
P
ktHead
Code
uint32
// PNumber
Code
uint32
// PNumber
Message
string
Message
string
}
}
// Check if a peer is still alive. Any -> Any.
// Check if a peer is still alive. Any -> Any.
type
Ping
struct
{
type
Ping
struct
{
P
acket
P
ktHead
// TODO _answer = PFEmpty
// TODO _answer = PFEmpty
}
}
// Tell peer it can close the connection if it has finished with us. Any -> Any
// Tell peer it can close the connection if it has finished with us. Any -> Any
type
CloseClient
struct
{
type
CloseClient
struct
{
P
acket
P
ktHead
}
}
// Request a node identification. This must be the first packet for any
// Request a node identification. This must be the first packet for any
// connection. Any -> Any.
// connection. Any -> Any.
type
RequestIdentification
struct
{
type
RequestIdentification
struct
{
P
acket
P
ktHead
ProtocolVersion
uint32
// TODO py.PProtocol upon decoding checks for != PROTOCOL_VERSION
ProtocolVersion
uint32
// TODO py.PProtocol upon decoding checks for != PROTOCOL_VERSION
NodeType
NodeType
// XXX name
NodeType
NodeType
// XXX name
UUID
UUID
UUID
UUID
...
@@ -171,7 +174,7 @@ type RequestIdentification struct {
...
@@ -171,7 +174,7 @@ type RequestIdentification struct {
// XXX -> ReplyIdentification? RequestIdentification.Answer somehow ?
// XXX -> ReplyIdentification? RequestIdentification.Answer somehow ?
type
AcceptIdentification
struct
{
type
AcceptIdentification
struct
{
P
acket
P
ktHead
NodeType
NodeType
// XXX name
NodeType
NodeType
// XXX name
MyUUID
UUID
MyUUID
UUID
NumPartitions
uint32
// PNumber
NumPartitions
uint32
// PNumber
...
@@ -186,31 +189,31 @@ type AcceptIdentification struct {
...
@@ -186,31 +189,31 @@ type AcceptIdentification struct {
// Ask current primary master's uuid. CTL -> A.
// Ask current primary master's uuid. CTL -> A.
type
PrimaryMaster
struct
{
type
PrimaryMaster
struct
{
P
acket
P
ktHead
}
}
type
AnswerPrimary
struct
{
type
AnswerPrimary
struct
{
P
acket
P
ktHead
PrimaryUUID
UUID
PrimaryUUID
UUID
}
}
// Announce a primary master node election. PM -> SM.
// Announce a primary master node election. PM -> SM.
type
AnnouncePrimary
struct
{
type
AnnouncePrimary
struct
{
P
acket
P
ktHead
}
}
// Force a re-election of a primary master node. M -> M.
// Force a re-election of a primary master node. M -> M.
type
ReelectPrimary
struct
{
type
ReelectPrimary
struct
{
P
acket
P
ktHead
}
}
// Ask all data needed by master to recover. PM -> S, S -> PM.
// Ask all data needed by master to recover. PM -> S, S -> PM.
type
Recovery
struct
{
type
Recovery
struct
{
P
acket
P
ktHead
}
}
type
AnswerRecovery
struct
{
type
AnswerRecovery
struct
{
P
acket
P
ktHead
PTid
PTid
BackupTID
Tid
BackupTID
Tid
TruncateTID
Tid
TruncateTID
Tid
...
@@ -219,11 +222,11 @@ type AnswerRecovery struct {
...
@@ -219,11 +222,11 @@ type AnswerRecovery struct {
// Ask the last OID/TID so that a master can initialize its TransactionManager.
// Ask the last OID/TID so that a master can initialize its TransactionManager.
// PM -> S, S -> PM.
// PM -> S, S -> PM.
type
LastIDs
struct
{
type
LastIDs
struct
{
P
acket
P
ktHead
}
}
type
AnswerLastIDs
struct
{
type
AnswerLastIDs
struct
{
P
acket
P
ktHead
LastOID
Oid
LastOID
Oid
LastTID
Tid
LastTID
Tid
}
}
...
@@ -231,11 +234,11 @@ type AnswerLastIDs struct {
...
@@ -231,11 +234,11 @@ type AnswerLastIDs struct {
// Ask the full partition table. PM -> S.
// Ask the full partition table. PM -> S.
// Answer rows in a partition table. S -> PM.
// Answer rows in a partition table. S -> PM.
type
PartitionTable
struct
{
type
PartitionTable
struct
{
P
acket
P
ktHead
}
}
type
AnswerPartitionTable
struct
{
type
AnswerPartitionTable
struct
{
P
acket
P
ktHead
PTid
PTid
RowList
RowList
RowList
RowList
}
}
...
@@ -243,7 +246,7 @@ type AnswerPartitionTable struct {
...
@@ -243,7 +246,7 @@ type AnswerPartitionTable struct {
// 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
{
P
acket
P
ktHead
PTid
PTid
RowList
RowList
RowList
RowList
}
}
...
@@ -251,7 +254,7 @@ type NotifyPartitionTable struct {
...
@@ -251,7 +254,7 @@ type NotifyPartitionTable struct {
// 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
{
P
acket
P
ktHead
PTid
PTid
CellList
[]
struct
{
CellList
[]
struct
{
...
@@ -265,7 +268,7 @@ type PartitionChanges struct {
...
@@ -265,7 +268,7 @@ type PartitionChanges struct {
// 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
{
P
acket
P
ktHead
// 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
...
@@ -274,17 +277,17 @@ type StartOperation struct {
...
@@ -274,17 +277,17 @@ type StartOperation struct {
// 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
// this message, it must not serve client nodes. PM -> S.
// this message, it must not serve client nodes. PM -> S.
type
StopOperation
struct
{
type
StopOperation
struct
{
P
acket
P
ktHead
}
}
// Ask unfinished transactions S -> PM.
// Ask unfinished transactions S -> PM.
// Answer unfinished transactions PM -> S.
// Answer unfinished transactions PM -> S.
type
UnfinishedTransactions
struct
{
type
UnfinishedTransactions
struct
{
P
acket
P
ktHead
}
}
type
AnswerUnfinishedTransactions
struct
{
type
AnswerUnfinishedTransactions
struct
{
P
acket
P
ktHead
MaxTID
Tid
MaxTID
Tid
TidList
[]
struct
{
TidList
[]
struct
{
UnfinishedTID
Tid
UnfinishedTID
Tid
...
@@ -294,28 +297,28 @@ type AnswerUnfinishedTransactions struct {
...
@@ -294,28 +297,28 @@ type AnswerUnfinishedTransactions struct {
// Ask locked transactions PM -> S.
// Ask locked transactions PM -> S.
// Answer locked transactions S -> PM.
// Answer locked transactions S -> PM.
type
LockedTransactions
struct
{
type
LockedTransactions
struct
{
P
acket
P
ktHead
}
}
type
AnswerLockedTransactions
struct
{
type
AnswerLockedTransactions
struct
{
P
acket
P
ktHead
TidDict
map
[
Tid
]
Tid
// ttid -> tid
TidDict
map
[
Tid
]
Tid
// ttid -> tid
}
}
// Return final tid if ttid has been committed. * -> S. C -> PM.
// Return final tid if ttid has been committed. * -> S. C -> PM.
type
FinalTID
struct
{
type
FinalTID
struct
{
P
acket
P
ktHead
TTID
Tid
TTID
Tid
}
}
type
AnswerFinalTID
struct
{
type
AnswerFinalTID
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
// Commit a transaction. PM -> S.
// Commit a transaction. PM -> S.
type
ValidateTransaction
struct
{
type
ValidateTransaction
struct
{
P
acket
P
ktHead
TTID
Tid
TTID
Tid
Tid
Tid
Tid
Tid
}
}
...
@@ -324,26 +327,26 @@ type ValidateTransaction struct {
...
@@ -324,26 +327,26 @@ type ValidateTransaction struct {
// Ask to begin a new transaction. C -> PM.
// Ask to begin a new transaction. C -> PM.
// Answer when a transaction begin, give a TID if necessary. PM -> C.
// Answer when a transaction begin, give a TID if necessary. PM -> C.
type
BeginTransaction
struct
{
type
BeginTransaction
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
type
AnswerBeginTransaction
struct
{
type
AnswerBeginTransaction
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
// 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
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
OIDList
[]
Oid
OIDList
[]
Oid
CheckedList
[]
Oid
CheckedList
[]
Oid
}
}
type
AnswerFinishTransaction
struct
{
type
AnswerFinishTransaction
struct
{
P
acket
P
ktHead
TTID
Tid
TTID
Tid
Tid
Tid
Tid
Tid
}
}
...
@@ -351,7 +354,7 @@ type AnswerFinishTransaction struct {
...
@@ -351,7 +354,7 @@ type AnswerFinishTransaction struct {
// 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
{
P
acket
P
ktHead
TTID
Tid
TTID
Tid
MaxTID
Tid
MaxTID
Tid
}
}
...
@@ -359,7 +362,7 @@ type NotifyTransactionFinished struct {
...
@@ -359,7 +362,7 @@ type NotifyTransactionFinished struct {
// 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
{
P
acket
P
ktHead
Ttid
Tid
Ttid
Tid
Tid
Tid
Tid
Tid
}
}
...
@@ -372,27 +375,27 @@ type AnswerLockInformation struct {
...
@@ -372,27 +375,27 @@ type AnswerLockInformation struct {
// Invalidate objects. PM -> C.
// Invalidate objects. PM -> C.
// XXX ask_finish_transaction ?
// XXX ask_finish_transaction ?
type
InvalidateObjects
struct
{
type
InvalidateObjects
struct
{
P
acket
P
ktHead
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
{
P
acket
P
ktHead
TTID
Tid
TTID
Tid
}
}
// Ask new object IDs. C -> PM.
// Ask new object IDs. C -> PM.
// Answer new object IDs. PM -> C.
// Answer new object IDs. PM -> C.
type
GenerateOIDs
struct
{
type
GenerateOIDs
struct
{
P
acket
P
ktHead
NumOIDs
uint32
// PNumber
NumOIDs
uint32
// PNumber
}
}
// XXX answer_new_oids ?
// XXX answer_new_oids ?
type
AnswerGenerateOIDs
struct
{
type
AnswerGenerateOIDs
struct
{
P
acket
P
ktHead
OidList
[]
Oid
OidList
[]
Oid
}
}
...
@@ -404,7 +407,7 @@ type AnswerGenerateOIDs struct {
...
@@ -404,7 +407,7 @@ 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
{
P
acket
P
ktHead
Oid
Oid
Oid
Oid
Serial
Tid
Serial
Tid
Compression
bool
Compression
bool
...
@@ -416,7 +419,7 @@ type StoreObject struct {
...
@@ -416,7 +419,7 @@ type StoreObject struct {
}
}
type
AnswerStoreObject
struct
{
type
AnswerStoreObject
struct
{
P
acket
P
ktHead
Conflicting
bool
Conflicting
bool
Oid
Oid
Oid
Oid
Serial
Tid
Serial
Tid
...
@@ -424,14 +427,14 @@ type AnswerStoreObject struct {
...
@@ -424,14 +427,14 @@ type AnswerStoreObject struct {
// Abort a transaction. C -> S, PM.
// Abort a transaction. C -> S, PM.
type
AbortTransaction
struct
{
type
AbortTransaction
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
// 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
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
User
string
User
string
Description
string
Description
string
...
@@ -443,7 +446,7 @@ type StoreTransaction struct {
...
@@ -443,7 +446,7 @@ type StoreTransaction 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
VoteTransaction
struct
{
type
VoteTransaction
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
// TODO _answer = PFEmpty
// TODO _answer = PFEmpty
}
}
...
@@ -453,7 +456,7 @@ type VoteTransaction struct {
...
@@ -453,7 +456,7 @@ type VoteTransaction struct {
// a TID is specified, an object right before the TID will be returned. C -> S.
// a TID is specified, an object right before the TID will be returned. C -> S.
// Answer the requested object. S -> C.
// Answer the requested object. S -> C.
type
GetObject
struct
{
type
GetObject
struct
{
P
acket
P
ktHead
Oid
Oid
Oid
Oid
Serial
Tid
Serial
Tid
Tid
Tid
Tid
Tid
...
@@ -461,7 +464,7 @@ type GetObject struct {
...
@@ -461,7 +464,7 @@ type GetObject struct {
// XXX answer_object ?
// XXX answer_object ?
type
AnswerGetObject
struct
{
type
AnswerGetObject
struct
{
P
acket
P
ktHead
Oid
Oid
Oid
Oid
SerialStart
Tid
SerialStart
Tid
SerialEnd
Tid
SerialEnd
Tid
...
@@ -475,7 +478,7 @@ type AnswerGetObject struct {
...
@@ -475,7 +478,7 @@ type AnswerGetObject struct {
// and the range is [first, last). C -> S.
// and the range is [first, last). C -> S.
// Answer the requested TIDs. S -> C.
// Answer the requested TIDs. S -> C.
type
TIDList
struct
{
type
TIDList
struct
{
P
acket
P
ktHead
First
uint64
// PIndex XXX this is TID actually ? -> no it is offset in list
First
uint64
// PIndex XXX this is TID actually ? -> no it is offset in list
Last
uint64
// PIndex ----//----
Last
uint64
// PIndex ----//----
Partition
uint32
// PNumber
Partition
uint32
// PNumber
...
@@ -483,7 +486,7 @@ type TIDList struct {
...
@@ -483,7 +486,7 @@ type TIDList struct {
// XXX answer_tids ?
// XXX answer_tids ?
type
AnswerTIDList
struct
{
type
AnswerTIDList
struct
{
P
acket
P
ktHead
TIDList
[]
Tid
TIDList
[]
Tid
}
}
...
@@ -491,7 +494,7 @@ type AnswerTIDList struct {
...
@@ -491,7 +494,7 @@ type AnswerTIDList struct {
// C -> S.
// C -> S.
// Answer the requested TIDs. S -> C
// Answer the requested TIDs. S -> C
type
TIDListFrom
struct
{
type
TIDListFrom
struct
{
P
acket
P
ktHead
MinTID
Tid
MinTID
Tid
MaxTID
Tid
MaxTID
Tid
Length
uint32
// PNumber
Length
uint32
// PNumber
...
@@ -500,19 +503,19 @@ type TIDListFrom struct {
...
@@ -500,19 +503,19 @@ type TIDListFrom struct {
// XXX answer_tids ?
// XXX answer_tids ?
type
AnswerTIDListFrom
struct
{
type
AnswerTIDListFrom
struct
{
P
acket
P
ktHead
TidList
[]
Tid
TidList
[]
Tid
}
}
// Ask information about a transaction. Any -> S.
// Ask information about a transaction. Any -> S.
// Answer information (user, description) about a transaction. S -> Any.
// Answer information (user, description) about a transaction. S -> Any.
type
TransactionInformation
struct
{
type
TransactionInformation
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
type
AnswerTransactionInformation
struct
{
type
AnswerTransactionInformation
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
User
string
User
string
Description
string
Description
string
...
@@ -525,14 +528,14 @@ type AnswerTransactionInformation struct {
...
@@ -525,14 +528,14 @@ type AnswerTransactionInformation struct {
// descending, and the range is [first, last]. C -> S.
// descending, and the range is [first, last]. C -> S.
// Answer history information (serial, size) for an object. S -> C.
// Answer history information (serial, size) for an object. S -> C.
type
ObjectHistory
struct
{
type
ObjectHistory
struct
{
P
acket
P
ktHead
Oid
Oid
Oid
Oid
First
uint64
// PIndex XXX this is actually TID
First
uint64
// PIndex XXX this is actually TID
Last
uint64
// PIndex ----//----
Last
uint64
// PIndex ----//----
}
}
type
AnswerObjectHistory
struct
{
type
AnswerObjectHistory
struct
{
P
acket
P
ktHead
Oid
Oid
Oid
Oid
HistoryList
[]
struct
{
HistoryList
[]
struct
{
Serial
Tid
Serial
Tid
...
@@ -544,14 +547,14 @@ type AnswerObjectHistory struct {
...
@@ -544,14 +547,14 @@ type AnswerObjectHistory struct {
// Ask information about partition
// Ask information about partition
// Answer information about partition
// Answer information about partition
type
PartitionList
struct
{
type
PartitionList
struct
{
P
acket
P
ktHead
MinOffset
uint32
// PNumber
MinOffset
uint32
// PNumber
MaxOffset
uint32
// PNumber
MaxOffset
uint32
// PNumber
UUID
UUID
UUID
UUID
}
}
type
AnswerPartitionList
struct
{
type
AnswerPartitionList
struct
{
P
acket
P
ktHead
PTid
PTid
RowList
RowList
RowList
RowList
}
}
...
@@ -559,18 +562,18 @@ type AnswerPartitionList struct {
...
@@ -559,18 +562,18 @@ type AnswerPartitionList struct {
// Ask information about nodes
// Ask information about nodes
// Answer information about nodes
// Answer information about nodes
type
X_NodeList
struct
{
type
X_NodeList
struct
{
P
acket
P
ktHead
NodeType
NodeType
}
}
type
AnswerNodeList
struct
{
type
AnswerNodeList
struct
{
P
acket
P
ktHead
NodeList
[]
NodeInfo
NodeList
[]
NodeInfo
}
}
// Set the node state
// Set the node state
type
SetNodeState
struct
{
type
SetNodeState
struct
{
P
acket
P
ktHead
UUID
UUID
NodeState
NodeState
...
@@ -579,7 +582,7 @@ type SetNodeState struct {
...
@@ -579,7 +582,7 @@ type SetNodeState struct {
// 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
{
P
acket
P
ktHead
UUIDList
[]
UUID
UUIDList
[]
UUID
// XXX _answer = Error
// XXX _answer = Error
...
@@ -587,7 +590,7 @@ type AddPendingNodes struct {
...
@@ -587,7 +590,7 @@ type AddPendingNodes struct {
// 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
{
P
acket
P
ktHead
UUIDList
[]
UUID
UUIDList
[]
UUID
// XXX _answer = Error
// XXX _answer = Error
...
@@ -595,19 +598,19 @@ type TweakPartitionTable struct {
...
@@ -595,19 +598,19 @@ type TweakPartitionTable struct {
// Notify information about one or more nodes. PM -> Any.
// Notify information about one or more nodes. PM -> Any.
type
NotifyNodeInformation
struct
{
type
NotifyNodeInformation
struct
{
P
acket
P
ktHead
NodeList
[]
NodeInfo
NodeList
[]
NodeInfo
}
}
// Ask node information
// Ask node information
type
NodeInformation
struct
{
type
NodeInformation
struct
{
P
acket
P
ktHead
// XXX _answer = PFEmpty
// XXX _answer = PFEmpty
}
}
// Set the cluster state
// Set the cluster state
type
SetClusterState
struct
{
type
SetClusterState
struct
{
P
acket
P
ktHead
State
ClusterState
State
ClusterState
// XXX _answer = Error
// XXX _answer = Error
...
@@ -615,14 +618,14 @@ type SetClusterState struct {
...
@@ -615,14 +618,14 @@ type SetClusterState struct {
// Notify information about the cluster
// Notify information about the cluster
type
ClusterInformation
struct
{
type
ClusterInformation
struct
{
P
acket
P
ktHead
State
ClusterState
State
ClusterState
}
}
// 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
P
acket
P
ktHead
State
ClusterState
State
ClusterState
}
}
...
@@ -642,7 +645,7 @@ type X_ClusterState struct { // XXX conflicts with ClusterState enum
...
@@ -642,7 +645,7 @@ 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
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
LTID
Tid
LTID
Tid
UndoneTID
Tid
UndoneTID
Tid
...
@@ -651,7 +654,7 @@ type ObjectUndoSerial struct {
...
@@ -651,7 +654,7 @@ type ObjectUndoSerial struct {
// XXX answer_undo_transaction ?
// XXX answer_undo_transaction ?
type
AnswerObjectUndoSerial
struct
{
type
AnswerObjectUndoSerial
struct
{
P
acket
P
ktHead
ObjectTIDDict
map
[
Oid
]
struct
{
ObjectTIDDict
map
[
Oid
]
struct
{
CurrentSerial
Tid
CurrentSerial
Tid
UndoSerial
Tid
UndoSerial
Tid
...
@@ -663,13 +666,13 @@ type AnswerObjectUndoSerial struct {
...
@@ -663,13 +666,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
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
Oid
Oid
Oid
Oid
}
}
type
AnswerHasLock
struct
{
type
AnswerHasLock
struct
{
P
acket
P
ktHead
Oid
Oid
Oid
Oid
LockState
LockState
LockState
LockState
}
}
...
@@ -682,7 +685,7 @@ type AnswerHasLock struct {
...
@@ -682,7 +685,7 @@ type AnswerHasLock struct {
// Same structure as AnswerStoreObject, to handle the same way, except there
// Same structure as AnswerStoreObject, to handle the same way, except there
// is nothing to invalidate in any client's cache.
// is nothing to invalidate in any client's cache.
type
CheckCurrentSerial
struct
{
type
CheckCurrentSerial
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
Serial
Tid
Serial
Tid
Oid
Oid
Oid
Oid
...
@@ -702,12 +705,12 @@ type AnswerCheckCurrentSerial struct {
...
@@ -702,12 +705,12 @@ type AnswerCheckCurrentSerial struct {
// S -> M
// S -> M
// M -> C
// M -> C
type
Pack
struct
{
type
Pack
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
type
AnswerPack
struct
{
type
AnswerPack
struct
{
P
acket
P
ktHead
Status
bool
Status
bool
}
}
...
@@ -715,7 +718,7 @@ type AnswerPack struct {
...
@@ -715,7 +718,7 @@ type AnswerPack struct {
// ctl -> A
// ctl -> A
// A -> M
// A -> M
type
CheckReplicas
struct
{
type
CheckReplicas
struct
{
P
acket
P
ktHead
PartitionDict
map
[
uint32
/*PNumber*/
]
UUID
// partition -> source
PartitionDict
map
[
uint32
/*PNumber*/
]
UUID
// partition -> source
MinTID
Tid
MinTID
Tid
MaxTID
Tid
MaxTID
Tid
...
@@ -725,7 +728,7 @@ type CheckReplicas struct {
...
@@ -725,7 +728,7 @@ type CheckReplicas struct {
// M -> S
// M -> S
type
CheckPartition
struct
{
type
CheckPartition
struct
{
P
acket
P
ktHead
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Source
struct
{
Source
struct
{
UpstreamName
string
UpstreamName
string
...
@@ -745,7 +748,7 @@ type CheckPartition struct {
...
@@ -745,7 +748,7 @@ type CheckPartition struct {
// reference node.
// reference node.
// S -> S
// S -> S
type
CheckTIDRange
struct
{
type
CheckTIDRange
struct
{
P
acket
P
ktHead
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Length
uint32
// PNumber
Length
uint32
// PNumber
MinTID
Tid
MinTID
Tid
...
@@ -753,7 +756,7 @@ type CheckTIDRange struct {
...
@@ -753,7 +756,7 @@ type CheckTIDRange struct {
}
}
type
AnswerCheckTIDRange
struct
{
type
AnswerCheckTIDRange
struct
{
P
acket
P
ktHead
Count
uint32
// PNumber
Count
uint32
// PNumber
Checksum
Checksum
Checksum
Checksum
MaxTID
Tid
MaxTID
Tid
...
@@ -768,7 +771,7 @@ type AnswerCheckTIDRange struct {
...
@@ -768,7 +771,7 @@ type AnswerCheckTIDRange struct {
// reference node.
// reference node.
// S -> S
// S -> S
type
CheckSerialRange
struct
{
type
CheckSerialRange
struct
{
P
acket
P
ktHead
Partition
uint32
// PNumber
Partition
uint32
// PNumber
Length
uint32
// PNumber
Length
uint32
// PNumber
MinTID
Tid
MinTID
Tid
...
@@ -786,7 +789,7 @@ type AnswerCheckSerialRange struct {
...
@@ -786,7 +789,7 @@ type AnswerCheckSerialRange struct {
// S -> M
// S -> M
type
PartitionCorrupted
struct
{
type
PartitionCorrupted
struct
{
P
acket
P
ktHead
Partition
uint32
// PNumber
Partition
uint32
// PNumber
CellList
[]
UUID
CellList
[]
UUID
}
}
...
@@ -797,11 +800,11 @@ type PartitionCorrupted struct {
...
@@ -797,11 +800,11 @@ type PartitionCorrupted struct {
// Answer last committed TID.
// Answer last committed TID.
// M -> C
// M -> C
type
LastTransaction
struct
{
type
LastTransaction
struct
{
P
acket
P
ktHead
}
}
type
AnswerLastTransaction
struct
{
type
AnswerLastTransaction
struct
{
P
acket
P
ktHead
Tid
Tid
Tid
Tid
}
}
...
@@ -809,7 +812,7 @@ type AnswerLastTransaction struct {
...
@@ -809,7 +812,7 @@ type AnswerLastTransaction struct {
// Notify that node is ready to serve requests.
// Notify that node is ready to serve requests.
// S -> M
// S -> M
type
NotifyReady
struct
{
type
NotifyReady
struct
{
P
acket
P
ktHead
}
}
// replication
// replication
...
...
t/neo/p
roto/p
ktgen.go
→
t/neo/pktgen.go
View file @
63875e79
File moved
t/neo/storage.go
View file @
63875e79
...
@@ -4,8 +4,12 @@ package neo
...
@@ -4,8 +4,12 @@ package neo
import
(
import
(
"context"
"context"
"encoding/binary"
"net"
"net"
"fmt"
"fmt"
"io"
//"../neo/proto"
)
)
// NEO Storage application
// NEO Storage application
...
@@ -14,46 +18,56 @@ import (
...
@@ -14,46 +18,56 @@ import (
type
StorageApplication
struct
{
type
StorageApplication
struct
{
}
}
/*
// XXX change to bytes.Buffer if we need to access it as I/O
type Buffer struct {
buf []byte
}
*/
func
(
stor
*
StorageApplication
)
ServeConn
(
ctx
context
.
Context
,
conn
net
.
Conn
)
{
func
(
stor
*
StorageApplication
)
ServeConn
(
ctx
context
.
Context
,
conn
net
.
Conn
)
{
fmt
.
Printf
(
"stor: serving new client %s <-> %s
\n
"
,
conn
.
LocalAddr
(),
conn
.
RemoteAddr
())
fmt
.
Printf
(
"stor: serving new client %s <-> %s
\n
"
,
conn
.
LocalAddr
(),
conn
.
RemoteAddr
())
//fmt.Fprintf(conn, "Hello up there, you address is %s\n", conn.RemoteAddr()) // XXX err
//fmt.Fprintf(conn, "Hello up there, you address is %s\n", conn.RemoteAddr()) // XXX err
//conn.Close() // XXX err
//conn.Close() // XXX err
/*
// TODO: use bytes.Buffer{}
// TODO: use bytes.Buffer{}
// .Bytes() -> buf -> can grow up again up to buf[:cap(buf)]
// .Bytes() -> buf -> can grow up again up to buf[:cap(buf)]
// NewBuffer(buf) -> can use same buffer for later reading via bytes.Buffer
// NewBuffer(buf) -> can use same buffer for later reading via bytes.Buffer
// TODO read PktHeader (fixed length) (-> length, PktType (by .code))
// TODO read PktHeader (fixed length) (-> length, PktType (by .code))
// TODO PktHeader
//rxbuf := bytes.Buffer{}
//rxbuf := bytes.Buffer{}
rxbuf := bytes.NewBuffer(make([]byte, 4096))
rxbuf := bytes.NewBuffer(make([]byte, 4096))
n, err := conn.Read(rxbuf.Bytes())
n, err := conn.Read(rxbuf.Bytes())
*/
// first read to read pkt header and hopefully up to page of data in 1 syscall
// first read to read pkt header and hopefully up to page of data in 1 syscall
rxbuf
:=
Buffer
{
make
([]
byte
,
4096
}
rxbuf
:=
make
([]
byte
,
4096
)
n
,
err
:=
io
.
ReadAtLeast
(
conn
,
rxbuf
,
PktHeadLen
)
n
,
err
:=
io
.
ReadAtLeast
(
conn
,
rxbuf
,
PktHeadLen
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
)
//
TODO
panic
(
err
)
//
XXX err
}
}
id
:=
binary
.
BigEndian
.
Uint32
(
rxbuf
[
0
:
])
code
:=
binary
.
BigEndian
.
Uint16
(
rxbuf
[
4
:
])
_
/*id*/
=
binary
.
BigEndian
.
Uint32
(
rxbuf
[
0
:
])
// XXX -> PktHeader.Decode() ?
_
/*code*/
=
binary
.
BigEndian
.
Uint16
(
rxbuf
[
4
:
])
length
:=
binary
.
BigEndian
.
Uint32
(
rxbuf
[
6
:
])
length
:=
binary
.
BigEndian
.
Uint32
(
rxbuf
[
6
:
])
if
length
<
PktHeadLen
{
if
length
<
PktHeadLen
{
panic
()
// XXX err (length is a whole packet len with header)
panic
(
"TODO pkt.length < PktHeadLen"
)
// XXX err (length is a whole packet len with header)
}
}
if
length
>
len
(
rxbuf
)
{
if
length
>
uint32
(
len
(
rxbuf
))
{
// TODO grow rxbuf
// grow rxbuf
panic
()
rxbuf2
:=
make
([]
byte
,
length
)
copy
(
rxbuf2
,
rxbuf
[
:
n
])
rxbuf
=
rxbuf2
}
}
// read rest of pkt data, if we need to
// read rest of pkt data, if we need to
n2
,
err
:=
io
.
ReadFull
(
conn
,
rxbuf
[
n
:
length
])
_
,
err
=
io
.
ReadFull
(
conn
,
rxbuf
[
n
:
length
])
if
err
!=
nil
{
// read first pkt chunk: header + some data (all in 1 read call)
panic
(
err
)
// XXX err
rxl
.
N
=
4096
}
n
,
err
:=
rxbuf
.
ReadFrom
(
rxl
)
}
}
...
@@ -72,7 +86,6 @@ type Server interface {
...
@@ -72,7 +86,6 @@ type Server interface {
// - for every accepted connection spawn srv.ServeConn() in separate goroutine.
// - for every accepted connection spawn srv.ServeConn() in separate goroutine.
//
//
// the listener is closed when Serve returns.
// the listener is closed when Serve returns.
// XXX text
// XXX move -> generic place ?
// XXX move -> generic place ?
func
Serve
(
ctx
context
.
Context
,
l
net
.
Listener
,
srv
Server
)
error
{
func
Serve
(
ctx
context
.
Context
,
l
net
.
Listener
,
srv
Server
)
error
{
fmt
.
Printf
(
"stor: serving on %s ...
\n
"
,
l
.
Addr
())
fmt
.
Printf
(
"stor: serving on %s ...
\n
"
,
l
.
Addr
())
...
...
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