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 ...@@ -40,9 +40,8 @@ INVALID_PATH = 1
INVALID_ORDER = 2 INVALID_ORDER = 2
# Time global parameters # Time global parameters
SECONDS_IN_DAY = 86400.0 MAX_PROCESSING_TIME = 900 # in seconds
MAX_PROCESSING_TIME = 900 / SECONDS_IN_DAY # in fractions of day VALIDATION_ERROR_DELAY = 30 # in seconds
VALIDATION_ERROR_DELAY = 30 / SECONDS_IN_DAY # in fractions of day
class Queue: class Queue:
""" """
......
This diff is collapsed.
...@@ -30,7 +30,7 @@ import random ...@@ -30,7 +30,7 @@ import random
from Products.CMFActivity.ActivityTool import registerActivity from Products.CMFActivity.ActivityTool import registerActivity
from RAMQueue import RAMQueue from RAMQueue import RAMQueue
from DateTime import DateTime 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 from Products.CMFActivity.ActiveObject import DISTRIBUTABLE_STATE, INVOKE_ERROR_STATE, VALIDATE_ERROR_STATE
try: try:
...@@ -314,11 +314,11 @@ class SQLQueue(RAMQueue): ...@@ -314,11 +314,11 @@ class SQLQueue(RAMQueue):
return VALID return VALID
# Required for tests (time shift) # 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 To simulate timeShift, we simply substract delay from
all dates in SQLDict message table 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) registerActivity(SQLQueue)
...@@ -21,6 +21,7 @@ CREATE TABLE `message` ( ...@@ -21,6 +21,7 @@ CREATE TABLE `message` (
`group_method_id` VARCHAR(255) DEFAULT '', `group_method_id` VARCHAR(255) DEFAULT '',
`tag` VARCHAR(255), `tag` VARCHAR(255),
`retry` TINYINT UNSIGNED NOT NULL DEFAULT 0, `retry` TINYINT UNSIGNED NOT NULL DEFAULT 0,
`order_validation_text` VARCHAR(255),
`message` BLOB, `message` BLOB,
PRIMARY KEY (`uid`), PRIMARY KEY (`uid`),
KEY `date` (`date`), KEY `date` (`date`),
...@@ -30,5 +31,6 @@ CREATE TABLE `message` ( ...@@ -30,5 +31,6 @@ CREATE TABLE `message` (
KEY `processing` (`processing`), KEY `processing` (`processing`),
KEY `processing_date` (`processing_date`), KEY `processing_date` (`processing_date`),
KEY `priority` (`priority`), KEY `priority` (`priority`),
KEY `tag` (`tag`) KEY `tag` (`tag`),
KEY `order_validation_text` (`order_validation_text`)
) TYPE = InnoDB; ) TYPE = InnoDB;
...@@ -26,10 +26,10 @@ AND ...@@ -26,10 +26,10 @@ AND
message message
WHERE WHERE
processing <> 1 processing <> 1
<dtml-if processing_node>AND processing_node = <dtml-sqlvar processing_node type="int"> </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 priority> AND priority = <dtml-sqlvar priority type="int"> </dtml-if>
<dtml-if path>AND path = <dtml-sqlvar path type="string"></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 method_id> AND method_id = <dtml-sqlvar method_id type="string"> </dtml-if>
GROUP BY GROUP BY
path, method_id, processing_node, processing path, method_id, processing_node, processing
ORDER BY ORDER BY
......
...@@ -16,6 +16,6 @@ SELECT uid FROM ...@@ -16,6 +16,6 @@ SELECT uid FROM
WHERE WHERE
processing <> 1 processing <> 1
<dtml-if processing_node> AND processing_node = <dtml-sqlvar processing_node type="int"> </dtml-if> <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 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 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 to_date> AND date <= <dtml-sqlvar to_date type="datetime"> </dtml-if>
...@@ -10,16 +10,37 @@ class_file: ...@@ -10,16 +10,37 @@ class_file:
<params>uid:list <params>uid:list
priority priority
date date
retry</params> retry
delay
processing_node
order_validation_text</params>
UPDATE UPDATE
message message
SET SET
priority = <dtml-sqlvar priority type="int">, processing = 0
processing = 0, <dtml-if priority>
date = <dtml-sqlvar date type="datetime"> , 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> <dtml-if retry>
, retry = <dtml-sqlvar retry type="int"> , retry = retry + <dtml-sqlvar retry type="int">
</dtml-if> </dtml-if>
WHERE WHERE
<dtml-in uid>uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> 1 = 1
OR </dtml-if></dtml-in> <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 ...@@ -7,9 +7,15 @@ cache_time:0
class_name: class_name:
class_file: class_file:
</dtml-comment> </dtml-comment>
<params>delay</params> <params>delay
processing_node</params>
UPDATE UPDATE
message message
SET SET
date = date - <dtml-sqlvar delay type="int">, date = DATE_SUB(date, INTERVAL <dtml-sqlvar delay type="int"> SECOND),
processing_date = processing_date - <dtml-sqlvar delay type="int"> 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 ...@@ -15,7 +15,8 @@ broadcast
date date
processing_node=-1 processing_node=-1
group_method_id group_method_id
tag</params> tag
order_validation_text</params>
INSERT INTO message INSERT INTO message
SET SET
path = <dtml-sqlvar path type="string">, path = <dtml-sqlvar path type="string">,
...@@ -27,4 +28,5 @@ SET ...@@ -27,4 +28,5 @@ SET
broadcast = <dtml-sqlvar broadcast type="int">, broadcast = <dtml-sqlvar broadcast type="int">,
group_method_id = <dtml-sqlvar group_method_id type="string">, group_method_id = <dtml-sqlvar group_method_id type="string">,
tag = <dtml-sqlvar tag type="string">, tag = <dtml-sqlvar tag type="string">,
order_validation_text = <dtml-sqlvar order_validation_text type="string">,
message = <dtml-sqlvar message type="string"> message = <dtml-sqlvar message type="string">
...@@ -15,9 +15,10 @@ broadcast_list ...@@ -15,9 +15,10 @@ broadcast_list
date_list date_list
processing_node_list processing_node_list
group_method_id_list group_method_id_list
tag_list</params> tag_list
order_validation_text_list</params>
INSERT INTO message 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 VALUES
<dtml-in prefix="loop" expr="_.range(_.len(path_list))"> <dtml-in prefix="loop" expr="_.range(_.len(path_list))">
<dtml-if sequence-start><dtml-else>,</dtml-if> <dtml-if sequence-start><dtml-else>,</dtml-if>
...@@ -31,6 +32,7 @@ VALUES ...@@ -31,6 +32,7 @@ VALUES
<dtml-sqlvar expr="broadcast_list[loop_item]" type="int">, <dtml-sqlvar expr="broadcast_list[loop_item]" type="int">,
<dtml-sqlvar expr="group_method_id_list[loop_item]" type="string">, <dtml-sqlvar expr="group_method_id_list[loop_item]" type="string">,
<dtml-sqlvar expr="tag_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-sqlvar expr="message_list[loop_item]" type="string">
) )
</dtml-in> </dtml-in>
...@@ -7,9 +7,15 @@ cache_time:0 ...@@ -7,9 +7,15 @@ cache_time:0
class_name: class_name:
class_file: class_file:
</dtml-comment> </dtml-comment>
<params>delay</params> <params>delay
processing_node</params>
UPDATE UPDATE
message_queue message_queue
SET SET
date = date - <dtml-sqlvar delay type="int">, date = date - <dtml-sqlvar delay type="int">,
processing_date = processing_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