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
Ivan Tyagov
neoppod
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):
...
@@ -244,17 +244,12 @@ class DatabaseManager(object):
# See if object exists at all
# See if object exists at all
return
self
.
_getObject
(
oid
)
and
False
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
"""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),
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
the NID of a storage node, and a cell state. The Partition
Table ID must be stored as well."""
Table ID must be stored as well. If reset is True, existing data
raise
NotImplementedError
is first thrown away."""
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."""
raise
NotImplementedError
raise
NotImplementedError
def
dropPartitions
(
self
,
offset_list
):
def
dropPartitions
(
self
,
offset_list
):
...
...
neo/storage/database/mysqldb.py
View file @
1d11287f
...
@@ -306,7 +306,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -306,7 +306,7 @@ class MySQLDatabaseManager(DatabaseManager):
return
(
serial
,
r
[
0
][
0
]
if
r
else
None
,
compression
,
checksum
,
data
,
return
(
serial
,
r
[
0
][
0
]
if
r
else
None
,
compression
,
checksum
,
data
,
value_serial
)
value_serial
)
def
doSetPartitionTable
(
self
,
ptid
,
cell_list
,
reset
):
def
changePartitionTable
(
self
,
ptid
,
cell_list
,
reset
=
False
):
offset_list
=
[]
offset_list
=
[]
q
=
self
.
query
q
=
self
.
query
if
reset
:
if
reset
:
...
@@ -334,12 +334,6 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -334,12 +334,6 @@ class MySQLDatabaseManager(DatabaseManager):
if
code
!=
1517
:
# duplicate partition name
if
code
!=
1517
:
# duplicate partition name
raise
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
):
def
dropPartitions
(
self
,
offset_list
):
q
=
self
.
query
q
=
self
.
query
# XXX: these queries are inefficient (execution time increase with
# XXX: these queries are inefficient (execution time increase with
...
...
neo/storage/database/sqlite.py
View file @
1d11287f
...
@@ -271,7 +271,7 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -271,7 +271,7 @@ class SQLiteDatabaseManager(DatabaseManager):
data
=
str
(
data
)
data
=
str
(
data
)
return
serial
,
r
and
r
[
0
],
compression
,
checksum
,
data
,
value_serial
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
q
=
self
.
query
if
reset
:
if
reset
:
q
(
"DELETE FROM pt"
)
q
(
"DELETE FROM pt"
)
...
@@ -288,12 +288,6 @@ class SQLiteDatabaseManager(DatabaseManager):
...
@@ -288,12 +288,6 @@ class SQLiteDatabaseManager(DatabaseManager):
(
offset
,
nid
,
int
(
state
)))
(
offset
,
nid
,
int
(
state
)))
self
.
setPTID
(
ptid
)
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
):
def
dropPartitions
(
self
,
offset_list
):
where
=
" WHERE partition=?"
where
=
" WHERE partition=?"
q
=
self
.
query
q
=
self
.
query
...
...
neo/storage/handlers/initialization.py
View file @
1d11287f
...
@@ -44,7 +44,7 @@ class InitializationHandler(BaseMasterHandler):
...
@@ -44,7 +44,7 @@ class InitializationHandler(BaseMasterHandler):
logging
.
debug
(
'drop data for partitions %r'
,
unassigned_set
)
logging
.
debug
(
'drop data for partitions %r'
,
unassigned_set
)
app
.
dm
.
dropPartitions
(
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
):
def
notifyPartitionChanges
(
self
,
conn
,
ptid
,
cell_list
):
# XXX: This is safe to ignore those notifications because all of the
# 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):
...
@@ -68,8 +68,9 @@ class StorageDBTests(NeoUnitTestBase):
uuid
=
self
.
getStorageUUID
()
uuid
=
self
.
getStorageUUID
()
db
.
setUUID
(
uuid
)
db
.
setUUID
(
uuid
)
self
.
assertEqual
(
uuid
,
db
.
getUUID
())
self
.
assertEqual
(
uuid
,
db
.
getUUID
())
db
.
setPartitionTable
(
1
,
db
.
changePartitionTable
(
1
,
[(
i
,
uuid
,
CellStates
.
UP_TO_DATE
)
for
i
in
xrange
(
num_partitions
)])
[(
i
,
uuid
,
CellStates
.
UP_TO_DATE
)
for
i
in
xrange
(
num_partitions
)],
reset
=
True
)
def
checkConfigEntry
(
self
,
get_call
,
set_call
,
value
):
def
checkConfigEntry
(
self
,
get_call
,
set_call
,
value
):
# generic test for all configuration entries accessors
# generic test for all configuration entries accessors
...
@@ -97,7 +98,7 @@ class StorageDBTests(NeoUnitTestBase):
...
@@ -97,7 +98,7 @@ class StorageDBTests(NeoUnitTestBase):
uuid1
,
uuid2
=
self
.
getStorageUUID
(),
self
.
getStorageUUID
()
uuid1
,
uuid2
=
self
.
getStorageUUID
(),
self
.
getStorageUUID
()
cell1
=
(
0
,
uuid1
,
CellStates
.
OUT_OF_DATE
)
cell1
=
(
0
,
uuid1
,
CellStates
.
OUT_OF_DATE
)
cell2
=
(
1
,
uuid1
,
CellStates
.
UP_TO_DATE
)
cell2
=
(
1
,
uuid1
,
CellStates
.
UP_TO_DATE
)
db
.
setPartitionTable
(
ptid
,
[
cell1
,
cell2
]
)
db
.
changePartitionTable
(
ptid
,
[
cell1
,
cell2
],
1
)
result
=
db
.
getPartitionTable
()
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
set
(
result
),
{
cell1
,
cell2
})
self
.
assertEqual
(
set
(
result
),
{
cell1
,
cell2
})
...
@@ -225,15 +226,15 @@ class StorageDBTests(NeoUnitTestBase):
...
@@ -225,15 +226,15 @@ class StorageDBTests(NeoUnitTestBase):
# no partition table
# no partition table
self
.
assertEqual
(
list
(
db
.
getPartitionTable
()),
[])
self
.
assertEqual
(
list
(
db
.
getPartitionTable
()),
[])
# set one
# set one
db
.
setPartitionTable
(
ptid
,
[
cell1
]
)
db
.
changePartitionTable
(
ptid
,
[
cell1
],
1
)
result
=
db
.
getPartitionTable
()
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
list
(
result
),
[
cell1
])
self
.
assertEqual
(
list
(
result
),
[
cell1
])
# then another
# then another
db
.
setPartitionTable
(
ptid
,
[
cell2
]
)
db
.
changePartitionTable
(
ptid
,
[
cell2
],
1
)
result
=
db
.
getPartitionTable
()
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
list
(
result
),
[
cell2
])
self
.
assertEqual
(
list
(
result
),
[
cell2
])
# drop discarded cells
# drop discarded cells
db
.
setPartitionTable
(
ptid
,
[
cell2
,
cell3
]
)
db
.
changePartitionTable
(
ptid
,
[
cell2
,
cell3
],
1
)
result
=
db
.
getPartitionTable
()
result
=
db
.
getPartitionTable
()
self
.
assertEqual
(
list
(
result
),
[])
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