Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
8c736e77
Commit
8c736e77
authored
Nov 23, 2016
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fa68b9e4
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
146 additions
and
122 deletions
+146
-122
t/neo/cmd/neostorage-go/neostorage.go
t/neo/cmd/neostorage-go/neostorage.go
+1
-1
t/neo/proto/pkt.go
t/neo/proto/pkt.go
+126
-111
t/neo/storage/filestorage.go
t/neo/storage/filestorage.go
+16
-10
t/neo/zodb.go
t/neo/zodb.go
+3
-0
No files found.
t/neo/cmd/neostorage-go/neostorage.go
View file @
8c736e77
...
...
@@ -5,7 +5,7 @@
package
main
import
(
"../../storage"
// XXX rel ok?
_
"../../storage"
// XXX rel ok?
)
...
...
t/neo/proto/pkt.go
View file @
8c736e77
package
proto
// TODO .TID -> .Tid etc ?
import
(
.
"../"
)
const
(
PROTOCOL_VERSION
=
6
PROTOCOL_VERSION
=
7
MIN_PACKET_SIZE
=
10
// XXX link this to len(pkthead) ?
MAX_PACKET_SIZE
=
0x4000000
...
...
@@ -24,6 +26,7 @@ const (
REPLICATION_ERROR
CHECKING_ERROR
BACKEND_NOT_IMPLEMENTED
READ_ONLY_ACCESS
)
type
ClusterState
int
...
...
@@ -31,7 +34,7 @@ const (
// NOTE cluster states descriptions is in protocol.py
RECOVERING
ClusterState
=
iota
VERIFYING
RUNNING
CLUSTER_RUNNING
// XXX conflict with NodeState.
RUNNING
STOPPING
STARTING_BACKUP
BACKINGUP
...
...
@@ -79,10 +82,22 @@ type UUID int32
// TODO UUID_NAMESPACES
// XXX -> NodeInfo (and use []NodeInfo) ?
type
NodeList
[]
struct
{
type
Address
struct
{
Host
string
Port
uint16
// TODO if Host == 0 -> Port not added to wire (see py.PAddress)
}
// A SHA1 hash
type
Checksum
[
20
]
byte
// Partition Table identifier
// Zero value means "invalid id" (<-> None in py.PPTID)
type
PTid
uint64
// XXX move to common place ?
// NOTE original NodeList = []NodeInfo
type
NodeInfo
struct
{
NodeType
Address
PAddress
// TODO
Address
UUID
NodeState
}
...
...
@@ -142,10 +157,10 @@ type CloseClient struct {
// connection. Any -> Any.
type
RequestIdentification
struct
{
Packet
ProtocolVersion
PProtocol
// TODO
ProtocolVersion
uint32
// TODO py.PProtocol upon decoding checks for != PROTOCOL_VERSION
NodeType
NodeType
// XXX name
UUID
UUID
Address
PAddress
// TODO
Address
Name
string
}
...
...
@@ -157,9 +172,9 @@ type AcceptIdentification struct {
NumPartitions
uint32
// PNumber
NumReplicas
uint32
// PNumber
YourUUID
UUID
Primary
P
Address
// TODO
Primary
Address
// TODO
KnownMasterList
[]
struct
{
Address
PAddress
Address
UUID
UUID
}
}
...
...
@@ -191,9 +206,9 @@ type Recovery struct {
type
AnswerRecovery
struct
{
Packet
PT
ID
PPTID
// TODO
BackupTID
T
ID
TruncateTID
T
ID
PT
id
BackupTID
T
id
TruncateTID
T
id
}
// Ask the last OID/TID so that a master can initialize its TransactionManager.
...
...
@@ -204,8 +219,8 @@ type LastIDs struct {
type
AnswerLastIDs
struct
{
Packet
LastOID
O
ID
LastTID
T
ID
LastOID
O
id
LastTID
T
id
}
// Ask the full partition table. PM -> S.
...
...
@@ -216,7 +231,7 @@ type PartitionTable struct {
type
AnswerPartitionTable
struct
{
Packet
PT
ID
PPTID
// TODO
PT
id
RowList
RowList
}
...
...
@@ -224,16 +239,16 @@ type AnswerPartitionTable struct {
// Send rows in a partition table to update other nodes. PM -> S, C.
type
NotifyPartitionTable
struct
{
Packet
PT
ID
PPTID
// TODO
PT
id
RowList
RowList
}
// Notify a subset of a partition table. This is used to notify changes.
// PM -> S, C.
type
PartitionChanges
struct
type
PartitionChanges
struct
{
Packet
PT
ID
PPTID
// TODO
PT
id
CellList
[]
struct
{
// XXX does below correlate with Cell inside top-level CellList ?
Offset
uint32
// PNumber
...
...
@@ -265,9 +280,9 @@ type UnfinishedTransactions struct {
type
AnswerUnfinishedTransactions
struct
{
Packet
MaxTID
T
ID
MaxTID
T
id
TidList
[]
struct
{
UnfinishedTID
T
ID
UnfinishedTID
T
id
}
}
...
...
@@ -279,25 +294,25 @@ type LockedTransactions struct {
type
AnswerLockedTransactions
struct
{
Packet
TidDict
map
[
T
ID
]
TID
// ttid -> tid
TidDict
map
[
T
id
]
Tid
// ttid -> tid
}
// Return final tid if ttid has been committed. * -> S. C -> PM.
type
FinalTID
struct
{
Packet
TTID
T
ID
TTID
T
id
}
type
AnswerFinalTID
struct
{
Packet
T
ID
TID
T
id
Tid
}
// Commit a transaction. PM -> S.
type
ValidateTransaction
struct
{
Packet
TTID
T
ID
Tid
T
ID
TTID
T
id
Tid
T
id
}
...
...
@@ -305,62 +320,62 @@ type ValidateTransaction struct {
// Answer when a transaction begin, give a TID if necessary. PM -> C.
type
BeginTransaction
struct
{
Packet
T
ID
TID
T
id
Tid
}
type
AnswerBeginTransaction
struct
{
Packet
T
ID
TID
T
id
Tid
}
// Finish a transaction. C -> PM.
// Answer when a transaction is finished. PM -> C.
type
FinishTransaction
struct
{
Packet
T
ID
TID
OIDList
[]
O
ID
CheckedList
[]
O
ID
T
id
Tid
OIDList
[]
O
id
CheckedList
[]
O
id
}
type
AnswerFinishTransaction
struct
{
Packet
TTID
T
ID
T
ID
TID
TTID
T
id
T
id
Tid
}
// Notify that a transaction blocking a replication is now finished
// M -> S
type
NotifyTransactionFinished
struct
{
Packet
TTID
T
ID
MaxTID
T
ID
TTID
T
id
MaxTID
T
id
}
// Lock information on a transaction. PM -> S.
// Notify information on a transaction locked. S -> PM.
type
LockInformation
struct
{
Packet
Ttid
T
ID
Tid
T
ID
Ttid
T
id
Tid
T
id
}
// XXX AnswerInformationLocked ?
type
AnswerLockInformation
struct
{
Ttid
T
ID
Ttid
T
id
}
// Invalidate objects. PM -> C.
// XXX ask_finish_transaction ?
type
InvalidateObjects
struct
{
Packet
T
ID
TID
OidList
[]
O
ID
T
id
Tid
OidList
[]
O
id
}
// Unlock information on a transaction. PM -> S.
type
UnlockInformation
struct
{
Packet
TTID
T
ID
TTID
T
id
}
// Ask new object IDs. C -> PM.
...
...
@@ -373,7 +388,7 @@ type GenerateOIDs struct {
// XXX answer_new_oids ?
type
AnswerGenerateOIDs
struct
{
Packet
OidList
[]
O
ID
OidList
[]
O
id
}
...
...
@@ -385,38 +400,38 @@ type AnswerGenerateOIDs struct {
// node must not try to resolve the conflict. S -> C.
type
StoreObject
struct
{
Packet
O
ID
OID
Serial
T
ID
O
id
Oid
Serial
T
id
Compression
bool
Checksum
PChecksum
// TODO
Checksum
Checksum
Data
[]
byte
// XXX or string ?
DataSerial
T
ID
T
ID
TID
DataSerial
T
id
T
id
Tid
Unlock
bool
}
type
AnswerStoreObject
struct
{
Packet
Conflicting
bool
O
ID
OID
Serial
T
ID
O
id
Oid
Serial
T
id
}
// Abort a transaction. C -> S, PM.
type
AbortTransaction
struct
{
Packet
T
ID
TID
T
id
Tid
}
// Ask to store a transaction. C -> S.
// Answer if transaction has been stored. S -> C.
type
StoreTransaction
struct
{
Packet
T
ID
TID
T
id
Tid
User
string
Description
string
Extension
string
OidList
[]
O
ID
OidList
[]
O
id
// TODO _answer = PFEmpty
}
...
...
@@ -424,7 +439,7 @@ type StoreTransaction struct {
// Answer if transaction has been stored. S -> C.
type
VoteTransaction
struct
{
Packet
T
ID
TID
T
id
Tid
// TODO _answer = PFEmpty
}
...
...
@@ -434,21 +449,21 @@ type VoteTransaction struct {
// Answer the requested object. S -> C.
type
GetObject
struct
{
Packet
O
ID
OID
Serial
T
ID
T
ID
TID
O
id
Oid
Serial
T
id
T
id
Tid
}
// XXX answer_object ?
type
AnswerGetObject
struct
{
Packet
O
ID
OID
SerialStart
T
ID
SerialEnd
T
ID
O
id
Oid
SerialStart
T
id
SerialEnd
T
id
Compression
bool
Checksum
P
Checksum
Checksum
Checksum
Data
[]
byte
// XXX or string ?
DataSerial
T
ID
DataSerial
T
id
}
// Ask for TIDs between a range of offsets. The order of TIDs is descending,
...
...
@@ -456,7 +471,7 @@ type AnswerGetObject struct {
// Answer the requested TIDs. S -> C.
type
TIDList
struct
{
Packet
Fi
srt
uint64
// PIndex XXX this is TID actually ?
Fi
rst
uint64
// PIndex XXX this is TID actually ? -> no it is offset in list
Last
uint64
// PIndex ----//----
Partition
uint32
// PNumber
}
...
...
@@ -464,7 +479,7 @@ type TIDList struct {
// XXX answer_tids ?
type
AnswerTIDList
struct
{
Packet
TIDList
[]
T
ID
TIDList
[]
T
id
}
// Ask for length TIDs starting at min_tid. The order of TIDs is ascending.
...
...
@@ -472,8 +487,8 @@ type AnswerTIDList struct {
// Answer the requested TIDs. S -> C
type
TIDListFrom
struct
{
Packet
MinTID
T
ID
MaxTID
T
ID
MinTID
T
id
MaxTID
T
id
Length
uint32
// PNumber
Partition
uint32
// PNumber
}
...
...
@@ -481,24 +496,24 @@ type TIDListFrom struct {
// XXX answer_tids ?
type
AnswerTIDListFrom
struct
{
Packet
TidList
[]
T
ID
TidList
[]
T
id
}
// Ask information about a transaction. Any -> S.
// Answer information (user, description) about a transaction. S -> Any.
type
TransactionInformation
struct
{
Packet
T
ID
TID
T
id
Tid
}
type
AnswerTransactionInformation
struct
{
Packet
T
ID
TID
T
id
Tid
User
string
Description
string
Extension
string
Packed
bool
OidList
[]
O
ID
OidList
[]
O
id
}
// Ask history information for a given object. The order of serials is
...
...
@@ -506,16 +521,16 @@ type AnswerTransactionInformation struct {
// Answer history information (serial, size) for an object. S -> C.
type
ObjectHistory
struct
{
Packet
O
ID
OID
O
id
Oid
First
uint64
// PIndex XXX this is actually TID
Last
uint64
// PIndex ----//----
}
type
AnswerObjectHistory
struct
{
Packet
O
ID
OID
O
id
Oid
HistoryList
[]
struct
{
Serial
T
ID
Serial
T
id
Size
uint32
// PNumber
}
}
...
...
@@ -532,20 +547,20 @@ type PartitionList struct {
type
AnswerPartitionList
struct
{
Packet
PT
ID
PTID
PT
id
RowList
RowList
)
}
// Ask information about nodes
// Answer information about nodes
type
NodeList
struct
{
type
X_
NodeList
struct
{
Packet
NodeType
}
type
AnswerNodeList
struct
{
Packet
NodeList
NodeList
[]
NodeInfo
}
// Set the node state
...
...
@@ -576,7 +591,7 @@ type TweakPartitionTable struct {
// Notify information about one or more nodes. PM -> Any.
type
NotifyNodeInformation
struct
{
Packet
NodeList
NodeList
[]
NodeInfo
}
// Ask node information
...
...
@@ -601,7 +616,7 @@ type ClusterInformation struct {
// Ask state of the cluster
// Answer state of the cluster
type
ClusterState
struct
{
type
X_ClusterState
struct
{
// XXX conflicts with ClusterState enum
Packet
State
ClusterState
}
...
...
@@ -623,18 +638,18 @@ type ClusterState struct {
// S -> C
type
ObjectUndoSerial
struct
{
Packet
T
ID
TID
LTID
T
ID
UndoneTID
T
ID
OidList
[]
O
ID
T
id
Tid
LTID
T
id
UndoneTID
T
id
OidList
[]
O
id
}
// XXX answer_undo_transaction ?
type
AnswerObjectUndoSerial
struct
{
Packet
ObjectTIDDict
map
[
O
ID
]
struct
{
CurrentSerial
T
ID
UndoSerial
T
ID
ObjectTIDDict
map
[
O
id
]
struct
{
CurrentSerial
T
id
UndoSerial
T
id
IsCurrent
bool
}
}
...
...
@@ -644,13 +659,13 @@ type AnswerObjectUndoSerial struct {
// Answer whether a transaction holds the write lock for requested object.
type
HasLock
struct
{
Packet
T
ID
TID
O
ID
OID
T
id
Tid
O
id
Oid
}
type
AnswerHasLock
struct
{
Packet
O
ID
OID
O
id
Oid
LockState
LockState
}
...
...
@@ -663,16 +678,16 @@ type AnswerHasLock struct {
// is nothing to invalidate in any client's cache.
type
CheckCurrentSerial
struct
{
Packet
T
ID
TID
Serial
T
ID
O
ID
OID
T
id
Tid
Serial
T
id
O
id
Oid
}
// XXX answer_store_object ?
type
AnswerCheckCurrentSerial
struct
{
Conflicting
bool
O
ID
OID
Serial
T
ID
O
id
Oid
Serial
T
id
}
// Request a pack at given TID.
...
...
@@ -683,7 +698,7 @@ type AnswerCheckCurrentSerial struct {
// M -> C
type
Pack
struct
{
Packet
T
ID
TID
T
id
Tid
}
type
AnswerPack
struct
{
...
...
@@ -697,8 +712,8 @@ type AnswerPack struct {
type
CheckReplicas
struct
{
Packet
PartitionDict
map
[
uint32
/*PNumber*/
]
UUID
// partition -> source
MinTID
T
ID
MaxTID
T
ID
MinTID
T
id
MaxTID
T
id
// XXX _answer = Error
}
...
...
@@ -709,10 +724,10 @@ type CheckPartition struct {
Partition
uint32
// PNumber
Source
struct
{
UpstreamName
string
Address
P
Address
Address
Address
}
MinTID
T
ID
MaxTID
T
ID
MinTID
T
id
MaxTID
T
id
}
...
...
@@ -728,15 +743,15 @@ type CheckTIDRange struct {
Packet
Partition
uint32
// PNumber
Length
uint32
// PNumber
MinTID
T
ID
MaxTID
T
ID
MinTID
T
id
MaxTID
T
id
}
type
AnswerCheckTIDRange
struct
{
Packet
Count
uint32
// PNumber
Checksum
PChecksum
// TODO
MaxTID
T
ID
Checksum
Checksum
MaxTID
T
id
}
// Ask some stats about a range of object history.
...
...
@@ -751,17 +766,17 @@ type CheckSerialRange struct {
Packet
Partition
uint32
// PNumber
Length
uint32
// PNumber
MinTID
T
ID
MaxTID
T
ID
MinOID
O
ID
MinTID
T
id
MaxTID
T
id
MinOID
O
id
}
type
AnswerCheckSerialRange
struct
{
Count
uint32
// PNumber
TidChecksum
P
Checksum
MaxTID
T
ID
OidChecksum
P
Checksum
MaxOID
O
ID
TidChecksum
Checksum
MaxTID
T
id
OidChecksum
Checksum
MaxOID
O
id
}
// S -> M
...
...
@@ -782,7 +797,7 @@ type LastTransaction struct {
type
AnswerLastTransaction
struct
{
Packet
T
ID
TID
T
id
Tid
}
...
...
t/neo/storage/filestorage.go
View file @
8c736e77
...
...
@@ -3,8 +3,13 @@
// filestorage support XXX text
package
storage
import
(
"os"
.
"../"
)
type
FileStorage
struct
{
f
d
int
f
*
os
.
File
// XXX naming -> file ?
}
// IStorage
...
...
@@ -36,32 +41,32 @@ type DataRec struct {
}
func
(
TxnRecHead
*
rh
)
MarshalFS
()
[]
byte
{
func
(
rh
*
TxnRecHead
)
MarshalFS
()
[]
byte
{
panic
(
"TODO"
)
}
func
(
TxnRecHead
*
rh
)
UnmarshalFS
(
data
[]
byte
)
{
TODO
func
(
rh
*
TxnRecHead
)
UnmarshalFS
(
data
[]
byte
)
{
//
TODO
}
func
NewFileStorage
(
path
string
)
(
*
FileStorage
,
error
)
{
f
d
,
err
:=
...
Open
(
path
,
O_RDONLY
)
f
,
err
:=
os
.
Open
(
path
)
// note opens in O_RDONLY
if
err
!=
nil
{
return
nil
,
err
}
// TODO read file header
Read
(
fd
,
4
)
!=
"FS21"
->
invalid
header
return
&
FileStorage
{
f
d
:
fd
}
//Read(f
, 4) != "FS21" -> invalid header
return
&
FileStorage
{
f
:
f
},
nil
}
func
(
f
*
FileStorage
)
Close
()
error
{
err
:=
Os
.
Close
(
f
.
fd
)
err
:=
f
.
f
.
Close
(
)
if
err
!=
nil
{
return
err
}
f
.
f
d
=
-
1
f
.
f
=
nil
return
nil
}
...
...
@@ -70,5 +75,6 @@ func (f *FileStorage) Iterate(start, stop Tid) IStorageIterator {
panic
(
"TODO start/stop support"
)
}
// TODO
return
nil
}
t/neo/zodb.go
View file @
8c736e77
...
...
@@ -18,10 +18,13 @@ const (
INVALID_TID
Tid
=
1
<<
64
-
1
// 0xffffffffffffffff TODO recheck it is the same
INVALID_OID
Oid
=
0xffffffffffffffff
// 1<<64 - 1
ZERO_TID
Tid
=
0
// XXX or simply TID{} ? // XXX -> TID0 ?
TID0
Tid
=
ZERO_TID
// XXX ^^^ choose 1
ZERO_OID
Oid
=
0
// XXX or simply OID{} ? // XXX -> OID0
// OID_LEN = 8
// TID_LEN = 8
MAX_TID
Tid
=
0x7fffffffffffffff
// SQLite does not accept numbers above 2^63-1 // XXX -> TIDMAX ?
TIDMAX
Tid
=
MAX_TID
// XXX ^^^ choose 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