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
6e32ebb7
Commit
6e32ebb7
authored
Nov 21, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix spelling mistakes
parent
b61f8745
Changes
42
Show whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
85 additions
and
85 deletions
+85
-85
README.rst
README.rst
+1
-1
neo/admin/handler.py
neo/admin/handler.py
+1
-1
neo/client/Storage.py
neo/client/Storage.py
+1
-1
neo/client/__init__.py
neo/client/__init__.py
+1
-1
neo/client/app.py
neo/client/app.py
+3
-3
neo/client/cache.py
neo/client/cache.py
+1
-1
neo/client/handlers/storage.py
neo/client/handlers/storage.py
+1
-1
neo/lib/connection.py
neo/lib/connection.py
+2
-2
neo/lib/connector.py
neo/lib/connector.py
+2
-2
neo/lib/locking.py
neo/lib/locking.py
+2
-2
neo/lib/node.py
neo/lib/node.py
+3
-3
neo/lib/patch.py
neo/lib/patch.py
+1
-1
neo/lib/protocol.py
neo/lib/protocol.py
+5
-5
neo/lib/threaded_app.py
neo/lib/threaded_app.py
+1
-1
neo/lib/util.py
neo/lib/util.py
+1
-1
neo/master/app.py
neo/master/app.py
+3
-3
neo/master/handlers/secondary.py
neo/master/handlers/secondary.py
+1
-1
neo/master/transactions.py
neo/master/transactions.py
+1
-1
neo/neoctl/app.py
neo/neoctl/app.py
+2
-2
neo/scripts/neostorage.py
neo/scripts/neostorage.py
+1
-1
neo/storage/database/manager.py
neo/storage/database/manager.py
+7
-7
neo/storage/database/mysqldb.py
neo/storage/database/mysqldb.py
+2
-2
neo/storage/handlers/client.py
neo/storage/handlers/client.py
+1
-1
neo/storage/handlers/initialization.py
neo/storage/handlers/initialization.py
+1
-1
neo/storage/replicator.py
neo/storage/replicator.py
+1
-1
neo/tests/__init__.py
neo/tests/__init__.py
+4
-4
neo/tests/client/testClientApp.py
neo/tests/client/testClientApp.py
+5
-5
neo/tests/functional/__init__.py
neo/tests/functional/__init__.py
+2
-2
neo/tests/functional/testClient.py
neo/tests/functional/testClient.py
+3
-3
neo/tests/functional/testMaster.py
neo/tests/functional/testMaster.py
+2
-2
neo/tests/functional/testStorage.py
neo/tests/functional/testStorage.py
+2
-2
neo/tests/master/testElectionHandler.py
neo/tests/master/testElectionHandler.py
+1
-1
neo/tests/master/testStorageHandler.py
neo/tests/master/testStorageHandler.py
+1
-1
neo/tests/master/testTransactions.py
neo/tests/master/testTransactions.py
+1
-1
neo/tests/storage/testStorageDBTests.py
neo/tests/storage/testStorageDBTests.py
+4
-4
neo/tests/storage/testTransactions.py
neo/tests/storage/testTransactions.py
+1
-1
neo/tests/testConnection.py
neo/tests/testConnection.py
+1
-1
neo/tests/testNodes.py
neo/tests/testNodes.py
+1
-1
neo/tests/testPT.py
neo/tests/testPT.py
+8
-8
neo/tests/testUtil.py
neo/tests/testUtil.py
+1
-1
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+1
-1
neo/tests/threaded/testReplication.py
neo/tests/threaded/testReplication.py
+1
-1
No files found.
README.rst
View file @
6e32ebb7
...
@@ -34,7 +34,7 @@ ZODB API is fully implemented except:
...
@@ -34,7 +34,7 @@ ZODB API is fully implemented except:
for garbage collection)
for garbage collection)
- blobs: not implemented (not considered yet)
- blobs: not implemented (not considered yet)
Any ZODB like FileStorage can be converted to NEO instanteously,
Any ZODB like FileStorage can be converted to NEO instant
an
eously,
which means the database is operational before all data are imported.
which means the database is operational before all data are imported.
There's also a tool to convert back to FileStorage.
There's also a tool to convert back to FileStorage.
...
...
neo/admin/handler.py
View file @
6e32ebb7
...
@@ -74,7 +74,7 @@ class AdminEventHandler(EventHandler):
...
@@ -74,7 +74,7 @@ class AdminEventHandler(EventHandler):
class
MasterEventHandler
(
EventHandler
):
class
MasterEventHandler
(
EventHandler
):
""" This class is just used to dispa
ct
h message to right handler"""
""" This class is just used to dispa
tc
h message to right handler"""
def
_connectionLost
(
self
,
conn
):
def
_connectionLost
(
self
,
conn
):
app
=
self
.
app
app
=
self
.
app
...
...
neo/client/Storage.py
View file @
6e32ebb7
...
@@ -108,7 +108,7 @@ class Storage(BaseStorage.BaseStorage,
...
@@ -108,7 +108,7 @@ class Storage(BaseStorage.BaseStorage,
def
deleteObject
(
self
,
oid
,
serial
,
transaction
):
def
deleteObject
(
self
,
oid
,
serial
,
transaction
):
self
.
app
.
store
(
oid
,
serial
,
None
,
None
,
transaction
)
self
.
app
.
store
(
oid
,
serial
,
None
,
None
,
transaction
)
# mu
tl
iple revisions
# mu
lt
iple revisions
def
loadSerial
(
self
,
oid
,
serial
):
def
loadSerial
(
self
,
oid
,
serial
):
try
:
try
:
return
self
.
app
.
load
(
oid
,
serial
)[
0
]
return
self
.
app
.
load
(
oid
,
serial
)[
0
]
...
...
neo/client/__init__.py
View file @
6e32ebb7
...
@@ -87,4 +87,4 @@ def patch():
...
@@ -87,4 +87,4 @@ def patch():
patch
()
patch
()
import
app
# set up signal handers early enough to do it in the main thread
import
app
# set up signal hand
l
ers early enough to do it in the main thread
neo/client/app.py
View file @
6e32ebb7
...
@@ -132,7 +132,7 @@ class Application(ThreadedApplication):
...
@@ -132,7 +132,7 @@ class Application(ThreadedApplication):
self
.
_cache_lock_acquire
=
lock
.
acquire
self
.
_cache_lock_acquire
=
lock
.
acquire
self
.
_cache_lock_release
=
lock
.
release
self
.
_cache_lock_release
=
lock
.
release
# _connecting_to_master_node is used to prevent simultaneous master
# _connecting_to_master_node is used to prevent simultaneous master
# node connection attemps
# node connection attemp
t
s
self
.
_connecting_to_master_node
=
Lock
()
self
.
_connecting_to_master_node
=
Lock
()
self
.
compress
=
compress
self
.
compress
=
compress
...
@@ -324,7 +324,7 @@ class Application(ThreadedApplication):
...
@@ -324,7 +324,7 @@ class Application(ThreadedApplication):
object existed, but its creation was undone
object existed, but its creation was undone
Note that loadSerial is used during conflict resolution to load
Note that loadSerial is used during conflict resolution to load
object's current version, which is not visible to us normaly (it was
object's current version, which is not visible to us normal
l
y (it was
committed after our snapshot was taken).
committed after our snapshot was taken).
"""
"""
# TODO:
# TODO:
...
@@ -987,7 +987,7 @@ class Application(ThreadedApplication):
...
@@ -987,7 +987,7 @@ class Application(ThreadedApplication):
queue
=
txn_context
[
'queue'
]
queue
=
txn_context
[
'queue'
]
txn_context
[
'object_stored_counter_dict'
][
oid
]
=
{}
txn_context
[
'object_stored_counter_dict'
][
oid
]
=
{}
# ZODB.Connection performs calls 'checkCurrentSerialInTransaction'
# ZODB.Connection performs calls 'checkCurrentSerialInTransaction'
# after stores, and skips oids that have been succe
e
ssfully stored.
# after stores, and skips oids that have been successfully stored.
assert
oid
not
in
txn_context
[
'cache_dict'
],
(
oid
,
txn_context
)
assert
oid
not
in
txn_context
[
'cache_dict'
],
(
oid
,
txn_context
)
txn_context
[
'data_dict'
].
setdefault
(
oid
,
CHECKED_SERIAL
)
txn_context
[
'data_dict'
].
setdefault
(
oid
,
CHECKED_SERIAL
)
checked_nodes
=
txn_context
[
'checked_nodes'
]
checked_nodes
=
txn_context
[
'checked_nodes'
]
...
...
neo/client/cache.py
View file @
6e32ebb7
...
@@ -203,7 +203,7 @@ class ClientCache(object):
...
@@ -203,7 +203,7 @@ class ClientCache(object):
item
=
self
.
_load
(
oid
,
next_tid
)
item
=
self
.
_load
(
oid
,
next_tid
)
if
item
:
if
item
:
# We don't handle late invalidations for cached oids, because
# We don't handle late invalidations for cached oids, because
# the caller is not supposed to explicit
e
ly asks for tids after
# the caller is not supposed to explicitly asks for tids after
# app.last_tid (and the cache should be empty when app.last_tid
# app.last_tid (and the cache should be empty when app.last_tid
# is still None).
# is still None).
assert
item
.
tid
==
tid
,
(
item
,
tid
)
assert
item
.
tid
==
tid
,
(
item
,
tid
)
...
...
neo/client/handlers/storage.py
View file @
6e32ebb7
...
@@ -170,7 +170,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
...
@@ -170,7 +170,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
raise
ConflictError
,
'Lock wait timeout for oid %s on %r'
%
(
raise
ConflictError
,
'Lock wait timeout for oid %s on %r'
%
(
dump
(
oid
),
conn
)
dump
(
oid
),
conn
)
# HasLock design required that storage is multi-threaded so that
# HasLock design required that storage is multi-threaded so that
# it can answer to AskHasLock while processing store re
s
quests.
# it can answer to AskHasLock while processing store requests.
# This means that the 2 cases (granted to us or nobody) are legitimate,
# This means that the 2 cases (granted to us or nobody) are legitimate,
# either because it gave us the lock but is/was slow to store our data,
# either because it gave us the lock but is/was slow to store our data,
# or because the storage took a lot of time processing a previous
# or because the storage took a lot of time processing a previous
...
...
neo/lib/connection.py
View file @
6e32ebb7
...
@@ -72,7 +72,7 @@ class HandlerSwitcher(object):
...
@@ -72,7 +72,7 @@ class HandlerSwitcher(object):
_pending
=
self
.
_pending
_pending
=
self
.
_pending
if
self
.
_is_handling
:
if
self
.
_is_handling
:
# If this is called while handling a packet, the response is to
# If this is called while handling a packet, the response is to
# be ex
c
pected for the current handler...
# be expected for the current handler...
(
request_dict
,
_
)
=
_pending
[
0
]
(
request_dict
,
_
)
=
_pending
[
0
]
else
:
else
:
# ...otherwise, queue for the latest handler
# ...otherwise, queue for the latest handler
...
@@ -100,7 +100,7 @@ class HandlerSwitcher(object):
...
@@ -100,7 +100,7 @@ class HandlerSwitcher(object):
# on_timeout sent a packet with a smaller timeout
# on_timeout sent a packet with a smaller timeout
# so keep the connection open
# so keep the connection open
return
return
# Notify that a timeout occured
# Notify that a timeout occur
r
ed
return
msg_id
return
msg_id
def
handle
(
self
,
connection
,
packet
):
def
handle
(
self
,
connection
,
packet
):
...
...
neo/lib/connector.py
View file @
6e32ebb7
...
@@ -124,8 +124,8 @@ class SocketConnector(object):
...
@@ -124,8 +124,8 @@ class SocketConnector(object):
def
getDescriptor
(
self
):
def
getDescriptor
(
self
):
# this descriptor must only be used by the event manager, where it
# this descriptor must only be used by the event manager, where it
# guarantee uni
city only while the connector is opened and registere
d
# guarantee uni
queness only while the connector is opened an
d
# in epoll
#
registered
in epoll
return
self
.
socket_fd
return
self
.
socket_fd
@
staticmethod
@
staticmethod
...
...
neo/lib/locking.py
View file @
6e32ebb7
...
@@ -12,7 +12,7 @@ from Queue import Empty
...
@@ -12,7 +12,7 @@ from Queue import Empty
Python threading module contains a simple logging mechanism, but:
Python threading module contains a simple logging mechanism, but:
- It's limitted to RLock class
- It's limitted to RLock class
- It's enabled instance by instance
- It's enabled instance by instance
- Choice to log or not is done at instan
c
iation
- Choice to log or not is done at instan
t
iation
- It does not emit any log before trying to acquire lock
- It does not emit any log before trying to acquire lock
This file defines a VerboseLock class implementing basic lock API and
This file defines a VerboseLock class implementing basic lock API and
...
@@ -29,7 +29,7 @@ class LockUser(object):
...
@@ -29,7 +29,7 @@ class LockUser(object):
def
__init__
(
self
,
message
,
level
=
0
):
def
__init__
(
self
,
message
,
level
=
0
):
t
=
threading
.
currentThread
()
t
=
threading
.
currentThread
()
ident
=
getattr
(
t
,
'node_name'
,
t
.
name
)
ident
=
getattr
(
t
,
'node_name'
,
t
.
name
)
# This class is instan
c
iated from a place desiring to known what
# This class is instan
t
iated from a place desiring to known what
# called it.
# called it.
# limit=1 would return execution position in this method
# limit=1 would return execution position in this method
# limit=2 would return execution position in caller
# limit=2 would return execution position in caller
...
...
neo/lib/node.py
View file @
6e32ebb7
...
@@ -227,7 +227,7 @@ class Node(object):
...
@@ -227,7 +227,7 @@ class Node(object):
self
.
setState
(
NodeStates
.
PENDING
)
self
.
setState
(
NodeStates
.
PENDING
)
def
asTuple
(
self
):
def
asTuple
(
self
):
""" Returned tuple is inten
ted to be used in procot
ol encoders """
""" Returned tuple is inten
ded to be used in protoc
ol encoders """
return
(
self
.
getType
(),
self
.
_address
,
self
.
_uuid
,
self
.
_state
)
return
(
self
.
getType
(),
self
.
_address
,
self
.
_uuid
,
self
.
_state
)
def
__gt__
(
self
,
node
):
def
__gt__
(
self
,
node
):
...
@@ -337,7 +337,7 @@ class NodeManager(object):
...
@@ -337,7 +337,7 @@ class NodeManager(object):
def
__init__
(
self
,
master_db
=
None
):
def
__init__
(
self
,
master_db
=
None
):
"""
"""
master_db (string)
master_db (string)
Path to a file containing master nodes'
s
addresses. Used to automate
Path to a file containing master nodes' addresses. Used to automate
master list updates. If not provided, no automation will happen.
master list updates. If not provided, no automation will happen.
"""
"""
self
.
_node_set
=
set
()
self
.
_node_set
=
set
()
...
@@ -583,7 +583,7 @@ class NodeManager(object):
...
@@ -583,7 +583,7 @@ class NodeManager(object):
'Discrepancy between node_by_uuid (%r) and '
\
'Discrepancy between node_by_uuid (%r) and '
\
'node_by_addr (%r)'
%
(
node_by_uuid
,
node_by_addr
)
'node_by_addr (%r)'
%
(
node_by_uuid
,
node_by_addr
)
if
state
==
NodeStates
.
DOWN
:
if
state
==
NodeStates
.
DOWN
:
logging
.
debug
(
'droping node %r (%r), found with %s '
logging
.
debug
(
'drop
p
ing node %r (%r), found with %s '
'%s %s %s'
,
node
,
node
.
isConnected
(),
*
log_args
)
'%s %s %s'
,
node
,
node
.
isConnected
(),
*
log_args
)
if
node
.
isConnected
():
if
node
.
isConnected
():
# Cut this connection, node removed by handler.
# Cut this connection, node removed by handler.
...
...
neo/lib/patch.py
View file @
6e32ebb7
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
#
#
def
speedupFileStorageTxnLookup
():
def
speedupFileStorageTxnLookup
():
"""Speed up lookup of start position when instan
c
iating an iterator
"""Speed up lookup of start position when instan
t
iating an iterator
FileStorage does not index the file positions of transactions.
FileStorage does not index the file positions of transactions.
With this patch, we use the existing {oid->file_pos} index to bisect the
With this patch, we use the existing {oid->file_pos} index to bisect the
...
...
neo/lib/protocol.py
View file @
6e32ebb7
...
@@ -329,7 +329,7 @@ class ParseError(Exception):
...
@@ -329,7 +329,7 @@ class ParseError(Exception):
class
PItem
(
object
):
class
PItem
(
object
):
"""
"""
Base class for any packet item, _encode and _decode must be overriden
Base class for any packet item, _encode and _decode must be overrid
d
en
by subclasses.
by subclasses.
"""
"""
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
...
@@ -1491,8 +1491,8 @@ class Replicate(Packet):
...
@@ -1491,8 +1491,8 @@ class Replicate(Packet):
class
ReplicationDone
(
Packet
):
class
ReplicationDone
(
Packet
):
"""
"""
Notify the master node that a partition has been success
ully replicated from
Notify the master node that a partition has been success
fully replicated
a storage to another.
from
a storage to another.
S -> M
S -> M
"""
"""
_fmt
=
PStruct
(
'notify_replication_done'
,
_fmt
=
PStruct
(
'notify_replication_done'
,
...
@@ -1527,7 +1527,7 @@ def register(request, ignore_when_closed=None):
...
@@ -1527,7 +1527,7 @@ def register(request, ignore_when_closed=None):
# By default, on a closed connection:
# By default, on a closed connection:
# - request: ignore
# - request: ignore
# - answer: keep
# - answer: keep
# - no
fit
ication: keep
# - no
tif
ication: keep
ignore_when_closed
=
answer
is
not
None
ignore_when_closed
=
answer
is
not
None
request
.
_ignore_when_closed
=
ignore_when_closed
request
.
_ignore_when_closed
=
ignore_when_closed
if
answer
in
(
Error
,
None
):
if
answer
in
(
Error
,
None
):
...
@@ -1564,7 +1564,7 @@ class ParserState(object):
...
@@ -1564,7 +1564,7 @@ class ParserState(object):
class
Packets
(
dict
):
class
Packets
(
dict
):
"""
"""
Packet registry that check
packet code unicity and provide
an index
Packet registry that check
s packet code uniqueness and provides
an index
"""
"""
def
__metaclass__
(
name
,
base
,
d
):
def
__metaclass__
(
name
,
base
,
d
):
for
k
,
v
in
d
.
iteritems
():
for
k
,
v
in
d
.
iteritems
():
...
...
neo/lib/threaded_app.py
View file @
6e32ebb7
...
@@ -150,7 +150,7 @@ class ThreadedApplication(BaseApplication):
...
@@ -150,7 +150,7 @@ class ThreadedApplication(BaseApplication):
if
msg_id
==
qpacket
.
getId
():
if
msg_id
==
qpacket
.
getId
():
if
is_forgotten
:
if
is_forgotten
:
raise
ValueError
,
'ForgottenPacket for an '
\
raise
ValueError
,
'ForgottenPacket for an '
\
'explicit
e
ly expected packet.'
'explicitly expected packet.'
_handlePacket
(
qconn
,
qpacket
,
kw
,
handler
)
_handlePacket
(
qconn
,
qpacket
,
kw
,
handler
)
break
break
if
not
is_forgotten
and
qpacket
is
not
None
:
if
not
is_forgotten
and
qpacket
is
not
None
:
...
...
neo/lib/util.py
View file @
6e32ebb7
...
@@ -142,7 +142,7 @@ def parseNodeAddress(address, port_opt=None):
...
@@ -142,7 +142,7 @@ def parseNodeAddress(address, port_opt=None):
else
:
else
:
host
=
address
host
=
address
port
=
port_opt
port
=
port_opt
# Resolve (maybe) and cast to can
n
onical form
# Resolve (maybe) and cast to canonical form
# XXX: Always pick the first result. This might not be what is desired, and
# XXX: Always pick the first result. This might not be what is desired, and
# if so this function should either take a hint on the desired address type
# if so this function should either take a hint on the desired address type
# or return either raw host & port or getaddrinfo return value.
# or return either raw host & port or getaddrinfo return value.
...
...
neo/master/app.py
View file @
6e32ebb7
...
@@ -40,7 +40,7 @@ from .verification import VerificationManager
...
@@ -40,7 +40,7 @@ from .verification import VerificationManager
class
Application
(
BaseApplication
):
class
Application
(
BaseApplication
):
"""The master node application."""
"""The master node application."""
packing
=
None
packing
=
None
# Latest completely commited TID
# Latest completely commit
t
ed TID
last_transaction
=
ZERO_TID
last_transaction
=
ZERO_TID
backup_tid
=
None
backup_tid
=
None
backup_app
=
None
backup_app
=
None
...
@@ -261,7 +261,7 @@ class Application(BaseApplication):
...
@@ -261,7 +261,7 @@ class Application(BaseApplication):
def
provideService
(
self
):
def
provideService
(
self
):
"""
"""
This is the normal mode for a primary master node. Handle transactions
This is the normal mode for a primary master node. Handle transactions
and stop the service only if a catastroph
y
happens or the user commits
and stop the service only if a catastroph
e
happens or the user commits
a shutdown.
a shutdown.
"""
"""
logging
.
info
(
'provide service'
)
logging
.
info
(
'provide service'
)
...
@@ -298,7 +298,7 @@ class Application(BaseApplication):
...
@@ -298,7 +298,7 @@ class Application(BaseApplication):
# secondaries, rather than the other way around. This requires
# secondaries, rather than the other way around. This requires
# a bit more work when a new master joins a cluster but makes
# a bit more work when a new master joins a cluster but makes
# it easier to resolve UUID conflicts with minimal cluster
# it easier to resolve UUID conflicts with minimal cluster
# impact, and ensure primary master uni
city
(primary masters
# impact, and ensure primary master uni
queness
(primary masters
# become noisy, in that they actively try to maintain
# become noisy, in that they actively try to maintain
# connections to all other master nodes, so duplicate
# connections to all other master nodes, so duplicate
# primaries will eventually get in touch with each other and
# primaries will eventually get in touch with each other and
...
...
neo/master/handlers/secondary.py
View file @
6e32ebb7
...
@@ -51,7 +51,7 @@ class PrimaryHandler(EventHandler):
...
@@ -51,7 +51,7 @@ class PrimaryHandler(EventHandler):
app
=
self
.
app
app
=
self
.
app
addr
=
conn
.
getAddress
()
addr
=
conn
.
getAddress
()
node
=
app
.
nm
.
getByAddress
(
addr
)
node
=
app
.
nm
.
getByAddress
(
addr
)
# connection successful
l
, set it as running
# connection successful, set it as running
node
.
setRunning
()
node
.
setRunning
()
conn
.
ask
(
Packets
.
RequestIdentification
(
conn
.
ask
(
Packets
.
RequestIdentification
(
NodeTypes
.
MASTER
,
NodeTypes
.
MASTER
,
...
...
neo/master/transactions.py
View file @
6e32ebb7
...
@@ -334,7 +334,7 @@ class TransactionManager(object):
...
@@ -334,7 +334,7 @@ class TransactionManager(object):
"""
"""
Set that a node has locked the transaction.
Set that a node has locked the transaction.
If transaction is completely locked, calls function given at
If transaction is completely locked, calls function given at
instan
c
iation time.
instan
t
iation time.
"""
"""
logging
.
debug
(
'Lock TXN %s for %s'
,
dump
(
ttid
),
uuid_str
(
uuid
))
logging
.
debug
(
'Lock TXN %s for %s'
,
dump
(
ttid
),
uuid_str
(
uuid
))
if
self
[
ttid
].
lock
(
uuid
)
and
self
.
_queue
[
0
]
==
ttid
:
if
self
[
ttid
].
lock
(
uuid
)
and
self
.
_queue
[
0
]
==
ttid
:
...
...
neo/neoctl/app.py
View file @
6e32ebb7
...
@@ -174,7 +174,7 @@ class TerminalNeoCTL(object):
...
@@ -174,7 +174,7 @@ class TerminalNeoCTL(object):
def
tweakPartitionTable
(
self
,
params
):
def
tweakPartitionTable
(
self
,
params
):
"""
"""
Optimize partition table.
Optimize partition table.
No partiti
ti
on will be assigned to specified storage nodes.
No partition will be assigned to specified storage nodes.
Parameters: [node [...]]
Parameters: [node [...]]
"""
"""
return
self
.
neoctl
.
tweakPartitionTable
(
map
(
self
.
asNode
,
params
))
return
self
.
neoctl
.
tweakPartitionTable
(
map
(
self
.
asNode
,
params
))
...
@@ -294,7 +294,7 @@ class Application(object):
...
@@ -294,7 +294,7 @@ class Application(object):
if
docstring
is
None
:
if
docstring
is
None
:
docstring
=
'(no docstring)'
docstring
=
'(no docstring)'
docstring_line_list
=
docstring
.
split
(
'
\
n
'
)
docstring_line_list
=
docstring
.
split
(
'
\
n
'
)
# Strip empty lines at begining & end of line list
# Strip empty lines at begin
n
ing & end of line list
for
end
in
(
0
,
-
1
):
for
end
in
(
0
,
-
1
):
while
len
(
docstring_line_list
)
\
while
len
(
docstring_line_list
)
\
and
docstring_line_list
[
end
]
==
''
:
and
docstring_line_list
[
end
]
==
''
:
...
...
neo/scripts/neostorage.py
View file @
6e32ebb7
...
@@ -43,7 +43,7 @@ def main(args=None):
...
@@ -43,7 +43,7 @@ def main(args=None):
# TODO: Forbid using "reset" along with any unneeded argument.
# TODO: Forbid using "reset" along with any unneeded argument.
# "reset" is too dangerous to let user a chance of accidentally
# "reset" is too dangerous to let user a chance of accidentally
# letting it slip through in a long option list.
# letting it slip through in a long option list.
# We should drop support configation files to make such check useful.
# We should drop support config
ur
ation files to make such check useful.
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
(
options
,
args
)
=
parser
.
parse_args
(
args
=
args
)
config
=
ConfigurationManager
(
defaults
,
options
,
'storage'
)
config
=
ConfigurationManager
(
defaults
,
options
,
'storage'
)
...
...
neo/storage/database/manager.py
View file @
6e32ebb7
...
@@ -76,7 +76,7 @@ class DatabaseManager(object):
...
@@ -76,7 +76,7 @@ class DatabaseManager(object):
@
abstract
@
abstract
def
_parse
(
self
,
database
):
def
_parse
(
self
,
database
):
"""Called during instan
c
iation, to process database parameter."""
"""Called during instan
t
iation, to process database parameter."""
def
setup
(
self
,
reset
=
0
):
def
setup
(
self
,
reset
=
0
):
"""Set up a database, discarding existing data first if reset is True
"""Set up a database, discarding existing data first if reset is True
...
@@ -92,7 +92,7 @@ class DatabaseManager(object):
...
@@ -92,7 +92,7 @@ class DatabaseManager(object):
@
abstract
@
abstract
def
_setup
(
self
):
def
_setup
(
self
):
"""To be overriden by the backend to set up a database
"""To be overrid
d
en by the backend to set up a database
It must recover self._uncommitted_data from temporary object table.
It must recover self._uncommitted_data from temporary object table.
_uncommitted_data is already instantiated and must be updated with
_uncommitted_data is already instantiated and must be updated with
...
@@ -411,7 +411,7 @@ class DatabaseManager(object):
...
@@ -411,7 +411,7 @@ class DatabaseManager(object):
@
abstract
@
abstract
def
_pruneData
(
self
,
data_id_list
):
def
_pruneData
(
self
,
data_id_list
):
"""To be overriden by the backend to delete any unreferenced data
"""To be overrid
d
en by the backend to delete any unreferenced data
'unreferenced' means:
'unreferenced' means:
- not in self._uncommitted_data
- not in self._uncommitted_data
...
@@ -421,7 +421,7 @@ class DatabaseManager(object):
...
@@ -421,7 +421,7 @@ class DatabaseManager(object):
@
abstract
@
abstract
def
storeData
(
self
,
checksum
,
data
,
compression
):
def
storeData
(
self
,
checksum
,
data
,
compression
):
"""To be overriden by the backend to store object raw data
"""To be overrid
d
en by the backend to store object raw data
If same data was already stored, the storage only has to check there's
If same data was already stored, the storage only has to check there's
no hash collision.
no hash collision.
...
@@ -485,7 +485,7 @@ class DatabaseManager(object):
...
@@ -485,7 +485,7 @@ class DatabaseManager(object):
tid
tid
Transation doing the undo
Transation doing the undo
ltid
ltid
Upper (exclued) bound of transactions visible to transaction doing
Upper (exclu
d
ed) bound of transactions visible to transaction doing
the undo.
the undo.
undone_tid
undone_tid
Transaction to undo
Transaction to undo
...
@@ -636,7 +636,7 @@ class DatabaseManager(object):
...
@@ -636,7 +636,7 @@ class DatabaseManager(object):
@
abstract
@
abstract
def
checkTIDRange
(
self
,
partition
,
length
,
min_tid
,
max_tid
):
def
checkTIDRange
(
self
,
partition
,
length
,
min_tid
,
max_tid
):
"""
"""
Generate a dig
g
est from transaction list.
Generate a digest from transaction list.
min_tid (packed)
min_tid (packed)
TID at which verification starts.
TID at which verification starts.
length (int)
length (int)
...
@@ -653,7 +653,7 @@ class DatabaseManager(object):
...
@@ -653,7 +653,7 @@ class DatabaseManager(object):
@
abstract
@
abstract
def
checkSerialRange
(
self
,
partition
,
length
,
min_tid
,
max_tid
,
min_oid
):
def
checkSerialRange
(
self
,
partition
,
length
,
min_tid
,
max_tid
,
min_oid
):
"""
"""
Generate a dig
g
est from object list.
Generate a digest from object list.
min_oid (packed)
min_oid (packed)
OID at which verification starts.
OID at which verification starts.
min_tid (packed)
min_tid (packed)
...
...
neo/storage/database/mysqldb.py
View file @
6e32ebb7
...
@@ -216,7 +216,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -216,7 +216,7 @@ class MySQLDatabaseManager(DatabaseManager):
engine
+=
" compression='tokudb_uncompressed'"
engine
+=
" compression='tokudb_uncompressed'"
# The table "data" stores object data.
# The table "data" stores object data.
# We'd like to have partial index on 'hash' colum (e.g. hash(4))
# We'd like to have partial index on 'hash' colum
n
(e.g. hash(4))
# but 'UNIQUE' constraint would not work as expected.
# but 'UNIQUE' constraint would not work as expected.
q
(
"""CREATE TABLE IF NOT EXISTS data (
q
(
"""CREATE TABLE IF NOT EXISTS data (
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
...
@@ -630,7 +630,7 @@ class MySQLDatabaseManager(DatabaseManager):
...
@@ -630,7 +630,7 @@ class MySQLDatabaseManager(DatabaseManager):
return
oid_list
,
user
,
desc
,
ext
,
bool
(
packed
),
util
.
p64
(
ttid
)
return
oid_list
,
user
,
desc
,
ext
,
bool
(
packed
),
util
.
p64
(
ttid
)
def
getObjectHistory
(
self
,
oid
,
offset
,
length
):
def
getObjectHistory
(
self
,
oid
,
offset
,
length
):
# FIXME: This method doesn't take client's current ransaction id as
# FIXME: This method doesn't take client's current
t
ransaction id as
# parameter, which means it can return transactions in the future of
# parameter, which means it can return transactions in the future of
# client's transaction.
# client's transaction.
oid
=
util
.
u64
(
oid
)
oid
=
util
.
u64
(
oid
)
...
...
neo/storage/handlers/client.py
View file @
6e32ebb7
...
@@ -88,7 +88,7 @@ class ClientOperationHandler(EventHandler):
...
@@ -88,7 +88,7 @@ class ClientOperationHandler(EventHandler):
except
DelayedError
:
except
DelayedError
:
# locked by a previous transaction, retry later
# locked by a previous transaction, retry later
# If we are unlocking, we want queueEvent to raise
# If we are unlocking, we want queueEvent to raise
# AlreadyPendingError, to avoid making
lc
ient wait for an unneeded
# AlreadyPendingError, to avoid making
cl
ient wait for an unneeded
# response.
# response.
try
:
try
:
self
.
app
.
queueEvent
(
self
.
_askStoreObject
,
conn
,
(
oid
,
serial
,
self
.
app
.
queueEvent
(
self
.
_askStoreObject
,
conn
,
(
oid
,
serial
,
...
...
neo/storage/handlers/initialization.py
View file @
6e32ebb7
...
@@ -29,7 +29,7 @@ class InitializationHandler(BaseMasterHandler):
...
@@ -29,7 +29,7 @@ class InitializationHandler(BaseMasterHandler):
pt
.
load
(
ptid
,
row_list
,
self
.
app
.
nm
)
pt
.
load
(
ptid
,
row_list
,
self
.
app
.
nm
)
if
not
pt
.
filled
():
if
not
pt
.
filled
():
raise
ProtocolError
(
'Partial partition table received'
)
raise
ProtocolError
(
'Partial partition table received'
)
# Install the partition table into the database for persistenc
y
.
# Install the partition table into the database for persistenc
e
.
cell_list
=
[]
cell_list
=
[]
num_partitions
=
pt
.
getPartitions
()
num_partitions
=
pt
.
getPartitions
()
unassigned_set
=
set
(
xrange
(
num_partitions
))
unassigned_set
=
set
(
xrange
(
num_partitions
))
...
...
neo/storage/replicator.py
View file @
6e32ebb7
...
@@ -336,7 +336,7 @@ class Replicator(object):
...
@@ -336,7 +336,7 @@ class Replicator(object):
offset
,
message
and
' (%s)'
%
message
)
offset
,
message
and
' (%s)'
%
message
)
if
offset
in
self
.
partition_dict
:
if
offset
in
self
.
partition_dict
:
# XXX: Try another partition if possible, to increase probability to
# XXX: Try another partition if possible, to increase probability to
# connect to another node. It would be better to explicit
e
ly
# connect to another node. It would be better to explicitly
# search for another node instead.
# search for another node instead.
tid
=
self
.
replicate_dict
.
pop
(
offset
,
None
)
or
self
.
replicate_tid
tid
=
self
.
replicate_dict
.
pop
(
offset
,
None
)
or
self
.
replicate_tid
if
self
.
replicate_dict
:
if
self
.
replicate_dict
:
...
...
neo/tests/__init__.py
View file @
6e32ebb7
...
@@ -312,7 +312,7 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -312,7 +312,7 @@ class NeoUnitTestBase(NeoTestBase):
self
.
assertRaises
(
protocol
.
ProtocolError
,
method
,
*
args
,
**
kwargs
)
self
.
assertRaises
(
protocol
.
ProtocolError
,
method
,
*
args
,
**
kwargs
)
def
checkUnexpectedPacketRaised
(
self
,
method
,
*
args
,
**
kwargs
):
def
checkUnexpectedPacketRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the UnexpectedPacketError exception w
x
as raised """
""" Check if the UnexpectedPacketError exception was raised """
self
.
assertRaises
(
protocol
.
UnexpectedPacketError
,
method
,
*
args
,
**
kwargs
)
self
.
assertRaises
(
protocol
.
UnexpectedPacketError
,
method
,
*
args
,
**
kwargs
)
def
checkIdenficationRequired
(
self
,
method
,
*
args
,
**
kwargs
):
def
checkIdenficationRequired
(
self
,
method
,
*
args
,
**
kwargs
):
...
@@ -320,11 +320,11 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -320,11 +320,11 @@ class NeoUnitTestBase(NeoTestBase):
self
.
checkUnexpectedPacketRaised
(
method
,
*
args
,
**
kwargs
)
self
.
checkUnexpectedPacketRaised
(
method
,
*
args
,
**
kwargs
)
def
checkBrokenNodeDisallowedErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
def
checkBrokenNodeDisallowedErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the BrokenNodeDisallowedError exception w
x
as raised """
""" Check if the BrokenNodeDisallowedError exception was raised """
self
.
assertRaises
(
protocol
.
BrokenNodeDisallowedError
,
method
,
*
args
,
**
kwargs
)
self
.
assertRaises
(
protocol
.
BrokenNodeDisallowedError
,
method
,
*
args
,
**
kwargs
)
def
checkNotReadyErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
def
checkNotReadyErrorRaised
(
self
,
method
,
*
args
,
**
kwargs
):
""" Check if the NotReadyError exception w
x
as raised """
""" Check if the NotReadyError exception was raised """
self
.
assertRaises
(
protocol
.
NotReadyError
,
method
,
*
args
,
**
kwargs
)
self
.
assertRaises
(
protocol
.
NotReadyError
,
method
,
*
args
,
**
kwargs
)
def
checkAborted
(
self
,
conn
):
def
checkAborted
(
self
,
conn
):
...
@@ -372,7 +372,7 @@ class NeoUnitTestBase(NeoTestBase):
...
@@ -372,7 +372,7 @@ class NeoUnitTestBase(NeoTestBase):
self
.
assertEqual
(
found_uuid
,
uuid
)
self
.
assertEqual
(
found_uuid
,
uuid
)
# in check(Ask|Answer|Notify)Packet we return the packet so it can be used
# in check(Ask|Answer|Notify)Packet we return the packet so it can be used
# in tests if more accurate
s
checks are required
# in tests if more accurate checks are required
def
checkErrorPacket
(
self
,
conn
,
decode
=
False
):
def
checkErrorPacket
(
self
,
conn
,
decode
=
False
):
""" Check if an error packet was answered """
""" Check if an error packet was answered """
...
...
neo/tests/client/testClientApp.py
View file @
6e32ebb7
...
@@ -81,7 +81,7 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -81,7 +81,7 @@ class ClientApplicationTests(NeoUnitTestBase):
# stop threads
# stop threads
for
app
in
self
.
_to_stop_list
:
for
app
in
self
.
_to_stop_list
:
app
.
close
()
app
.
close
()
# restore environ
ne
ment
# restore environment
Application
.
_ask
=
self
.
_ask
Application
.
_ask
=
self
.
_ask
Application
.
_getMasterConnection
=
self
.
_getMasterConnection
Application
.
_getMasterConnection
=
self
.
_getMasterConnection
NeoUnitTestBase
.
_tearDown
(
self
,
success
)
NeoUnitTestBase
.
_tearDown
(
self
,
success
)
...
@@ -596,7 +596,7 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -596,7 +596,7 @@ class ClientApplicationTests(NeoUnitTestBase):
Object oid previous revision before tid1 is tid0.
Object oid previous revision before tid1 is tid0.
Transaction tid2 modified oid (and contains its data).
Transaction tid2 modified oid (and contains its data).
Undo is rejeced with a raise, because conflict resolution fails.
Undo is rejec
t
ed with a raise, because conflict resolution fails.
"""
"""
oid0
=
self
.
makeOID
(
1
)
oid0
=
self
.
makeOID
(
1
)
tid0
=
self
.
getNextTID
()
tid0
=
self
.
getNextTID
()
...
@@ -795,7 +795,7 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -795,7 +795,7 @@ class ClientApplicationTests(NeoUnitTestBase):
ask_func_list
.
pop
(
0
)(
conn
)
ask_func_list
.
pop
(
0
)(
conn
)
app
.
nm
.
getByAddress
(
conn
.
getAddress
()).
_connection
=
None
app
.
nm
.
getByAddress
(
conn
.
getAddress
()).
_connection
=
None
app
.
_ask
=
_ask_base
app
.
_ask
=
_ask_base
# fake
d environne
ment
# fake
environ
ment
app
.
em
.
close
()
app
.
em
.
close
()
app
.
em
=
Mock
({
'getConnectionList'
:
[]})
app
.
em
=
Mock
({
'getConnectionList'
:
[]})
app
.
pt
=
Mock
({
'operational'
:
False
})
app
.
pt
=
Mock
({
'operational'
:
False
})
...
@@ -831,11 +831,11 @@ class ClientApplicationTests(NeoUnitTestBase):
...
@@ -831,11 +831,11 @@ class ClientApplicationTests(NeoUnitTestBase):
self
.
assertTrue
(
self
.
test_ok
)
self
.
assertTrue
(
self
.
test_ok
)
# check NEOStorageError is raised when the primary connection is lost
# check NEOStorageError is raised when the primary connection is lost
app
.
master_conn
=
None
app
.
master_conn
=
None
# check disabled since we reonnect to pmn
# check disabled since we re
c
onnect to pmn
#self.assertRaises(NEOStorageError, app._askPrimary, packet)
#self.assertRaises(NEOStorageError, app._askPrimary, packet)
def
test_threadContextIsolation
(
self
):
def
test_threadContextIsolation
(
self
):
""" Thread context properties must not be visible ac
c
ross instances
""" Thread context properties must not be visible across instances
while remaining in the same thread """
while remaining in the same thread """
app1
=
self
.
getApp
()
app1
=
self
.
getApp
()
app1_local
=
app1
.
_thread_container
app1_local
=
app1
.
_thread_container
...
...
neo/tests/functional/__init__.py
View file @
6e32ebb7
...
@@ -183,7 +183,7 @@ class NEOProcess(object):
...
@@ -183,7 +183,7 @@ class NEOProcess(object):
self
.
wait
()
self
.
wait
()
except
:
except
:
# We can ignore all exceptions at this point, since there is no
# We can ignore all exceptions at this point, since there is no
# garanteed way to handle them (other objects we would depend on
# g
u
aranteed way to handle them (other objects we would depend on
# might already have been deleted).
# might already have been deleted).
pass
pass
...
@@ -565,7 +565,7 @@ class NEOCluster(object):
...
@@ -565,7 +565,7 @@ class NEOCluster(object):
def
callback
(
last_try
):
def
callback
(
last_try
):
current_try
=
self
.
getPrimary
()
current_try
=
self
.
getPrimary
()
if
None
not
in
(
uuid
,
current_try
)
and
uuid
!=
current_try
:
if
None
not
in
(
uuid
,
current_try
)
and
uuid
!=
current_try
:
raise
AssertionError
,
'An unexpected primary ar
ised
: %r, '
\
raise
AssertionError
,
'An unexpected primary ar
ose
: %r, '
\
'expected %r'
%
(
dump
(
current_try
),
dump
(
uuid
))
'expected %r'
%
(
dump
(
current_try
),
dump
(
uuid
))
return
uuid
is
None
or
uuid
==
current_try
,
current_try
return
uuid
is
None
or
uuid
==
current_try
,
current_try
self
.
expectCondition
(
callback
,
*
args
,
**
kw
)
self
.
expectCondition
(
callback
,
*
args
,
**
kw
)
...
...
neo/tests/functional/testClient.py
View file @
6e32ebb7
...
@@ -43,7 +43,7 @@ class Tree(Persistent):
...
@@ -43,7 +43,7 @@ class Tree(Persistent):
self
.
left
=
Tree
(
depth
)
self
.
left
=
Tree
(
depth
)
# simple persitent object with conflict resolution
# simple persi
s
tent object with conflict resolution
class
PCounter
(
Persistent
):
class
PCounter
(
Persistent
):
_value
=
0
_value
=
0
...
@@ -131,7 +131,7 @@ class ClientTests(NEOFunctionalTest):
...
@@ -131,7 +131,7 @@ class ClientTests(NEOFunctionalTest):
c2
.
root
()[
'other'
]
c2
.
root
()[
'other'
]
c1
.
root
()[
'item'
]
=
1
c1
.
root
()[
'item'
]
=
1
t1
.
commit
()
t1
.
commit
()
# load objet from zope cache
# load obje
c
t from zope cache
self
.
assertEqual
(
c1
.
root
()[
'item'
],
1
)
self
.
assertEqual
(
c1
.
root
()[
'item'
],
1
)
self
.
assertEqual
(
c2
.
root
()[
'item'
],
0
)
self
.
assertEqual
(
c2
.
root
()[
'item'
],
0
)
...
@@ -334,7 +334,7 @@ class ClientTests(NEOFunctionalTest):
...
@@ -334,7 +334,7 @@ class ClientTests(NEOFunctionalTest):
t3
.
user
=
'user'
t3
.
user
=
'user'
t3
.
description
=
'desc'
t3
.
description
=
'desc'
st3
.
tpc_begin
(
t3
)
st3
.
tpc_begin
(
t3
)
# retr
ei
ve the last revision
# retr
ie
ve the last revision
data
,
serial
=
st3
.
load
(
oid
)
data
,
serial
=
st3
.
load
(
oid
)
# try to store again, should not be delayed
# try to store again, should not be delayed
st3
.
store
(
oid
,
serial
,
data
,
''
,
t3
)
st3
.
store
(
oid
,
serial
,
data
,
''
,
t3
)
...
...
neo/tests/functional/testMaster.py
View file @
6e32ebb7
...
@@ -63,7 +63,7 @@ class MasterTests(NEOFunctionalTest):
...
@@ -63,7 +63,7 @@ class MasterTests(NEOFunctionalTest):
# BUG: The following check expects neoctl to reconnect before
# BUG: The following check expects neoctl to reconnect before
# the election finishes.
# the election finishes.
self
.
assertEqual
(
self
.
neo
.
getPrimary
(),
None
)
self
.
assertEqual
(
self
.
neo
.
getPrimary
(),
None
)
# Check that a primary master ar
ised
.
# Check that a primary master ar
ose
.
self
.
neo
.
expectPrimary
(
timeout
=
10
)
self
.
neo
.
expectPrimary
(
timeout
=
10
)
# Check that the uuid really changed.
# Check that the uuid really changed.
new_uuid
=
self
.
neo
.
getPrimary
()
new_uuid
=
self
.
neo
.
getPrimary
()
...
@@ -83,7 +83,7 @@ class MasterTests(NEOFunctionalTest):
...
@@ -83,7 +83,7 @@ class MasterTests(NEOFunctionalTest):
uuid
,
=
self
.
neo
.
killPrimary
()
uuid
,
=
self
.
neo
.
killPrimary
()
# Check the state of the primary we just killed
# Check the state of the primary we just killed
self
.
neo
.
expectMasterState
(
uuid
,
(
None
,
NodeStates
.
UNKNOWN
))
self
.
neo
.
expectMasterState
(
uuid
,
(
None
,
NodeStates
.
UNKNOWN
))
# Check that a primary master ar
ised
.
# Check that a primary master ar
ose
.
self
.
neo
.
expectPrimary
(
timeout
=
10
)
self
.
neo
.
expectPrimary
(
timeout
=
10
)
# Check that the uuid really changed.
# Check that the uuid really changed.
self
.
assertNotEqual
(
self
.
neo
.
getPrimary
(),
uuid
)
self
.
assertNotEqual
(
self
.
neo
.
getPrimary
(),
uuid
)
...
...
neo/tests/functional/testStorage.py
View file @
6e32ebb7
...
@@ -69,7 +69,7 @@ class StorageTests(NEOFunctionalTest):
...
@@ -69,7 +69,7 @@ class StorageTests(NEOFunctionalTest):
def
__checkDatabase
(
self
,
db_name
):
def
__checkDatabase
(
self
,
db_name
):
db
=
self
.
neo
.
getSQLConnection
(
db_name
)
db
=
self
.
neo
.
getSQLConnection
(
db_name
)
# wait for the sql transaction to be commited
# wait for the sql transaction to be commit
t
ed
def
callback
(
last_try
):
def
callback
(
last_try
):
db
.
commit
()
# to get a fresh view
db
.
commit
()
# to get a fresh view
# One revision per object and two for the root, before and after
# One revision per object and two for the root, before and after
...
@@ -185,7 +185,7 @@ class StorageTests(NEOFunctionalTest):
...
@@ -185,7 +185,7 @@ class StorageTests(NEOFunctionalTest):
def
testVerificationTriggered
(
self
):
def
testVerificationTriggered
(
self
):
""" Check that the verification stage is executed when a storage node
""" Check that the verification stage is executed when a storage node
required to be operation
n
al is lost, and the cluster come back in
required to be operational is lost, and the cluster come back in
running state when the storage is up again """
running state when the storage is up again """
# start neo with one storages
# start neo with one storages
...
...
neo/tests/master/testElectionHandler.py
View file @
6e32ebb7
...
@@ -225,7 +225,7 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
...
@@ -225,7 +225,7 @@ class MasterServerElectionTests(MasterClientElectionTestBase):
def
_tearDown
(
self
,
success
):
def
_tearDown
(
self
,
success
):
NeoUnitTestBase
.
_tearDown
(
self
,
success
)
NeoUnitTestBase
.
_tearDown
(
self
,
success
)
# restore environ
ne
ment
# restore environment
del
ClientConnection
.
_addPacket
del
ClientConnection
.
_addPacket
def
test_requestIdentification1
(
self
):
def
test_requestIdentification1
(
self
):
...
...
neo/tests/master/testStorageHandler.py
View file @
6e32ebb7
...
@@ -160,7 +160,7 @@ class MasterStorageHandlerTests(NeoUnitTestBase):
...
@@ -160,7 +160,7 @@ class MasterStorageHandlerTests(NeoUnitTestBase):
self
.
assertEqual
(
lptid
,
self
.
app
.
pt
.
getID
())
self
.
assertEqual
(
lptid
,
self
.
app
.
pt
.
getID
())
def
test_answerPack
(
self
):
def
test_answerPack
(
self
):
# Note: incom
m
ing status has no meaning here, so it's left to False.
# Note: incoming status has no meaning here, so it's left to False.
node1
,
conn1
=
self
.
_getStorage
()
node1
,
conn1
=
self
.
_getStorage
()
node2
,
conn2
=
self
.
_getStorage
()
node2
,
conn2
=
self
.
_getStorage
()
self
.
app
.
packing
=
None
self
.
app
.
packing
=
None
...
...
neo/tests/master/testTransactions.py
View file @
6e32ebb7
...
@@ -169,7 +169,7 @@ class testTransactionManager(NeoUnitTestBase):
...
@@ -169,7 +169,7 @@ class testTransactionManager(NeoUnitTestBase):
"""
"""
Transaction lock is present to ensure invalidation TIDs are sent in
Transaction lock is present to ensure invalidation TIDs are sent in
strictly increasing order.
strictly increasing order.
Note: this implementation might change later,
to allow more para
lelism.
Note: this implementation might change later,
for more paral
lelism.
"""
"""
client_uuid
,
client
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
client_uuid
,
client
=
self
.
makeNode
(
NodeTypes
.
CLIENT
)
tm
=
TransactionManager
(
lambda
tid
,
txn
:
None
)
tm
=
TransactionManager
(
lambda
tid
,
txn
:
None
)
...
...
neo/tests/storage/testStorageDBTests.py
View file @
6e32ebb7
...
@@ -167,17 +167,17 @@ class StorageDBTests(NeoUnitTestBase):
...
@@ -167,17 +167,17 @@ class StorageDBTests(NeoUnitTestBase):
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
None
)
# one non-commited version
# one non-commit
t
ed version
with
self
.
commitTransaction
(
tid1
,
objs1
,
txn1
):
with
self
.
commitTransaction
(
tid1
,
objs1
,
txn1
):
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
None
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
None
)
# one commited version
# one commit
t
ed version
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
FOUND_BUT_NOT_VISIBLE
)
FOUND_BUT_NOT_VISIBLE
)
# two version available, one non-commited
# two version available, one non-commit
t
ed
with
self
.
commitTransaction
(
tid2
,
objs2
,
txn2
):
with
self
.
commitTransaction
(
tid2
,
objs2
,
txn2
):
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NO_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NO_NEXT
)
...
@@ -187,7 +187,7 @@ class StorageDBTests(NeoUnitTestBase):
...
@@ -187,7 +187,7 @@ class StorageDBTests(NeoUnitTestBase):
FOUND_BUT_NOT_VISIBLE
)
FOUND_BUT_NOT_VISIBLE
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid2
),
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid2
),
OBJECT_T1_NO_NEXT
)
OBJECT_T1_NO_NEXT
)
# two commited versions
# two commit
t
ed versions
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T2
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
),
OBJECT_T2
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
tid1
),
OBJECT_T1_NEXT
)
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
self
.
assertEqual
(
self
.
db
.
getObject
(
oid1
,
before_tid
=
tid1
),
...
...
neo/tests/storage/testTransactions.py
View file @
6e32ebb7
...
@@ -187,7 +187,7 @@ class TransactionManagerTests(NeoUnitTestBase):
...
@@ -187,7 +187,7 @@ class TransactionManagerTests(NeoUnitTestBase):
ttid1
,
serial
,
*
obj
)
ttid1
,
serial
,
*
obj
)
def
testResolvableConflict
(
self
):
def
testResolvableConflict
(
self
):
""" Try to store an object with the la
s
test revision """
""" Try to store an object with the latest revision """
uuid
=
self
.
getClientUUID
()
uuid
=
self
.
getClientUUID
()
tid
,
txn
=
self
.
_getTransaction
()
tid
,
txn
=
self
.
_getTransaction
()
serial
,
obj
=
self
.
_getObject
(
1
)
serial
,
obj
=
self
.
_getObject
(
1
)
...
...
neo/tests/testConnection.py
View file @
6e32ebb7
...
@@ -330,7 +330,7 @@ class HandlerSwitcherTests(NeoUnitTestBase):
...
@@ -330,7 +330,7 @@ class HandlerSwitcherTests(NeoUnitTestBase):
r2
=
self
.
_makeRequest
(
2
)
r2
=
self
.
_makeRequest
(
2
)
a2
=
self
.
_makeAnswer
(
2
)
a2
=
self
.
_makeAnswer
(
2
)
h
=
self
.
_makeHandler
()
h
=
self
.
_makeHandler
()
# emit requests aroun
g
state setHandler
# emit requests aroun
d
state setHandler
self
.
_handlers
.
emit
(
r1
,
0
,
None
)
self
.
_handlers
.
emit
(
r1
,
0
,
None
)
applied
=
self
.
_handlers
.
setHandler
(
h
)
applied
=
self
.
_handlers
.
setHandler
(
h
)
self
.
assertFalse
(
applied
)
self
.
assertFalse
(
applied
)
...
...
neo/tests/testNodes.py
View file @
6e32ebb7
...
@@ -301,7 +301,7 @@ class MasterDBTests(NeoUnitTestBase):
...
@@ -301,7 +301,7 @@ class MasterDBTests(NeoUnitTestBase):
def
testInitialAccessRights
(
self
):
def
testInitialAccessRights
(
self
):
"""
"""
Verify MasterDB raises immediately on instan
c
iation if it cannot
Verify MasterDB raises immediately on instan
t
iation if it cannot
create a non-existing database. This does not guarantee any later
create a non-existing database. This does not guarantee any later
open will succeed, but makes the simple error case obvious.
open will succeed, but makes the simple error case obvious.
"""
"""
...
...
neo/tests/testPT.py
View file @
6e32ebb7
...
@@ -65,9 +65,9 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -65,9 +65,9 @@ class PartitionTableTests(NeoUnitTestBase):
self
.
assertEqual
(
cell
.
getState
(),
CellStates
.
UP_TO_DATE
)
self
.
assertEqual
(
cell
.
getState
(),
CellStates
.
UP_TO_DATE
)
else
:
else
:
self
.
assertEqual
(
len
(
pt
.
partition_list
[
x
]),
0
)
self
.
assertEqual
(
len
(
pt
.
partition_list
[
x
]),
0
)
# try to add to a
n unexista
nt partition
# try to add to a
nonexiste
nt partition
self
.
assertRaises
(
IndexError
,
pt
.
setCell
,
10
,
sn1
,
CellStates
.
UP_TO_DATE
)
self
.
assertRaises
(
IndexError
,
pt
.
setCell
,
10
,
sn1
,
CellStates
.
UP_TO_DATE
)
# if we add in discard
e
s state, must be removed
# if we add in discards state, must be removed
pt
.
setCell
(
0
,
sn1
,
CellStates
.
DISCARDED
)
pt
.
setCell
(
0
,
sn1
,
CellStates
.
DISCARDED
)
for
x
in
xrange
(
num_partitions
):
for
x
in
xrange
(
num_partitions
):
self
.
assertEqual
(
len
(
pt
.
partition_list
[
x
]),
0
)
self
.
assertEqual
(
len
(
pt
.
partition_list
[
x
]),
0
)
...
@@ -168,7 +168,7 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -168,7 +168,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_partitions
=
5
num_replicas
=
2
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
@@ -214,7 +214,7 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -214,7 +214,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_partitions
=
5
num_replicas
=
2
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
@@ -244,7 +244,7 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -244,7 +244,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_partitions
=
5
num_replicas
=
2
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
@@ -286,7 +286,7 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -286,7 +286,7 @@ class PartitionTableTests(NeoUnitTestBase):
num_partitions
=
5
num_partitions
=
5
num_replicas
=
2
num_replicas
=
2
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
pt
=
PartitionTable
(
num_partitions
,
num_replicas
)
# add two kind of node, usable and unsable
# add two kind of node, usable and un
u
sable
uuid1
=
self
.
getStorageUUID
()
uuid1
=
self
.
getStorageUUID
()
server1
=
(
"127.0.0.1"
,
19001
)
server1
=
(
"127.0.0.1"
,
19001
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
sn1
=
StorageNode
(
Mock
(),
server1
,
uuid1
)
...
@@ -294,7 +294,7 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -294,7 +294,7 @@ class PartitionTableTests(NeoUnitTestBase):
# now test
# now test
self
.
assertTrue
(
pt
.
hasOffset
(
0
))
self
.
assertTrue
(
pt
.
hasOffset
(
0
))
self
.
assertFalse
(
pt
.
hasOffset
(
1
))
self
.
assertFalse
(
pt
.
hasOffset
(
1
))
# unkno
nw
partition
# unkno
wn
partition
self
.
assertFalse
(
pt
.
hasOffset
(
50
))
self
.
assertFalse
(
pt
.
hasOffset
(
50
))
def
test_10_operational
(
self
):
def
test_10_operational
(
self
):
...
@@ -397,7 +397,7 @@ class PartitionTableTests(NeoUnitTestBase):
...
@@ -397,7 +397,7 @@ class PartitionTableTests(NeoUnitTestBase):
self
.
assertEqual
(
len
(
row_3
),
0
)
self
.
assertEqual
(
len
(
row_3
),
0
)
row_4
=
pt
.
getRow
(
4
)
row_4
=
pt
.
getRow
(
4
)
self
.
assertEqual
(
len
(
row_4
),
0
)
self
.
assertEqual
(
len
(
row_4
),
0
)
# unkn
wo
n row
# unkn
ow
n row
self
.
assertRaises
(
IndexError
,
pt
.
getRow
,
5
)
self
.
assertRaises
(
IndexError
,
pt
.
getRow
,
5
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
neo/tests/testUtil.py
View file @
6e32ebb7
...
@@ -22,7 +22,7 @@ from neo.lib.util import ReadBuffer, parseNodeAddress
...
@@ -22,7 +22,7 @@ from neo.lib.util import ReadBuffer, parseNodeAddress
class
UtilTests
(
NeoUnitTestBase
):
class
UtilTests
(
NeoUnitTestBase
):
def
test_parseNodeAddress
(
self
):
def
test_parseNodeAddress
(
self
):
""" Parsing of addesses """
""" Parsing of add
r
esses """
def
test
(
parsed
,
*
args
):
def
test
(
parsed
,
*
args
):
self
.
assertEqual
(
parsed
,
parseNodeAddress
(
*
args
))
self
.
assertEqual
(
parsed
,
parseNodeAddress
(
*
args
))
http_port
=
socket
.
getservbyname
(
'http'
)
http_port
=
socket
.
getservbyname
(
'http'
)
...
...
neo/tests/threaded/test.py
View file @
6e32ebb7
...
@@ -970,7 +970,7 @@ class Test(NEOThreadedTest):
...
@@ -970,7 +970,7 @@ class Test(NEOThreadedTest):
self
.
assertFalse
(
storage
.
tm
.
_transaction_dict
)
self
.
assertFalse
(
storage
.
tm
.
_transaction_dict
)
finally
:
finally
:
db
.
close
()
db
.
close
()
# Check we did't get an invalidation, which would cause an
# Check we did
n
't get an invalidation, which would cause an
# assertion failure in the cache. Connection does the same check in
# assertion failure in the cache. Connection does the same check in
# _setstate_noncurrent so this could be also done by starting a
# _setstate_noncurrent so this could be also done by starting a
# transaction before the last one, and clearing the cache before
# transaction before the last one, and clearing the cache before
...
...
neo/tests/threaded/testReplication.py
View file @
6e32ebb7
...
@@ -242,7 +242,7 @@ class ReplicationTests(NEOThreadedTest):
...
@@ -242,7 +242,7 @@ class ReplicationTests(NEOThreadedTest):
More generally, this checks that when a handler raises when a connection
More generally, this checks that when a handler raises when a connection
is closed voluntarily, the connection is in a consistent state and can
is closed voluntarily, the connection is in a consistent state and can
be, for example, closed again after the exception is ca
tched
, without
be, for example, closed again after the exception is ca
ught
, without
assertion failure.
assertion failure.
"""
"""
conn
,
=
backup
.
master
.
getConnectionList
(
backup
.
upstream
.
master
)
conn
,
=
backup
.
master
.
getConnectionList
(
backup
.
upstream
.
master
)
...
...
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