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
3
Merge Requests
3
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
e4023e90
Commit
e4023e90
authored
Apr 24, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
632042db
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
8 deletions
+91
-8
t/neo/marshal.go
t/neo/marshal.go
+4
-4
t/neo/proto.go
t/neo/proto.go
+3
-2
t/neo/storage.go
t/neo/storage.go
+84
-2
No files found.
t/neo/marshal.go
View file @
e4023e90
...
@@ -1919,8 +1919,8 @@ func (p *AnswerGetObject) NEOEncodedLen() int {
...
@@ -1919,8 +1919,8 @@ func (p *AnswerGetObject) NEOEncodedLen() int {
func
(
p
*
AnswerGetObject
)
NEOEncode
(
data
[]
byte
)
{
func
(
p
*
AnswerGetObject
)
NEOEncode
(
data
[]
byte
)
{
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
0
:
],
uint64
(
p
.
Oid
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
Start
))
binary
.
BigEndian
.
PutUint64
(
data
[
8
:
],
uint64
(
p
.
Serial
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
SerialEnd
))
binary
.
BigEndian
.
PutUint64
(
data
[
16
:
],
uint64
(
p
.
NextSerial
))
(
data
[
24
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
(
data
[
24
:
])[
0
]
=
bool2byte
(
p
.
Compression
)
copy
(
data
[
25
:
],
p
.
Checksum
[
:
])
copy
(
data
[
25
:
],
p
.
Checksum
[
:
])
{
{
...
@@ -1939,8 +1939,8 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
...
@@ -1939,8 +1939,8 @@ func (p *AnswerGetObject) NEODecode(data []byte) (int, error) {
goto
overflow
goto
overflow
}
}
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Oid
=
zodb
.
Oid
(
binary
.
BigEndian
.
Uint64
(
data
[
0
:
]))
p
.
Serial
Start
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
Serial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
8
:
]))
p
.
SerialEnd
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
NextSerial
=
zodb
.
Tid
(
binary
.
BigEndian
.
Uint64
(
data
[
16
:
]))
p
.
Compression
=
byte2bool
((
data
[
24
:
])[
0
])
p
.
Compression
=
byte2bool
((
data
[
24
:
])[
0
])
copy
(
p
.
Checksum
[
:
],
data
[
25
:
45
])
copy
(
p
.
Checksum
[
:
],
data
[
25
:
45
])
{
{
...
...
t/neo/proto.go
View file @
e4023e90
...
@@ -218,6 +218,7 @@ type Notify struct {
...
@@ -218,6 +218,7 @@ type Notify struct {
// usually. Any -> Any.
// usually. Any -> Any.
type
Error
struct
{
type
Error
struct
{
Code
uint32
// PNumber
Code
uint32
// PNumber
//Code ErrorCode // PNumber
Message
string
Message
string
}
}
...
@@ -537,8 +538,8 @@ type GetObject struct {
...
@@ -537,8 +538,8 @@ type GetObject struct {
// XXX answer_object ?
// XXX answer_object ?
type
AnswerGetObject
struct
{
type
AnswerGetObject
struct
{
Oid
zodb
.
Oid
Oid
zodb
.
Oid
Serial
Start
zodb
.
Tid
Serial
zodb
.
Tid
// XXX strictly is SerialStart/SerialEnd in proto.py
SerialEnd
zodb
.
Tid
NextSerial
zodb
.
Tid
// XXX but there it is out of sync
Compression
bool
Compression
bool
Checksum
Checksum
Checksum
Checksum
Data
[]
byte
// TODO separately (for writev)
Data
[]
byte
// TODO separately (for writev)
...
...
t/neo/storage.go
View file @
e4023e90
...
@@ -11,18 +11,22 @@
...
@@ -11,18 +11,22 @@
// See COPYING file for full licensing terms.
// See COPYING file for full licensing terms.
// TODO text
// TODO text
// XXX move to separate "storage" package ?
package
neo
package
neo
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"./zodb"
)
)
// NEO Storage application
// NEO Storage application
// XXX naming
// XXX naming
type
StorageApplication
struct
{
type
Storage
struct
{
zstor
zodb
.
IStorage
// underlying ZODB storage XXX temp ?
}
}
...
@@ -33,7 +37,7 @@ type Buffer struct {
...
@@ -33,7 +37,7 @@ type Buffer struct {
}
}
*/
*/
func
(
stor
*
Storage
Application
)
ServeLink
(
ctx
context
.
Context
,
link
*
NodeLink
)
{
func
(
stor
*
Storage
)
ServeLink
(
ctx
context
.
Context
,
link
*
NodeLink
)
{
fmt
.
Printf
(
"stor: serving new node %s <-> %s
\n
"
,
link
.
peerLink
.
LocalAddr
(),
link
.
peerLink
.
RemoteAddr
())
fmt
.
Printf
(
"stor: serving new node %s <-> %s
\n
"
,
link
.
peerLink
.
LocalAddr
(),
link
.
peerLink
.
RemoteAddr
())
/*
/*
...
@@ -92,3 +96,81 @@ func (stor *StorageApplication) ServeLink(ctx context.Context, link *NodeLink) {
...
@@ -92,3 +96,81 @@ func (stor *StorageApplication) ServeLink(ctx context.Context, link *NodeLink) {
//recvPkt()
//recvPkt()
}
}
type
StorageClientHandler
struct
{
stor
*
Storage
}
// XXX stub
// XXX move me out of here
func
RecvAndDecode
(
conn
*
Conn
)
(
interface
{},
error
)
{
pkt
,
err
:=
conn
.
Recv
()
if
err
!=
nil
{
return
nil
,
err
}
// TODO decode pkt
return
pkt
,
nil
}
func
EncodeAndSend
(
conn
*
Conn
,
pkt
NEOEncoder
)
error
{
// TODO encode pkt
l
:=
pkt
.
NEOEncodedLen
()
buf
:=
PktBuf
{
make
([]
byte
,
PktHeadLen
+
l
)}
// XXX -> freelist
pkt
.
NEOEncode
(
buf
.
Payload
())
return
conn
.
Send
(
&
buf
)
// XXX why pointer?
}
// XXX naming for RecvAndDecode and EncodeAndSend
func
(
ch
*
StorageClientHandler
)
ServeConn
(
ctx
context
.
Context
,
conn
*
Conn
)
{
// TODO ctx.Done -> close conn
defer
conn
.
Close
()
// XXX err
pkt
,
err
:=
RecvAndDecode
(
conn
)
if
err
!=
nil
{
return
// XXX log / err / send error before closing
}
switch
pkt
:=
pkt
.
(
type
)
{
case
*
GetObject
:
xid
:=
zodb
.
Xid
{
Oid
:
pkt
.
Oid
}
if
pkt
.
Serial
!=
INVALID_TID
{
xid
.
Tid
=
pkt
.
Serial
xid
.
TidBefore
=
false
}
else
{
xid
.
Tid
=
pkt
.
Tid
xid
.
TidBefore
=
true
}
data
,
tid
,
err
:=
ch
.
stor
.
zstor
.
Load
(
xid
)
if
err
!=
nil
{
// TODO translate err to NEO protocol error codes
errPkt
:=
Error
{
Code
:
0
,
Message
:
err
.
Error
()}
EncodeAndSend
(
conn
,
&
errPkt
)
// XXX err
}
else
{
answer
:=
AnswerGetObject
{
Oid
:
xid
.
Oid
,
Serial
:
tid
,
Compression
:
false
,
Data
:
data
,
// XXX .CheckSum
// XXX .NextSerial
// XXX .DataSerial
}
EncodeAndSend
(
conn
,
&
answer
)
// XXX err
}
case
*
LastTransaction
:
// ----//---- for zstor.LastTid()
case
*
ObjectHistory
:
//case *StoreObject:
}
//pkt.Put(...)
}
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