Commit a217dc86 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Change the scheduling of active objects.

Now VALIDATION_ERROR_DELAY is in seconds but not in days.
timeShift is performed only for objects assigned to a given node.
SQLDict postpones all active objects which have the same order validation
specification at a time.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4261 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b7365c8c
......@@ -40,9 +40,8 @@ INVALID_PATH = 1
INVALID_ORDER = 2
# Time global parameters
SECONDS_IN_DAY = 86400.0
MAX_PROCESSING_TIME = 900 / SECONDS_IN_DAY # in fractions of day
VALIDATION_ERROR_DELAY = 30 / SECONDS_IN_DAY # in fractions of day
MAX_PROCESSING_TIME = 900 # in seconds
VALIDATION_ERROR_DELAY = 30 # in seconds
class Queue:
"""
......
This diff is collapsed.
......@@ -30,7 +30,7 @@ import random
from Products.CMFActivity.ActivityTool import registerActivity
from RAMQueue import RAMQueue
from DateTime import DateTime
from Queue import VALID, INVALID_ORDER, INVALID_PATH, EXCEPTION, MAX_PROCESSING_TIME, VALIDATION_ERROR_DELAY, SECONDS_IN_DAY
from Queue import VALID, INVALID_ORDER, INVALID_PATH, EXCEPTION, MAX_PROCESSING_TIME, VALIDATION_ERROR_DELAY
from Products.CMFActivity.ActiveObject import DISTRIBUTABLE_STATE, INVOKE_ERROR_STATE, VALIDATE_ERROR_STATE
try:
......@@ -314,11 +314,11 @@ class SQLQueue(RAMQueue):
return VALID
# Required for tests (time shift)
def timeShift(self, activity_tool, delay):
def timeShift(self, activity_tool, delay, processing_node = None):
"""
To simulate timeShift, we simply substract delay from
all dates in SQLDict message table
"""
activity_tool.SQLQueue_timeShift(delay = delay * SECONDS_IN_DAY)
activity_tool.SQLQueue_timeShift(delay = delay, processing_node = processing_node)
registerActivity(SQLQueue)
......@@ -21,6 +21,7 @@ CREATE TABLE `message` (
`group_method_id` VARCHAR(255) DEFAULT '',
`tag` VARCHAR(255),
`retry` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`order_validation_text` VARCHAR(255),
`message` BLOB,
PRIMARY KEY (`uid`),
KEY `date` (`date`),
......@@ -30,5 +31,6 @@ CREATE TABLE `message` (
KEY `processing` (`processing`),
KEY `processing_date` (`processing_date`),
KEY `priority` (`priority`),
KEY `tag` (`tag`)
KEY `tag` (`tag`),
KEY `order_validation_text` (`order_validation_text`)
) TYPE = InnoDB;
......@@ -26,10 +26,10 @@ AND
message
WHERE
processing <> 1
<dtml-if processing_node>AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if>
<dtml-if priority>AND priority = <dtml-sqlvar priority type="int"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"></dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
<dtml-if processing_node> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if>
<dtml-if priority> AND priority = <dtml-sqlvar priority type="int"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"> </dtml-if>
<dtml-if method_id> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
GROUP BY
path, method_id, processing_node, processing
ORDER BY
......
......@@ -16,6 +16,6 @@ SELECT uid FROM
WHERE
processing <> 1
<dtml-if processing_node> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if>
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"> </dtml-if>
<dtml-if to_date>AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if>
<dtml-if method_id> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
<dtml-if path> AND path = <dtml-sqlvar path type="string"> </dtml-if>
<dtml-if to_date> AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if>
......@@ -10,16 +10,37 @@ class_file:
<params>uid:list
priority
date
retry</params>
retry
delay
processing_node
order_validation_text</params>
UPDATE
message
SET
priority = <dtml-sqlvar priority type="int">,
processing = 0,
date = <dtml-sqlvar date type="datetime">
processing = 0
<dtml-if priority>
, priority = <dtml-sqlvar priority type="int">
</dtml-if>
<dtml-if delay>
, date = DATE_ADD(NOW(), INTERVAL <dtml-sqlvar delay type="int"> * (retry + 1) SECOND)
<dtml-elif date>
, date = <dtml-sqlvar date type="datetime">
</dtml-if>
<dtml-if retry>
, retry = <dtml-sqlvar retry type="int">
, retry = retry + <dtml-sqlvar retry type="int">
</dtml-if>
WHERE
<dtml-in uid>uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else>
OR </dtml-if></dtml-in>
1 = 1
<dtml-if uid>
AND (
<dtml-in uid>
uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if>
</dtml-in>
)
</dtml-if>
<dtml-if processing_node>
AND processing_node = <dtml-sqlvar processing_node type="int">
</dtml-if>
<dtml-if order_validation_text>
AND order_validation_text = <dtml-sqlvar order_validation_text type="string">
</dtml-if>
\ No newline at end of file
......@@ -7,9 +7,15 @@ cache_time:0
class_name:
class_file:
</dtml-comment>
<params>delay</params>
<params>delay
processing_node</params>
UPDATE
message
SET
date = date - <dtml-sqlvar delay type="int">,
processing_date = processing_date - <dtml-sqlvar delay type="int">
date = DATE_SUB(date, INTERVAL <dtml-sqlvar delay type="int"> SECOND),
processing_date = DATE_SUB(processing_date, INTERVAL <dtml-sqlvar delay type="int"> SECOND)
WHERE
1 = 1
<dtml-if processing_node>
AND processing_node = <dtml-sqlvar processing_node type="int">
</dtml-if>
\ No newline at end of file
......@@ -15,7 +15,8 @@ broadcast
date
processing_node=-1
group_method_id
tag</params>
tag
order_validation_text</params>
INSERT INTO message
SET
path = <dtml-sqlvar path type="string">,
......@@ -27,4 +28,5 @@ SET
broadcast = <dtml-sqlvar broadcast type="int">,
group_method_id = <dtml-sqlvar group_method_id type="string">,
tag = <dtml-sqlvar tag type="string">,
order_validation_text = <dtml-sqlvar order_validation_text type="string">,
message = <dtml-sqlvar message type="string">
......@@ -15,9 +15,10 @@ broadcast_list
date_list
processing_node_list
group_method_id_list
tag_list</params>
tag_list
order_validation_text_list</params>
INSERT INTO message
(path, date, method_id, processing_node, processing, priority, broadcast, group_method_id, tag, message)
(path, date, method_id, processing_node, processing, priority, broadcast, group_method_id, tag, order_validation_text, message)
VALUES
<dtml-in prefix="loop" expr="_.range(_.len(path_list))">
<dtml-if sequence-start><dtml-else>,</dtml-if>
......@@ -31,6 +32,7 @@ VALUES
<dtml-sqlvar expr="broadcast_list[loop_item]" type="int">,
<dtml-sqlvar expr="group_method_id_list[loop_item]" type="string">,
<dtml-sqlvar expr="tag_list[loop_item]" type="string">,
<dtml-sqlvar expr="order_validation_text_list[loop_item]" type="string">,
<dtml-sqlvar expr="message_list[loop_item]" type="string">
)
</dtml-in>
......@@ -7,9 +7,15 @@ cache_time:0
class_name:
class_file:
</dtml-comment>
<params>delay</params>
<params>delay
processing_node</params>
UPDATE
message_queue
SET
date = date - <dtml-sqlvar delay type="int">,
processing_date = processing_date - <dtml-sqlvar delay type="int">
WHERE
1 = 1
<dtml-if processing_node>
AND processing_node = <dtml-sqlvar processing_node type="int">
</dtml-if>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment