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
413c07d3
Commit
413c07d3
authored
Mar 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
a3d6a35d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
26 deletions
+29
-26
go/zodb/connection.go
go/zodb/connection.go
+3
-3
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+22
-22
go/zodb/zodbtools/info.go
go/zodb/zodbtools/info.go
+4
-1
No files found.
go/zodb/connection.go
View file @
413c07d3
...
@@ -152,13 +152,13 @@ const (
...
@@ -152,13 +152,13 @@ const (
// state eviction until state discard is semantically required.
// state eviction until state discard is semantically required.
PCachePinObject
PCachePolicy
=
1
<<
iota
PCachePinObject
PCachePolicy
=
1
<<
iota
// don't keep object in
the
cache.
// don't keep object in cache.
//
//
// The object will be discarded from the cache completely as soon as it
// The object will be discarded from the cache completely as soon as it
// is semantically valid to do so.
// is semantically valid to do so.
PCacheDropObject
PCacheDropObject
// keep object state in the
cache.
// keep object state in
cache.
//
//
// This prevents object state to go away when !dirty object is no
// This prevents object state to go away when !dirty object is no
// longer used. However the object itself can go away unless it is
// longer used. However the object itself can go away unless it is
...
@@ -237,7 +237,7 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
...
@@ -237,7 +237,7 @@ func (cache *LiveCache) Get(oid Oid) IPersistent {
// setNew sets objects corresponding to oid.
// setNew sets objects corresponding to oid.
//
//
// The cache must not have
previous entry for oid before
setNew is called.
// The cache must not have
entry for oid when
setNew is called.
func
(
cache
*
LiveCache
)
setNew
(
oid
Oid
,
obj
IPersistent
)
{
func
(
cache
*
LiveCache
)
setNew
(
oid
Oid
,
obj
IPersistent
)
{
var
cp
PCachePolicy
var
cp
PCachePolicy
if
cc
:=
cache
.
control
;
cc
!=
nil
{
if
cc
:=
cache
.
control
;
cc
!=
nil
{
...
...
go/zodb/persistent_test.go
View file @
413c07d3
...
@@ -204,8 +204,10 @@ func (cc *zcacheControl) PCacheClassify(obj IPersistent) PCachePolicy {
...
@@ -204,8 +204,10 @@ func (cc *zcacheControl) PCacheClassify(obj IPersistent) PCachePolicy {
return
cc
.
pCachePolicy
[
obj
.
POid
()]
// default -> 0
return
cc
.
pCachePolicy
[
obj
.
POid
()]
// default -> 0
}
}
// tPersistentDB represents testing database. XXX -> tDB ?
// tDB represents testing database.
type
tPersistentDB
struct
{
//
// The database can be worked on via zodb/go and committed into via zodb/py.
type
tDB
struct
{
*
testing
.
T
*
testing
.
T
work
string
// working directory
work
string
// working directory
...
@@ -222,8 +224,8 @@ type tPersistentDB struct {
...
@@ -222,8 +224,8 @@ type tPersistentDB struct {
rawcache
bool
rawcache
bool
}
}
// t
PersistentConn represents testing Connection. XXX -> tConn ?
// t
Connection represents testing Connection.
type
t
PersistentCon
n
struct
{
type
t
Connectio
n
struct
{
*
testing
.
T
*
testing
.
T
// a transaction and DB connection opened under it
// a transaction and DB connection opened under it
...
@@ -233,9 +235,9 @@ type tPersistentConn struct {
...
@@ -233,9 +235,9 @@ type tPersistentConn struct {
}
}
// testdb creates and initializes new test database.
// testdb creates and initializes new test database.
func
testdb
(
t0
*
testing
.
T
,
rawcache
bool
)
*
t
Persistent
DB
{
func
testdb
(
t0
*
testing
.
T
,
rawcache
bool
)
*
tDB
{
t0
.
Helper
()
t0
.
Helper
()
t
:=
&
t
Persistent
DB
{
t
:=
&
tDB
{
T
:
t0
,
T
:
t0
,
rawcache
:
rawcache
,
rawcache
:
rawcache
,
}
}
...
@@ -265,7 +267,7 @@ func testdb(t0 *testing.T, rawcache bool) *tPersistentDB {
...
@@ -265,7 +267,7 @@ func testdb(t0 *testing.T, rawcache bool) *tPersistentDB {
}
}
// Reopen repoens zodb/go .stor and .db .
// Reopen repoens zodb/go .stor and .db .
func
(
t
*
t
Persistent
DB
)
Reopen
()
{
func
(
t
*
tDB
)
Reopen
()
{
t
.
Helper
()
t
.
Helper
()
X
:=
t
.
fatalif
X
:=
t
.
fatalif
...
@@ -279,7 +281,7 @@ func (t *tPersistentDB) Reopen() {
...
@@ -279,7 +281,7 @@ func (t *tPersistentDB) Reopen() {
t
.
db
=
db
t
.
db
=
db
}
}
func
(
t
*
t
Persistent
DB
)
close
()
{
func
(
t
*
tDB
)
close
()
{
t
.
Helper
()
t
.
Helper
()
X
:=
t
.
fatalif
X
:=
t
.
fatalif
...
@@ -295,7 +297,7 @@ func (t *tPersistentDB) close() {
...
@@ -295,7 +297,7 @@ func (t *tPersistentDB) close() {
}
}
// Close release resources associated with test database.
// Close release resources associated with test database.
func
(
t
*
t
Persistent
DB
)
Close
()
{
func
(
t
*
tDB
)
Close
()
{
t
.
Helper
()
t
.
Helper
()
X
:=
t
.
fatalif
X
:=
t
.
fatalif
...
@@ -307,7 +309,7 @@ func (t *tPersistentDB) Close() {
...
@@ -307,7 +309,7 @@ func (t *tPersistentDB) Close() {
// MyObject(value).
// MyObject(value).
//
//
// The commit is performed by Commit.
// The commit is performed by Commit.
func
(
t
*
t
Persistent
DB
)
Add
(
oid
Oid
,
value
string
)
{
func
(
t
*
tDB
)
Add
(
oid
Oid
,
value
string
)
{
obj
:=
NewMyObject
(
nil
)
// XXX hack - goes without jar
obj
:=
NewMyObject
(
nil
)
// XXX hack - goes without jar
obj
.
oid
=
oid
obj
.
oid
=
oid
obj
.
value
=
value
obj
.
value
=
value
...
@@ -315,20 +317,19 @@ func (t *tPersistentDB) Add(oid Oid, value string) {
...
@@ -315,20 +317,19 @@ func (t *tPersistentDB) Add(oid Oid, value string) {
}
}
// Commit commits objects queued by Add.
// Commit commits objects queued by Add.
func
(
t
*
t
Persistent
DB
)
Commit
()
{
func
(
t
*
tDB
)
Commit
()
{
t
.
Helper
()
t
.
Helper
()
head
,
err
:=
ZPyCommit
(
t
.
zurl
,
t
.
head
,
t
.
commitq
...
)
head
,
err
:=
ZPyCommit
(
t
.
zurl
,
t
.
head
,
t
.
commitq
...
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
//fmt.Printf("commit @%s -> @%s\n", t.head, head)
t
.
head
=
head
t
.
head
=
head
t
.
commitq
=
nil
t
.
commitq
=
nil
}
}
// Open opens new test transaction/connection.
// Open opens new test transaction/connection.
func
(
t
*
t
PersistentDB
)
Open
(
opt
*
ConnOptions
)
*
tPersistentCon
n
{
func
(
t
*
t
DB
)
Open
(
opt
*
ConnOptions
)
*
tConnectio
n
{
t
.
Helper
()
t
.
Helper
()
X
:=
t
.
fatalif
X
:=
t
.
fatalif
...
@@ -338,7 +339,7 @@ func (t *tPersistentDB) Open(opt *ConnOptions) *tPersistentConn {
...
@@ -338,7 +339,7 @@ func (t *tPersistentDB) Open(opt *ConnOptions) *tPersistentConn {
assert
.
Same
(
t
,
conn
.
db
,
t
.
db
)
assert
.
Same
(
t
,
conn
.
db
,
t
.
db
)
assert
.
Same
(
t
,
conn
.
txn
,
txn
)
assert
.
Same
(
t
,
conn
.
txn
,
txn
)
return
&
t
PersistentCon
n
{
return
&
t
Connectio
n
{
T
:
t
.
T
,
T
:
t
.
T
,
txn
:
txn
,
txn
:
txn
,
ctx
:
ctx
,
ctx
:
ctx
,
...
@@ -347,7 +348,7 @@ func (t *tPersistentDB) Open(opt *ConnOptions) *tPersistentConn {
...
@@ -347,7 +348,7 @@ func (t *tPersistentDB) Open(opt *ConnOptions) *tPersistentConn {
}
}
// Get gets oid from t.conn and asserts its type.
// Get gets oid from t.conn and asserts its type.
func
(
t
*
t
PersistentCon
n
)
Get
(
oid
Oid
)
*
MyObject
{
func
(
t
*
t
Connectio
n
)
Get
(
oid
Oid
)
*
MyObject
{
t
.
Helper
()
t
.
Helper
()
xobj
,
err
:=
t
.
conn
.
Get
(
t
.
ctx
,
oid
)
xobj
,
err
:=
t
.
conn
.
Get
(
t
.
ctx
,
oid
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -364,7 +365,7 @@ func (t *tPersistentConn) Get(oid Oid) *MyObject {
...
@@ -364,7 +365,7 @@ func (t *tPersistentConn) Get(oid Oid) *MyObject {
}
}
// PActivate activates obj in t environment.
// PActivate activates obj in t environment.
func
(
t
*
t
PersistentCon
n
)
PActivate
(
obj
IPersistent
)
{
func
(
t
*
t
Connectio
n
)
PActivate
(
obj
IPersistent
)
{
t
.
Helper
()
t
.
Helper
()
err
:=
obj
.
PActivate
(
t
.
ctx
)
err
:=
obj
.
PActivate
(
t
.
ctx
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -375,7 +376,7 @@ func (t *tPersistentConn) PActivate(obj IPersistent) {
...
@@ -375,7 +376,7 @@ func (t *tPersistentConn) PActivate(obj IPersistent) {
// checkObj checks state of obj and that obj ∈ t.conn.
// checkObj checks state of obj and that obj ∈ t.conn.
//
//
// if object is !GHOST - it also verifies its value.
// if object is !GHOST - it also verifies its value.
func
(
t
*
t
PersistentCon
n
)
checkObj
(
obj
*
MyObject
,
oid
Oid
,
serial
Tid
,
state
ObjectState
,
refcnt
int32
,
valueOk
...
string
)
{
func
(
t
*
t
Connectio
n
)
checkObj
(
obj
*
MyObject
,
oid
Oid
,
serial
Tid
,
state
ObjectState
,
refcnt
int32
,
valueOk
...
string
)
{
t
.
Helper
()
t
.
Helper
()
// any object with live pointer to it must be also in conn's cache.
// any object with live pointer to it must be also in conn's cache.
...
@@ -415,7 +416,7 @@ func (t *tPersistentConn) checkObj(obj *MyObject, oid Oid, serial Tid, state Obj
...
@@ -415,7 +416,7 @@ func (t *tPersistentConn) checkObj(obj *MyObject, oid Oid, serial Tid, state Obj
}
}
// Resync resyncs t to new transaction @at.
// Resync resyncs t to new transaction @at.
func
(
t
*
t
PersistentCon
n
)
Resync
(
at
Tid
)
{
func
(
t
*
t
Connectio
n
)
Resync
(
at
Tid
)
{
t
.
Helper
()
t
.
Helper
()
db
:=
t
.
conn
.
db
db
:=
t
.
conn
.
db
...
@@ -434,20 +435,20 @@ func (t *tPersistentConn) Resync(at Tid) {
...
@@ -434,20 +435,20 @@ func (t *tPersistentConn) Resync(at Tid) {
}
}
// Abort aborts t's connection and verifies it becomes !live.
// Abort aborts t's connection and verifies it becomes !live.
func
(
t
*
t
PersistentCon
n
)
Abort
()
{
func
(
t
*
t
Connectio
n
)
Abort
()
{
t
.
Helper
()
t
.
Helper
()
assert
.
Same
(
t
,
t
.
conn
.
txn
,
t
.
txn
)
assert
.
Same
(
t
,
t
.
conn
.
txn
,
t
.
txn
)
t
.
txn
.
Abort
()
t
.
txn
.
Abort
()
assert
.
Equal
(
t
,
t
.
conn
.
txn
,
nil
)
assert
.
Equal
(
t
,
t
.
conn
.
txn
,
nil
)
}
}
func
(
t
*
t
Persistent
DB
)
fatalif
(
err
error
)
{
func
(
t
*
tDB
)
fatalif
(
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
}
}
func
(
t
*
t
PersistentCon
n
)
fatalif
(
err
error
)
{
func
(
t
*
t
Connectio
n
)
fatalif
(
err
error
)
{
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
...
@@ -488,7 +489,6 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -488,7 +489,6 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
(
nil
))
assert
.
Equal
(
db
.
pool
,
[]
*
Connection
(
nil
))
// δtail coverage is (at1, at1] (at0 not included)
// δtail coverage is (at1, at1] (at0 not included)
//fmt.Println(db.δtail.Tail(), db.δtail.Head())
assert
.
Equal
(
db
.
δtail
.
Tail
(),
at1
)
assert
.
Equal
(
db
.
δtail
.
Tail
(),
at1
)
assert
.
Equal
(
db
.
δtail
.
Head
(),
at1
)
assert
.
Equal
(
db
.
δtail
.
Head
(),
at1
)
...
...
go/zodb/zodbtools/info.go
View file @
413c07d3
...
@@ -42,7 +42,10 @@ var infov = []struct {name string; getParam paramFunc} {
...
@@ -42,7 +42,10 @@ var infov = []struct {name string; getParam paramFunc} {
// TODO reenable size
// TODO reenable size
// {"size", func(stor zodb.IStorage) (string, error) { return stor.StorageSize(), nil }},
// {"size", func(stor zodb.IStorage) (string, error) { return stor.StorageSize(), nil }},
{
"head"
,
zhead
},
{
"head"
,
zhead
},
{
"last_tid"
,
zhead
},
// last_tid is deprecated alias for head
{
"last_tid"
,
func
(
ctx
context
.
Context
,
stor
zodb
.
IStorage
)
(
string
,
error
)
{
fmt
.
Fprintf
(
os
.
Stderr
,
"W: last_tid is deprecated alias for head
\n
"
)
return
zhead
(
ctx
,
stor
)
}},
}
}
func
zhead
(
ctx
context
.
Context
,
stor
zodb
.
IStorage
)
(
string
,
error
)
{
func
zhead
(
ctx
context
.
Context
,
stor
zodb
.
IStorage
)
(
string
,
error
)
{
...
...
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