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
Xavier Thompson
neoppod
Commits
50d99997
Commit
50d99997
authored
Feb 10, 2012
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add -w/--wait storage parameter, to wait for backend to be available.
parent
6f2ee50e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
34 additions
and
11 deletions
+34
-11
neo/lib/config.py
neo/lib/config.py
+3
-0
neo/scripts/neostorage.py
neo/scripts/neostorage.py
+3
-0
neo/storage/app.py
neo/storage/app.py
+1
-1
neo/storage/database/btree.py
neo/storage/database/btree.py
+2
-2
neo/storage/database/manager.py
neo/storage/database/manager.py
+2
-1
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+18
-3
neo/tests/storage/testReplication.py
neo/tests/storage/testReplication.py
+1
-1
neo/tests/storage/testStorageBTree.py
neo/tests/storage/testStorageBTree.py
+1
-1
neo/tests/storage/testStorageMySQLdb.py
neo/tests/storage/testStorageMySQLdb.py
+3
-2
No files found.
neo/lib/config.py
View file @
50d99997
...
@@ -59,6 +59,9 @@ class ConfigurationManager(object):
...
@@ -59,6 +59,9 @@ class ConfigurationManager(object):
def
getDatabase
(
self
):
def
getDatabase
(
self
):
return
self
.
__get
(
'database'
)
return
self
.
__get
(
'database'
)
def
getWait
(
self
):
return
self
.
__get
(
'wait'
)
def
getDynamicMasterList
(
self
):
def
getDynamicMasterList
(
self
):
return
self
.
__get
(
'dynamic_master_list'
,
optional
=
True
)
return
self
.
__get
(
'dynamic_master_list'
,
optional
=
True
)
...
...
neo/scripts/neostorage.py
View file @
50d99997
...
@@ -42,6 +42,8 @@ parser.add_option('-a', '--adapter', help = 'database adapter to use')
...
@@ -42,6 +42,8 @@ parser.add_option('-a', '--adapter', help = 'database adapter to use')
parser
.
add_option
(
'-d'
,
'--database'
,
help
=
'database connections string'
)
parser
.
add_option
(
'-d'
,
'--database'
,
help
=
'database connections string'
)
parser
.
add_option
(
'-D'
,
'--dynamic-master-list'
,
help
=
'path of the file '
parser
.
add_option
(
'-D'
,
'--dynamic-master-list'
,
help
=
'path of the file '
'containing dynamic master node list'
)
'containing dynamic master node list'
)
parser
.
add_option
(
'-w'
,
'--wait'
,
help
=
'seconds to wait for backend to be '
'available, before erroring-out (-1 = infinite)'
,
type
=
'float'
,
default
=
0
)
defaults
=
dict
(
defaults
=
dict
(
name
=
'storage'
,
name
=
'storage'
,
...
@@ -61,6 +63,7 @@ def main(args=None):
...
@@ -61,6 +63,7 @@ def main(args=None):
database
=
options
.
database
,
database
=
options
.
database
,
reset
=
options
.
reset
,
reset
=
options
.
reset
,
adapter
=
options
.
adapter
,
adapter
=
options
.
adapter
,
wait
=
options
.
wait
,
)
)
config
=
ConfigurationManager
(
config
=
ConfigurationManager
(
defaults
,
defaults
,
...
...
neo/storage/app.py
View file @
50d99997
...
@@ -49,7 +49,7 @@ class Application(object):
...
@@ -49,7 +49,7 @@ class Application(object):
self
.
nm
=
NodeManager
(
config
.
getDynamicMasterList
())
self
.
nm
=
NodeManager
(
config
.
getDynamicMasterList
())
self
.
tm
=
TransactionManager
(
self
)
self
.
tm
=
TransactionManager
(
self
)
self
.
dm
=
buildDatabaseManager
(
config
.
getAdapter
(),
self
.
dm
=
buildDatabaseManager
(
config
.
getAdapter
(),
(
config
.
getDatabase
(),
)
(
config
.
getDatabase
(),
config
.
getWait
()
)
)
)
# load master nodes
# load master nodes
...
...
neo/storage/database/btree.py
View file @
50d99997
...
@@ -121,8 +121,8 @@ def safeIter(func, *args, **kw):
...
@@ -121,8 +121,8 @@ def safeIter(func, *args, **kw):
class
BTreeDatabaseManager
(
DatabaseManager
):
class
BTreeDatabaseManager
(
DatabaseManager
):
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
,
wait
):
super
(
BTreeDatabaseManager
,
self
).
__init__
(
database
)
super
(
BTreeDatabaseManager
,
self
).
__init__
(
database
,
wait
)
self
.
setup
(
reset
=
1
)
self
.
setup
(
reset
=
1
)
@
property
@
property
...
...
neo/storage/database/manager.py
View file @
50d99997
...
@@ -25,11 +25,12 @@ class CreationUndone(Exception):
...
@@ -25,11 +25,12 @@ class CreationUndone(Exception):
class
DatabaseManager
(
object
):
class
DatabaseManager
(
object
):
"""This class only describes an interface for database managers."""
"""This class only describes an interface for database managers."""
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
,
wait
):
"""
"""
Initialize the object.
Initialize the object.
"""
"""
self
.
_under_transaction
=
False
self
.
_under_transaction
=
False
self
.
_wait
=
wait
self
.
_parse
(
database
)
self
.
_parse
(
database
)
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
...
...
neo/storage/database/mysqldb.py
View file @
50d99997
...
@@ -25,6 +25,7 @@ from array import array
...
@@ -25,6 +25,7 @@ from array import array
from
hashlib
import
sha1
from
hashlib
import
sha1
import
re
import
re
import
string
import
string
import
time
from
.
import
DatabaseManager
from
.
import
DatabaseManager
from
.manager
import
CreationUndone
from
.manager
import
CreationUndone
...
@@ -55,8 +56,8 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -55,8 +56,8 @@ class MySQLDatabaseManager(DatabaseManager):
# (tested with testOudatedCellsOnDownStorage).
# (tested with testOudatedCellsOnDownStorage).
_use_partition
=
False
_use_partition
=
False
def
__init__
(
self
,
database
):
def
__init__
(
self
,
database
,
wait
):
super
(
MySQLDatabaseManager
,
self
).
__init__
(
database
)
super
(
MySQLDatabaseManager
,
self
).
__init__
(
database
,
wait
)
self
.
conn
=
None
self
.
conn
=
None
self
.
_config
=
{}
self
.
_config
=
{}
self
.
_connect
()
self
.
_connect
()
...
@@ -79,7 +80,21 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -79,7 +80,21 @@ class MySQLDatabaseManager(DatabaseManager):
neo
.
lib
.
logging
.
info
(
neo
.
lib
.
logging
.
info
(
'connecting to MySQL on the database %s with user %s'
,
'connecting to MySQL on the database %s with user %s'
,
self
.
db
,
self
.
user
)
self
.
db
,
self
.
user
)
self
.
conn
=
MySQLdb
.
connect
(
**
kwd
)
if
self
.
_wait
<
0
:
timeout_at
=
None
else
:
timeout_at
=
time
.
time
()
+
self
.
_wait
while
True
:
try
:
self
.
conn
=
MySQLdb
.
connect
(
**
kwd
)
except
Exception
:
if
timeout_at
is
not
None
and
time
.
time
()
>=
timeout_at
:
raise
neo
.
lib
.
logging
.
exception
(
'Connection to MySQL failed, '
'retrying.'
)
time
.
sleep
(
1
)
else
:
break
self
.
conn
.
autocommit
(
False
)
self
.
conn
.
autocommit
(
False
)
self
.
conn
.
query
(
"SET SESSION group_concat_max_len = -1"
)
self
.
conn
.
query
(
"SET SESSION group_concat_max_len = -1"
)
self
.
conn
.
set_sql_mode
(
"TRADITIONAL,NO_ENGINE_SUBSTITUTION"
)
self
.
conn
.
set_sql_mode
(
"TRADITIONAL,NO_ENGINE_SUBSTITUTION"
)
...
...
neo/tests/storage/testReplication.py
View file @
50d99997
...
@@ -118,7 +118,7 @@ class ReplicationTests(NeoUnitTestBase):
...
@@ -118,7 +118,7 @@ class ReplicationTests(NeoUnitTestBase):
def
buildStorage
(
self
,
transactions
,
objects
,
name
=
'BTree'
,
database
=
None
):
def
buildStorage
(
self
,
transactions
,
objects
,
name
=
'BTree'
,
database
=
None
):
def
makeid
(
oid_or_tid
):
def
makeid
(
oid_or_tid
):
return
pack
(
'!Q'
,
oid_or_tid
)
return
pack
(
'!Q'
,
oid_or_tid
)
storage
=
buildDatabaseManager
(
name
,
(
database
,
))
storage
=
buildDatabaseManager
(
name
,
(
database
,
0
))
storage
.
setup
(
reset
=
True
)
storage
.
setup
(
reset
=
True
)
storage
.
setNumPartitions
(
1
)
storage
.
setNumPartitions
(
1
)
storage
.
_transactions
=
transactions
storage
.
_transactions
=
transactions
...
...
neo/tests/storage/testStorageBTree.py
View file @
50d99997
...
@@ -24,7 +24,7 @@ class StorageBTreeTests(StorageDBTests):
...
@@ -24,7 +24,7 @@ class StorageBTreeTests(StorageDBTests):
def
getDB
(
self
,
reset
=
0
):
def
getDB
(
self
,
reset
=
0
):
# db manager
# db manager
db
=
BTreeDatabaseManager
(
''
)
db
=
BTreeDatabaseManager
(
''
,
0
)
db
.
setup
(
reset
)
db
.
setup
(
reset
)
return
db
return
db
...
...
neo/tests/storage/testStorageMySQLdb.py
View file @
50d99997
...
@@ -31,7 +31,7 @@ class StorageMySQSLdbTests(StorageDBTests):
...
@@ -31,7 +31,7 @@ class StorageMySQSLdbTests(StorageDBTests):
self
.
prepareDatabase
(
number
=
1
,
prefix
=
NEO_SQL_DATABASE
[:
-
1
])
self
.
prepareDatabase
(
number
=
1
,
prefix
=
NEO_SQL_DATABASE
[:
-
1
])
# db manager
# db manager
database
=
'%s@%s'
%
(
NEO_SQL_USER
,
NEO_SQL_DATABASE
)
database
=
'%s@%s'
%
(
NEO_SQL_USER
,
NEO_SQL_DATABASE
)
db
=
MySQLDatabaseManager
(
database
)
db
=
MySQLDatabaseManager
(
database
,
0
)
db
.
setup
(
reset
)
db
.
setup
(
reset
)
return
db
return
db
...
@@ -41,7 +41,8 @@ class StorageMySQSLdbTests(StorageDBTests):
...
@@ -41,7 +41,8 @@ class StorageMySQSLdbTests(StorageDBTests):
call
.
checkArgs
(
'BEGIN'
)
call
.
checkArgs
(
'BEGIN'
)
def
test_MySQLDatabaseManagerInit
(
self
):
def
test_MySQLDatabaseManagerInit
(
self
):
db
=
MySQLDatabaseManager
(
'%s@%s'
%
(
NEO_SQL_USER
,
NEO_SQL_DATABASE
))
db
=
MySQLDatabaseManager
(
'%s@%s'
%
(
NEO_SQL_USER
,
NEO_SQL_DATABASE
),
0
)
# init
# init
self
.
assertEqual
(
db
.
db
,
NEO_SQL_DATABASE
)
self
.
assertEqual
(
db
.
db
,
NEO_SQL_DATABASE
)
self
.
assertEqual
(
db
.
user
,
NEO_SQL_USER
)
self
.
assertEqual
(
db
.
user
,
NEO_SQL_USER
)
...
...
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