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
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
Binh
erp5
Commits
77424415
Commit
77424415
authored
Feb 18, 2019
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CMFActivity: enable node preference by default in some safe cases
parent
301962ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
3 deletions
+21
-3
product/CMFActivity/ActiveObject.py
product/CMFActivity/ActiveObject.py
+2
-0
product/CMFActivity/ActivityTool.py
product/CMFActivity/ActivityTool.py
+18
-2
product/CMFActivity/tests/testCMFActivity.py
product/CMFActivity/tests/testCMFActivity.py
+1
-1
No files found.
product/CMFActivity/ActiveObject.py
View file @
77424415
...
@@ -68,6 +68,8 @@ class ActiveObject(ExtensionClass.Base):
...
@@ -68,6 +68,8 @@ class ActiveObject(ExtensionClass.Base):
- "same": prefer execution on this node, to make
- "same": prefer execution on this node, to make
better use of the ZODB Storage cache
better use of the ZODB Storage cache
- "": no node preference
- "": no node preference
- None (default): let CMFActivity decide between the above 2 choice
(see ActivityTool.activateObject)
at_date -- request execution date for this activate call
at_date -- request execution date for this activate call
(default: date of commit)
(default: date of commit)
...
...
product/CMFActivity/ActivityTool.py
View file @
77424415
...
@@ -91,6 +91,11 @@ _server_address = None
...
@@ -91,6 +91,11 @@ _server_address = None
ROLE_IDLE
=
0
ROLE_IDLE
=
0
ROLE_PROCESSING
=
1
ROLE_PROCESSING
=
1
# Activating a path means we tried to avoid loading useless
# data in cache so there would be no gain to expect.
# And all nodes are likely to have tools already loaded.
NO_DEFAULT_NODE_PREFERENCE
=
str
,
BaseTool
# Logging channel definitions
# Logging channel definitions
import
logging
import
logging
# Main logging channel
# Main logging channel
...
@@ -1205,14 +1210,25 @@ class ActivityTool (BaseTool):
...
@@ -1205,14 +1210,25 @@ class ActivityTool (BaseTool):
url
=
object
.
getPhysicalPath
()
url
=
object
.
getPhysicalPath
()
if
serialization_tag
is
not
None
:
if
serialization_tag
is
not
None
:
kw
[
'serialization_tag'
]
=
serialization_tag
kw
[
'serialization_tag'
]
=
serialization_tag
if
node
is
not
None
:
while
1
:
# not a loop
if
node
!=
'same'
:
if
node
is
None
:
# The caller lets us decide whether we prefer to execute on same node
# (to increase the efficiency of the ZODB Storage cache).
if
(
isinstance
(
object
,
NO_DEFAULT_NODE_PREFERENCE
)
# A grouped activity is the sign we may have many of them so make
# sure that this node won't overprioritize too many activities.
or
kw
.
get
(
'group_method_id'
,
''
)
!=
''
):
break
elif
node
==
''
:
break
elif
node
!=
'same'
:
raise
ValueError
(
"Invalid node argument %r"
%
node
)
raise
ValueError
(
"Invalid node argument %r"
%
node
)
try
:
try
:
kw
[
'node'
]
=
1
+
self
.
getNodeList
(
kw
[
'node'
]
=
1
+
self
.
getNodeList
(
role
=
ROLE_PROCESSING
).
index
(
getCurrentNode
())
role
=
ROLE_PROCESSING
).
index
(
getCurrentNode
())
except
ValueError
:
except
ValueError
:
pass
pass
break
return
ActiveWrapper
(
self
,
url
,
oid
,
activity
,
return
ActiveWrapper
(
self
,
url
,
oid
,
activity
,
active_process
,
active_process_uid
,
kw
,
active_process
,
active_process_uid
,
kw
,
getattr
(
self
,
'REQUEST'
,
None
))
getattr
(
self
,
'REQUEST'
,
None
))
...
...
product/CMFActivity/tests/testCMFActivity.py
View file @
77424415
...
@@ -2490,7 +2490,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
...
@@ -2490,7 +2490,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
activities
=
'SQLDict'
,
'SQLQueue'
activities
=
'SQLDict'
,
'SQLQueue'
for
activities
in
product
(
activities
,
activities
):
for
activities
in
product
(
activities
,
activities
):
for
node
,
expected
in
(
None
,
'
21'
),
(
"same"
,
'12'
):
for
node
,
expected
in
(
None
,
'
12'
),
(
''
,
'21'
),
(
'same'
,
'12'
):
o
.
_setTitle
(
'0'
)
o
.
_setTitle
(
'0'
)
# The dance around getNodeDict is to simulate the creation of
# The dance around getNodeDict is to simulate the creation of
# activities from 2 different nodes. We also change title in 2
# activities from 2 different nodes. We also change title in 2
...
...
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