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
Jérome Perrin
neoppod
Commits
c84c48ee
Commit
c84c48ee
authored
Jul 30, 2018
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: make clearer that max_size attribute is used from outside ClientCache
parent
1ef5c1ba
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
12 deletions
+12
-12
neo/client/app.py
neo/client/app.py
+1
-1
neo/client/cache.py
neo/client/cache.py
+6
-6
neo/client/transactions.py
neo/client/transactions.py
+1
-1
neo/tests/threaded/__init__.py
neo/tests/threaded/__init__.py
+2
-2
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+1
-1
neo/tests/threaded/testReplication.py
neo/tests/threaded/testReplication.py
+1
-1
No files found.
neo/client/app.py
View file @
c84c48ee
...
...
@@ -447,7 +447,7 @@ class Application(ThreadedApplication):
txn_context
.
data_dict
[
oid
]
=
data
,
serial
,
txn_context
.
write
(
self
,
packet
,
oid
,
oid
=
oid
)
while
txn_context
.
data_size
>=
self
.
_cache
.
_
max_size
:
while
txn_context
.
data_size
>=
self
.
_cache
.
max_size
:
self
.
_waitAnyTransactionMessage
(
txn_context
)
self
.
_waitAnyTransactionMessage
(
txn_context
,
False
)
...
...
neo/client/cache.py
View file @
c84c48ee
...
...
@@ -64,7 +64,7 @@ class ClientCache(object):
- The history queue only contains items with counter > 0
"""
__slots__
=
(
'
_life_time'
,
'_max_history_size'
,
'_max
_size'
,
__slots__
=
(
'
max_size'
,
'_life_time'
,
'_max_history
_size'
,
'_queue_list'
,
'_oid_dict'
,
'_time'
,
'_size'
,
'_history_size'
,
'_nhit'
,
'_nmiss'
)
...
...
@@ -72,7 +72,7 @@ class ClientCache(object):
max_size
=
20
*
1024
*
1024
):
self
.
_life_time
=
life_time
self
.
_max_history_size
=
max_history_size
self
.
_
max_size
=
max_size
self
.
max_size
=
max_size
self
.
clear
()
def
clear
(
self
):
...
...
@@ -94,7 +94,7 @@ class ClientCache(object):
[
self
.
_history_size
]
+
[
sum
(
1
for
_
in
self
.
_iterQueue
(
level
))
for
level
in
xrange
(
1
,
len
(
self
.
_queue_list
))],
self
.
_life_time
,
self
.
_max_history_size
,
self
.
_
max_size
)
self
.
_life_time
,
self
.
_max_history_size
,
self
.
max_size
)
def
_iterQueue
(
self
,
level
):
"""for debugging purpose"""
...
...
@@ -168,7 +168,7 @@ class ClientCache(object):
# XXX It might be better to adjust the level according to the object
# size. See commented factor for example.
item
.
level
=
1
+
int
(
_log
(
counter
,
2
)
# * (1.01 - len(item.data) / self.
_
max_size)
# * (1.01 - len(item.data) / self.max_size)
)
self
.
_add
(
item
)
...
...
@@ -212,7 +212,7 @@ class ClientCache(object):
def
store
(
self
,
oid
,
data
,
tid
,
next_tid
):
"""Store a new data record in the cache"""
size
=
len
(
data
)
max_size
=
self
.
_
max_size
max_size
=
self
.
max_size
if
size
<
max_size
:
item
=
self
.
_load
(
oid
,
next_tid
)
if
item
:
...
...
@@ -331,7 +331,7 @@ def test(self):
# Test late invalidations.
cache
.
clear
()
cache
.
store
(
1
,
'10*'
,
10
,
None
)
cache
.
_
max_size
=
cache
.
_size
cache
.
max_size
=
cache
.
_size
cache
.
store
(
2
,
'10'
,
10
,
15
)
self
.
assertEqual
(
cache
.
_queue_list
[
0
].
oid
,
1
)
cache
.
store
(
2
,
'15'
,
15
,
None
)
...
...
neo/client/transactions.py
View file @
c84c48ee
...
...
@@ -121,7 +121,7 @@ class Transaction(object):
size
=
len
(
data
)
self
.
data_size
-=
size
size
+=
self
.
cache_size
if
size
<
app
.
_cache
.
_
max_size
:
if
size
<
app
.
_cache
.
max_size
:
self
.
cache_size
=
size
else
:
# Do not cache data past cache max size, as it
...
...
neo/tests/threaded/__init__.py
View file @
c84c48ee
...
...
@@ -425,7 +425,7 @@ class ClientApplication(Node, neo.client.app.Application):
self
.
poll_thread
.
node_name
=
name
# Smaller cache to speed up tests that checks behaviour when it's too
# small. See also NEOCluster.cache_size
self
.
_cache
.
_
max_size
//=
1024
self
.
_cache
.
max_size
//=
1024
def
_run
(
self
):
try
:
...
...
@@ -733,7 +733,7 @@ class NEOCluster(object):
@
property
def
cache_size
(
self
):
return
self
.
client
.
_cache
.
_
max_size
return
self
.
client
.
_cache
.
max_size
###
def
__enter__
(
self
):
...
...
neo/tests/threaded/test.py
View file @
c84c48ee
...
...
@@ -1939,7 +1939,7 @@ class Test(NEOThreadedTest):
def
changes
(
r1
,
r2
,
r3
):
r1
[
'b'
].
value
=
1
r1
[
'd'
].
value
=
2
r2
[
'a'
].
value
=
'*'
*
r2
.
_p_jar
.
db
().
storage
.
_cache
.
_
max_size
r2
[
'a'
].
value
=
'*'
*
r2
.
_p_jar
.
db
().
storage
.
_cache
.
max_size
r2
[
'b'
].
value
=
3
r2
[
'c'
].
value
=
4
r3
[
'a'
].
value
=
5
...
...
neo/tests/threaded/testReplication.py
View file @
c84c48ee
...
...
@@ -1046,7 +1046,7 @@ class ReplicationTests(NEOThreadedTest):
# try to commit something to backup storage and make sure it is
# really read-only
Zb
.
_cache
.
_
max_size
=
0
# make store() do work in sync way
Zb
.
_cache
.
max_size
=
0
# make store() do work in sync way
txn
=
transaction
.
Transaction
()
self
.
assertRaises
(
ReadOnlyError
,
Zb
.
tpc_begin
,
txn
)
self
.
assertRaises
(
ReadOnlyError
,
Zb
.
new_oid
)
...
...
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