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
b70de293
Commit
b70de293
authored
Aug 26, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: code clean up
parent
769f4ef8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
34 deletions
+12
-34
neo/client/Storage.py
neo/client/Storage.py
+9
-31
neo/client/app.py
neo/client/app.py
+3
-3
No files found.
neo/client/Storage.py
View file @
b70de293
...
...
@@ -49,8 +49,7 @@ class Storage(BaseStorage.BaseStorage,
)))
def
__init__
(
self
,
master_nodes
,
name
,
read_only
=
False
,
compress
=
None
,
logfile
=
None
,
_app
=
None
,
dynamic_master_list
=
None
,
**
kw
):
compress
=
None
,
logfile
=
None
,
_app
=
None
,
**
kw
):
"""
Do not pass those parameters (used internally):
_app
...
...
@@ -63,17 +62,8 @@ class Storage(BaseStorage.BaseStorage,
# Warning: _is_read_only is used in BaseStorage, do not rename it.
self
.
_is_read_only
=
read_only
if
_app
is
None
:
_app
=
Application
(
master_nodes
,
name
,
compress
=
compress
,
dynamic_master_list
=
dynamic_master_list
)
_app
=
Application
(
master_nodes
,
name
,
compress
=
compress
,
**
kw
)
self
.
app
=
_app
# Used to clone self (see new_instance & IMVCCStorage definition).
self
.
_init_args
=
(
master_nodes
,
name
)
self
.
_init_kw
=
{
'read_only'
:
read_only
,
'compress'
:
compress
,
'dynamic_master_list'
:
dynamic_master_list
,
'_app'
:
_app
,
}
@
property
def
_cache
(
self
):
...
...
@@ -105,27 +95,23 @@ class Storage(BaseStorage.BaseStorage,
"""
Note: never blocks in NEO.
"""
return
self
.
app
.
tpc_begin
(
transaction
=
transaction
,
tid
=
tid
,
status
=
status
)
return
self
.
app
.
tpc_begin
(
transaction
,
tid
,
status
)
@
check_read_only
def
tpc_vote
(
self
,
transaction
):
return
self
.
app
.
tpc_vote
(
transaction
=
transaction
,
tryToResolveConflict
=
self
.
tryToResolveConflict
)
return
self
.
app
.
tpc_vote
(
transaction
,
self
.
tryToResolveConflict
)
@
check_read_only
def
tpc_abort
(
self
,
transaction
):
return
self
.
app
.
tpc_abort
(
transaction
=
transaction
)
return
self
.
app
.
tpc_abort
(
transaction
)
def
tpc_finish
(
self
,
transaction
,
f
=
None
):
return
self
.
app
.
tpc_finish
(
transaction
=
transaction
,
tryToResolveConflict
=
self
.
tryToResolveConflict
,
f
=
f
)
return
self
.
app
.
tpc_finish
(
transaction
,
self
.
tryToResolveConflict
,
f
)
@
check_read_only
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
assert
version
==
''
,
'Versions are not supported'
return
self
.
app
.
store
(
oid
=
oid
,
serial
=
serial
,
data
=
data
,
version
=
version
,
transaction
=
transaction
)
return
self
.
app
.
store
(
oid
,
serial
,
data
,
version
,
transaction
)
@
check_read_only
def
deleteObject
(
self
,
oid
,
serial
,
transaction
):
...
...
@@ -149,10 +135,8 @@ class Storage(BaseStorage.BaseStorage,
def
iterator
(
self
,
start
=
None
,
stop
=
None
):
# Iterator lives in its own transaction, so get a fresh snapshot.
snapshot_tid
=
self
.
lastTransaction
()
if
stop
is
None
:
if
not
stop
or
snapshot_tid
<
stop
:
stop
=
snapshot_tid
else
:
stop
=
min
(
snapshot_tid
,
stop
)
return
self
.
app
.
iterator
(
start
,
stop
)
# undo
...
...
@@ -186,7 +170,7 @@ class Storage(BaseStorage.BaseStorage,
return
data
,
serial
,
''
def
__len__
(
self
):
return
self
.
app
.
get
StorageSize
()
return
self
.
app
.
get
ObjectCount
()
def
registerDB
(
self
,
db
,
limit
=
None
):
self
.
app
.
registerDB
(
db
,
limit
)
...
...
@@ -213,9 +197,6 @@ class Storage(BaseStorage.BaseStorage,
return
self
.
app
.
importFrom
(
source
,
start
,
stop
,
self
.
tryToResolveConflict
,
preindex
)
def
restore
(
self
,
oid
,
serial
,
data
,
version
,
prev_txn
,
transaction
):
raise
NotImplementedError
def
pack
(
self
,
t
,
referencesf
,
gc
=
False
):
if
gc
:
logging
.
warning
(
'Garbage Collection is not available in NEO,'
...
...
@@ -253,6 +234,3 @@ class Storage(BaseStorage.BaseStorage,
def
checkCurrentSerialInTransaction
(
self
,
oid
,
serial
,
transaction
):
self
.
app
.
checkCurrentSerialInTransaction
(
oid
,
serial
,
transaction
)
def
new_instance
(
self
):
return
Storage
(
*
self
.
_init_args
,
**
self
.
_init_kw
)
neo/client/app.py
View file @
b70de293
...
...
@@ -70,7 +70,7 @@ class Application(object):
"""The client node application."""
def
__init__
(
self
,
master_nodes
,
name
,
compress
=
True
,
dynamic_master_list
=
None
,
**
kw
):
dynamic_master_list
=
None
):
# Start polling thread
self
.
em
=
EventManager
()
self
.
poll_thread
=
ThreadedPoll
(
self
.
em
,
name
=
name
)
...
...
@@ -368,8 +368,8 @@ class Application(object):
finally
:
self
.
_oid_lock_release
()
def
get
StorageSize
(
self
):
# return the last OID used, this is in
na
curate
def
get
ObjectCount
(
self
):
# return the last OID used, this is in
ac
curate
return
int
(
u64
(
self
.
last_oid
))
@
profiler_decorator
...
...
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