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
Carlos Ramos Carreño
neoppod
Commits
81c93b67
Commit
81c93b67
authored
Sep 28, 2011
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coding style changes and small optimizations
With the change in TransactionManager, there's 1 comparison less.
parent
b2f51e77
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
41 deletions
+32
-41
neo/lib/connector.py
neo/lib/connector.py
+7
-10
neo/lib/event.py
neo/lib/event.py
+2
-5
neo/master/transactions.py
neo/master/transactions.py
+1
-1
neo/storage/replicator.py
neo/storage/replicator.py
+1
-1
neo/storage/transactions.py
neo/storage/transactions.py
+21
-24
No files found.
neo/lib/connector.py
View file @
81c93b67
...
...
@@ -170,13 +170,13 @@ class SocketConnector:
raise
NotImplementedError
class
SocketConnectorIPv4
(
SocketConnector
):
" Wrapper for IPv4 sockets"
af_type
=
socket
.
AF_INET
" Wrapper for IPv4 sockets"
af_type
=
socket
.
AF_INET
def
_accept
(
self
):
return
self
.
socket
.
accept
()
def
_accept
(
self
):
return
self
.
socket
.
accept
()
def
getAddress
(
self
):
def
getAddress
(
self
):
return
self
.
socket
.
getsockname
()
class
SocketConnectorIPv6
(
SocketConnector
):
...
...
@@ -185,13 +185,10 @@ class SocketConnectorIPv6(SocketConnector):
def
_accept
(
self
):
new_s
,
addr
=
self
.
socket
.
accept
()
addr
=
(
addr
[
0
],
addr
[
1
])
return
(
new_s
,
addr
)
return
new_s
,
addr
[:
2
]
def
getAddress
(
self
):
addr
=
self
.
socket
.
getsockname
()
addr
=
(
addr
[
0
],
addr
[
1
])
return
addr
return
self
.
socket
.
getsockname
()[:
2
]
registerConnectorHandler
(
SocketConnectorIPv4
)
registerConnectorHandler
(
SocketConnectorIPv6
)
...
...
neo/lib/event.py
View file @
81c93b67
...
...
@@ -78,11 +78,8 @@ class EpollEventManager(object):
del
self
.
connection_dict
[
fd
]
def
_getPendingConnection
(
self
):
if
len
(
self
.
_pending_processing
):
result
=
self
.
_pending_processing
.
pop
(
0
)
else
:
result
=
None
return
result
if
self
.
_pending_processing
:
return
self
.
_pending_processing
.
pop
(
0
)
def
_addPendingConnection
(
self
,
conn
):
pending_processing
=
self
.
_pending_processing
...
...
neo/master/transactions.py
View file @
81c93b67
...
...
@@ -357,7 +357,7 @@ class TransactionManager(object):
# will be finished
for
txn
in
self
.
_ttid_dict
.
itervalues
():
txn
.
registerForNotification
(
uuid
)
return
set
(
self
.
_ttid_dict
.
keys
()
)
return
set
(
self
.
_ttid_dict
)
def
begin
(
self
,
node
,
tid
=
None
):
"""
...
...
neo/storage/replicator.py
View file @
81c93b67
...
...
@@ -187,7 +187,7 @@ class Replicator(object):
def
pending
(
self
):
"""Return whether there is any pending partition."""
return
len
(
self
.
partition_dict
)
or
len
(
self
.
new_partition_set
)
return
bool
(
self
.
partition_dict
or
self
.
new_partition_set
)
def
getCurrentOffset
(
self
):
assert
self
.
current_partition
is
not
None
...
...
neo/storage/transactions.py
View file @
81c93b67
...
...
@@ -247,31 +247,17 @@ class TransactionManager(object):
self
.
_app
.
executeQueuedEvents
()
# Attemp to acquire lock again.
locking_tid
=
self
.
_store_lock_dict
.
get
(
oid
)
if
locking_tid
in
(
None
,
ttid
):
# check if this is generated from the latest revision.
if
locking_tid
==
ttid
:
# If previous store was an undo, next store must be based on
# undo target.
_
,
_
,
_
,
_
,
previous_serial
=
self
.
_transaction_dict
[
ttid
].
getObject
(
oid
)
if
previous_serial
is
None
:
# XXX: use some special serial when previous store was not
# an undo ? Maybe it should just not happen.
neo
.
lib
.
logging
.
info
(
'Transaction %s storing %s more than '
'once'
,
dump
(
ttid
),
dump
(
oid
))
else
:
previous_serial
=
None
if
locking_tid
is
None
:
previous_serial
=
None
elif
locking_tid
==
ttid
:
# If previous store was an undo, next store must be based on
# undo target.
previous_serial
=
self
.
_transaction_dict
[
ttid
].
getObject
(
oid
)[
4
]
if
previous_serial
is
None
:
history_list
=
self
.
_app
.
dm
.
getObjectHistory
(
oid
)
if
history_list
:
previous_serial
=
history_list
[
0
][
0
]
if
previous_serial
is
not
None
and
previous_serial
!=
serial
:
neo
.
lib
.
logging
.
info
(
'Resolvable conflict on %r:%r'
,
dump
(
oid
),
dump
(
ttid
))
raise
ConflictError
(
previous_serial
)
neo
.
lib
.
logging
.
debug
(
'Transaction %s storing %s'
,
dump
(
ttid
),
dump
(
oid
))
self
.
_store_lock_dict
[
oid
]
=
ttid
# XXX: use some special serial when previous store was not
# an undo ? Maybe it should just not happen.
neo
.
lib
.
logging
.
info
(
'Transaction %s storing %s more than '
'once'
,
dump
(
ttid
),
dump
(
oid
))
elif
locking_tid
<
ttid
:
# We have a bigger TTID than locking transaction, so we are younger:
# enter waiting queue so we are handled when lock gets released.
...
...
@@ -289,6 +275,17 @@ class TransactionManager(object):
neo
.
lib
.
logging
.
info
(
'Possible deadlock on %r:%r with %r'
,
dump
(
oid
),
dump
(
ttid
),
dump
(
locking_tid
))
raise
ConflictError
(
ZERO_TID
)
if
previous_serial
is
None
:
history_list
=
self
.
_app
.
dm
.
getObjectHistory
(
oid
)
if
history_list
:
previous_serial
=
history_list
[
0
][
0
]
if
previous_serial
is
not
None
and
previous_serial
!=
serial
:
neo
.
lib
.
logging
.
info
(
'Resolvable conflict on %r:%r'
,
dump
(
oid
),
dump
(
ttid
))
raise
ConflictError
(
previous_serial
)
neo
.
lib
.
logging
.
debug
(
'Transaction %s storing %s'
,
dump
(
ttid
),
dump
(
oid
))
self
.
_store_lock_dict
[
oid
]
=
ttid
def
checkCurrentSerial
(
self
,
ttid
,
serial
,
oid
):
self
.
lockObject
(
ttid
,
serial
,
oid
,
unlock
=
True
)
...
...
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