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
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
Stefane Fermigier
neo
Commits
1d11287f
Commit
1d11287f
authored
Jun 20, 2014
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: more refactoring of backends
parent
e76af297
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
29 deletions
+13
-29
neo/storage/database/manager.py
neo/storage/database/manager.py
+3
-8
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+1
-7
neo/storage/database/sqlite.py
neo/storage/database/sqlite.py
+1
-7
neo/storage/handlers/initialization.py
neo/storage/handlers/initialization.py
+1
-1
neo/tests/storage/testStorageDBTests.py
neo/tests/storage/testStorageDBTests.py
+7
-6
No files found.
neo/storage/database/manager.py
View file @
1d11287f
...
...
@@ -244,17 +244,12 @@ class DatabaseManager(object):
# See if object exists at all
return
self
.
_getObject
(
oid
)
and
False
def
changePartitionTable
(
self
,
ptid
,
cell_list
):
def
changePartitionTable
(
self
,
ptid
,
cell_list
,
reset
=
False
):
"""Change a part of a partition table. The list of cells is
a tuple of tuples, each of which consists of an offset (row ID),
the NID of a storage node, and a cell state. The Partition
Table ID must be stored as well."""
raise
NotImplementedError
def
setPartitionTable
(
self
,
ptid
,
cell_list
):
"""Set a whole partition table. The semantics is the same as
changePartitionTable, except that existing data must be
thrown away."""
Table ID must be stored as well. If reset is True, existing data
is first thrown away."""
raise
NotImplementedError
def
dropPartitions
(
self
,
offset_list
):
...
...
neo/storage/database/mysqldb.py
View file @
1d11287f
...
...
@@ -306,7 +306,7 @@ class MySQLDatabaseManager(DatabaseManager):
return
(
serial
,
r
[
0
][
0
]
if
r
else
None
,
compression
,
checksum
,
data
,
value_serial
)
def
doSetPartitionTable
(
self
,
ptid
,
cell_list
,
reset
):
def
changePartitionTable
(
self
,
ptid
,
cell_list
,
reset
=
False
):
offset_list
=
[]
q
=
self
.
query
if
reset
:
...
...
@@ -334,12 +334,6 @@ class MySQLDatabaseManager(DatabaseManager):
if
code
!=
1517
:
# duplicate partition name
raise
def
changePartitionTable
(
self
,
ptid
,
cell_list
):
self
.
doSetPartitionTable
(
ptid
,
cell_list
,
False
)
def
setPartitionTable
(
self
,
ptid
,
cell_list
):
self
.
doSetPartitionTable
(
ptid
,
cell_list
,
True
)
def
dropPartitions
(
self
,
offset_list
):
q
=
self
.
query
# XXX: these queries are inefficient (execution time increase with
...
...
neo/storage/database/sqlite.py
View file @
1d11287f
...
...
@@ -271,7 +271,7 @@ class SQLiteDatabaseManager(DatabaseManager):
data
=
str
(
data
)
return
serial
,
r
and
r
[
0
],
compression
,
checksum
,
data
,
value_serial
def
doSetPartitionTable
(
self
,
ptid
,
cell_list
,
reset
):
def
changePartitionTable
(
self
,
ptid
,
cell_list
,
reset
=
False
):
q
=
self
.
query
if
reset
:
q
(
"DELETE FROM pt"
)
...
...
@@ -288,12 +288,6 @@ class SQLiteDatabaseManager(DatabaseManager):
(
offset
,
nid
,
int
(
state
)))
self
.
setPTID
(
ptid
)
def
changePartitionTable
(
self
,
ptid
,
cell_list
):
self
.
doSetPartitionTable
(
ptid
,
cell_list
,
False
)
def
setPartitionTable
(
self
,
ptid
,
cell_list
):
self
.
doSetPartitionTable
(
ptid
,
cell_list
,
True
)
def
dropPartitions
(
self
,
offset_list
):
where
=
" WHERE partition=?"
q
=
self
.
query
...
...
neo/storage/handlers/initialization.py
View file @
1d11287f
...
...
@@ -44,7 +44,7 @@ class InitializationHandler(BaseMasterHandler):
logging
.
debug
(
'drop data for partitions %r'
,
unassigned_set
)
app
.
dm
.
dropPartitions
(
unassigned_set
)
app
.
dm
.
setPartitionTable
(
ptid
,
cell_list
)
app
.
dm
.
changePartitionTable
(
ptid
,
cell_list
,
reset
=
True
)
def
notifyPartitionChanges
(
self
,
conn
,
ptid
,
cell_list
):
# XXX: This is safe to ignore those notifications because all of the
...
...
neo/tests/storage/testStorageDBTests.py
View file @
1d11287f
...
...
@@ -68,8 +68,9 @@ class StorageDBTests(NeoUnitTestBase):
uuid
=
self
.
getStorageUUID
()
db
.
setUUID
(
uuid
)
self
.
assertEqual
(
uuid
,
db
.
getUUID
())
db
.
setPartitionTable
(
1
,
[(
i
,
uuid
,
CellStates
.
UP_TO_DATE
)
for
i
in
xrange
(
num_partitions
)])
db
.
changePartitionTable
(
1
,
[(
i
,
uuid
,
CellStates
.
UP_TO_DATE
)
for
i
in
xrange
(
num_partitions
)],
reset
=
True
)
def
checkConfigEntry
(
self
,
get_call
,
set_call
,
value
):
# generic test for all configuration entries accessors
...
...
@@ -97,7 +98,7 @@ class StorageDBTests(NeoUnitTestBase):
uuid1
,
uuid2
=
self
.
getStorageUUID
(),
self
.
getStorageUUID
()
cell1
=
(
0
,
uuid1
,
CellStates
.
OUT_OF_DATE
)
cell2
=
(
1
,
uuid1
,
CellStates
.
UP_TO_DATE
)
db
.
setPartitionTable
(
ptid
,
[
cell1
,
cell2
]
)
db
.
changePartitionTable
(
ptid
,
[
cell1
,
cell2
],
1
)
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
set
(
result
),
{
cell1
,
cell2
})
...
...
@@ -225,15 +226,15 @@ class StorageDBTests(NeoUnitTestBase):
# no partition table
self
.
assertEqual
(
list
(
db
.
getPartitionTable
()),
[])
# set one
db
.
setPartitionTable
(
ptid
,
[
cell1
]
)
db
.
changePartitionTable
(
ptid
,
[
cell1
],
1
)
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
list
(
result
),
[
cell1
])
# then another
db
.
setPartitionTable
(
ptid
,
[
cell2
]
)
db
.
changePartitionTable
(
ptid
,
[
cell2
],
1
)
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
list
(
result
),
[
cell2
])
# drop discarded cells
db
.
setPartitionTable
(
ptid
,
[
cell2
,
cell3
]
)
db
.
changePartitionTable
(
ptid
,
[
cell2
,
cell3
],
1
)
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
list
(
result
),
[])
...
...
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