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
Vincent Pelletier
neoppod
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,
...
@@ -49,8 +49,7 @@ class Storage(BaseStorage.BaseStorage,
)))
)))
def
__init__
(
self
,
master_nodes
,
name
,
read_only
=
False
,
def
__init__
(
self
,
master_nodes
,
name
,
read_only
=
False
,
compress
=
None
,
logfile
=
None
,
_app
=
None
,
compress
=
None
,
logfile
=
None
,
_app
=
None
,
**
kw
):
dynamic_master_list
=
None
,
**
kw
):
"""
"""
Do not pass those parameters (used internally):
Do not pass those parameters (used internally):
_app
_app
...
@@ -63,17 +62,8 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -63,17 +62,8 @@ class Storage(BaseStorage.BaseStorage,
# Warning: _is_read_only is used in BaseStorage, do not rename it.
# Warning: _is_read_only is used in BaseStorage, do not rename it.
self
.
_is_read_only
=
read_only
self
.
_is_read_only
=
read_only
if
_app
is
None
:
if
_app
is
None
:
_app
=
Application
(
master_nodes
,
name
,
compress
=
compress
,
_app
=
Application
(
master_nodes
,
name
,
compress
=
compress
,
**
kw
)
dynamic_master_list
=
dynamic_master_list
)
self
.
app
=
_app
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
@
property
def
_cache
(
self
):
def
_cache
(
self
):
...
@@ -105,27 +95,23 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -105,27 +95,23 @@ class Storage(BaseStorage.BaseStorage,
"""
"""
Note: never blocks in NEO.
Note: never blocks in NEO.
"""
"""
return
self
.
app
.
tpc_begin
(
transaction
=
transaction
,
tid
=
tid
,
return
self
.
app
.
tpc_begin
(
transaction
,
tid
,
status
)
status
=
status
)
@
check_read_only
@
check_read_only
def
tpc_vote
(
self
,
transaction
):
def
tpc_vote
(
self
,
transaction
):
return
self
.
app
.
tpc_vote
(
transaction
=
transaction
,
return
self
.
app
.
tpc_vote
(
transaction
,
self
.
tryToResolveConflict
)
tryToResolveConflict
=
self
.
tryToResolveConflict
)
@
check_read_only
@
check_read_only
def
tpc_abort
(
self
,
transaction
):
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
):
def
tpc_finish
(
self
,
transaction
,
f
=
None
):
return
self
.
app
.
tpc_finish
(
transaction
=
transaction
,
return
self
.
app
.
tpc_finish
(
transaction
,
self
.
tryToResolveConflict
,
f
)
tryToResolveConflict
=
self
.
tryToResolveConflict
,
f
=
f
)
@
check_read_only
@
check_read_only
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
def
store
(
self
,
oid
,
serial
,
data
,
version
,
transaction
):
assert
version
==
''
,
'Versions are not supported'
assert
version
==
''
,
'Versions are not supported'
return
self
.
app
.
store
(
oid
=
oid
,
serial
=
serial
,
return
self
.
app
.
store
(
oid
,
serial
,
data
,
version
,
transaction
)
data
=
data
,
version
=
version
,
transaction
=
transaction
)
@
check_read_only
@
check_read_only
def
deleteObject
(
self
,
oid
,
serial
,
transaction
):
def
deleteObject
(
self
,
oid
,
serial
,
transaction
):
...
@@ -149,10 +135,8 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -149,10 +135,8 @@ class Storage(BaseStorage.BaseStorage,
def
iterator
(
self
,
start
=
None
,
stop
=
None
):
def
iterator
(
self
,
start
=
None
,
stop
=
None
):
# Iterator lives in its own transaction, so get a fresh snapshot.
# Iterator lives in its own transaction, so get a fresh snapshot.
snapshot_tid
=
self
.
lastTransaction
()
snapshot_tid
=
self
.
lastTransaction
()
if
stop
is
None
:
if
not
stop
or
snapshot_tid
<
stop
:
stop
=
snapshot_tid
stop
=
snapshot_tid
else
:
stop
=
min
(
snapshot_tid
,
stop
)
return
self
.
app
.
iterator
(
start
,
stop
)
return
self
.
app
.
iterator
(
start
,
stop
)
# undo
# undo
...
@@ -186,7 +170,7 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -186,7 +170,7 @@ class Storage(BaseStorage.BaseStorage,
return
data
,
serial
,
''
return
data
,
serial
,
''
def
__len__
(
self
):
def
__len__
(
self
):
return
self
.
app
.
get
StorageSize
()
return
self
.
app
.
get
ObjectCount
()
def
registerDB
(
self
,
db
,
limit
=
None
):
def
registerDB
(
self
,
db
,
limit
=
None
):
self
.
app
.
registerDB
(
db
,
limit
)
self
.
app
.
registerDB
(
db
,
limit
)
...
@@ -213,9 +197,6 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -213,9 +197,6 @@ class Storage(BaseStorage.BaseStorage,
return
self
.
app
.
importFrom
(
source
,
start
,
stop
,
return
self
.
app
.
importFrom
(
source
,
start
,
stop
,
self
.
tryToResolveConflict
,
preindex
)
self
.
tryToResolveConflict
,
preindex
)
def
restore
(
self
,
oid
,
serial
,
data
,
version
,
prev_txn
,
transaction
):
raise
NotImplementedError
def
pack
(
self
,
t
,
referencesf
,
gc
=
False
):
def
pack
(
self
,
t
,
referencesf
,
gc
=
False
):
if
gc
:
if
gc
:
logging
.
warning
(
'Garbage Collection is not available in NEO,'
logging
.
warning
(
'Garbage Collection is not available in NEO,'
...
@@ -253,6 +234,3 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -253,6 +234,3 @@ class Storage(BaseStorage.BaseStorage,
def
checkCurrentSerialInTransaction
(
self
,
oid
,
serial
,
transaction
):
def
checkCurrentSerialInTransaction
(
self
,
oid
,
serial
,
transaction
):
self
.
app
.
checkCurrentSerialInTransaction
(
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):
...
@@ -70,7 +70,7 @@ class Application(object):
"""The client node application."""
"""The client node application."""
def
__init__
(
self
,
master_nodes
,
name
,
compress
=
True
,
def
__init__
(
self
,
master_nodes
,
name
,
compress
=
True
,
dynamic_master_list
=
None
,
**
kw
):
dynamic_master_list
=
None
):
# Start polling thread
# Start polling thread
self
.
em
=
EventManager
()
self
.
em
=
EventManager
()
self
.
poll_thread
=
ThreadedPoll
(
self
.
em
,
name
=
name
)
self
.
poll_thread
=
ThreadedPoll
(
self
.
em
,
name
=
name
)
...
@@ -368,8 +368,8 @@ class Application(object):
...
@@ -368,8 +368,8 @@ class Application(object):
finally
:
finally
:
self
.
_oid_lock_release
()
self
.
_oid_lock_release
()
def
get
StorageSize
(
self
):
def
get
ObjectCount
(
self
):
# return the last OID used, this is in
na
curate
# return the last OID used, this is in
ac
curate
return
int
(
u64
(
self
.
last_oid
))
return
int
(
u64
(
self
.
last_oid
))
@
profiler_decorator
@
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