Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Sebastian
erp5
Commits
6f54f10e
Commit
6f54f10e
authored
Jan 13, 2012
by
Julien Muchembled
Committed by
Tatuya Kamada
Dec 19, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ConflictFreeLog: fix conflict resolution
parent
10e16f2c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
product/ERP5Type/ConflictFree.py
product/ERP5Type/ConflictFree.py
+17
-3
No files found.
product/ERP5Type/ConflictFree.py
View file @
6f54f10e
...
...
@@ -2,6 +2,9 @@ from persistent import Persistent
class
ConflictFreeLog
(
Persistent
):
"""Scalable conflict-free append-only double-linked list
Wasted ZODB space due to conflicts is roughly proportional to the number of
clients that continuously add items at the same time.
"""
_prev
=
_next
=
None
_tail_count
=
0
...
...
@@ -70,9 +73,20 @@ class ConflictFreeLog(Persistent):
break
def
_p_resolveConflict
(
self
,
old_state
,
saved_state
,
new_state
):
if
old_state
.
get
(
'_tail_count'
,
0
)
==
new_state
.
get
(
'_tail_count'
,
0
):
i
=
len
(
old_state
[
'_log'
])
else
:
# May be called for the head and its predecessor.
old_tail_count
=
old_state
.
get
(
'_tail_count'
,
0
)
d
=
new_state
.
get
(
'_tail_count'
,
0
)
-
old_tail_count
if
d
:
if
old_tail_count
==
saved_state
.
get
(
'_tail_count'
,
0
):
# We are the first one to rotate. Really rotate.
# Only the head conflicts in this case.
return
dict
(
new_state
,
_log
=
saved_state
[
'_log'
][
d
:]
+
new_state
[
'_log'
])
# Another node rotated before us. Revert our rotation.
# Both the head and its predecessor conflict.
i
=
0
else
:
# We didn't rotate. Just add our items to saved head.
# Only the head conflicts.
i
=
len
(
old_state
[
'_log'
])
saved_state
[
'_log'
].
extend
(
new_state
[
'_log'
][
i
:])
return
saved_state
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