Commit 2264ab3a authored by Yoshinori Okuji's avatar Yoshinori Okuji

Broadcasting messages is supported.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@2003 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent cacdc675
......@@ -59,6 +59,7 @@ class SQLDict(RAMDict):
activity_tool.SQLDict_writeMessage( path = '/'.join(m.object_path) ,
method_id = m.method_id,
priority = m.activity_kw.get('priority', 1),
broadcast = m.activity_kw.get('broadcast', 0),
message = self.dumpMessage(m),
date = m.activity_kw.get('at_date', DateTime()))
# Also store uid of activity
......@@ -239,6 +240,8 @@ class SQLDict(RAMDict):
method_id = line.method_id
if not method_dict.has_key(method_id):
# Only invoke once (it would be different for a queue)
# This is optimisation with the goal to process objects on the same
# node and minimize network traffic with ZEO server
method_dict[method_id] = 1
m = self.loadMessage(line.message, uid = line.uid)
self.deleteMessage(activity_tool, m)
......@@ -283,10 +286,23 @@ class SQLDict(RAMDict):
path_dict = {}
for line in result:
path = line.path
if not path_dict.has_key(path):
broadcast = line.broadcast
if broadcast:
# Broadcast messages must be distributed into all nodes.
uid = line.uid
activity_tool.SQLDict_assignMessage(processing_node=1, uid=[uid])
for node in range(2, node_count+1):
activity_tool.SQLDict_writeMessage( path = path,
method_id = line.method_id,
priority = line.priority,
broadcast = 1,
processing_node = node,
message = line.message,
date = line.date)
elif not path_dict.has_key(path):
# Only assign once (it would be different for a queue)
path_dict[path] = 1
activity_tool.SQLDict_assignMessage(path=path, processing_node=processing_node, uid=None)
activity_tool.SQLDict_assignMessage(path=path, processing_node=processing_node, uid=None, broadcast=0)
get_transaction().commit() # Release locks immediately to allow processing of messages
processing_node = processing_node + 1
if processing_node > node_count:
......@@ -295,7 +311,10 @@ class SQLDict(RAMDict):
# Validation private methods
def _validate_after_method_id(self, activity_tool, message, value):
# Count number of occurances of method_id
result = activity_tool.SQLDict_validateMessageList(method_id=value, message_uid=None, path=None)
if type(value) == type(''):
value = [value]
for method_id in value:
result = activity_tool.SQLDict_validateMessageList(method_id=method_id, message_uid=None, path=None)
if result[0].uid_count > 0:
return INVALID_ORDER
return VALID
......
......@@ -10,7 +10,8 @@ class_file:
<params>path
processing_node
method_id
uid=None</params>
uid
broadcast</params>
UPDATE message
SET
processing_node=<dtml-sqlvar processing_node type="int">,
......@@ -23,3 +24,6 @@ WHERE
path = <dtml-sqlvar path type="string">
<dtml-if method_id>AND method_id = <dtml-sqlvar method_id type="string"></dtml-if>
</dtml-if>
<dtml-if broadcast>
AND broadcast = <dtml-sqlvar broadcast type="int">
</dtml-if>
......@@ -17,6 +17,7 @@ CREATE TABLE `message` (
`processing` INT DEFAULT 0,
`processing_date` datetime,
`priority` INT DEFAULT 0,
`broadcast` INT DEFAULT 0,
`message` BLOB,
PRIMARY KEY (`uid`),
KEY `date` (`date`),
......
......@@ -11,13 +11,16 @@ class_file:
method_id
message
priority
date</params>
broadcast
date
processing_node=-1</params>
INSERT INTO message
SET
path = <dtml-sqlvar path type="string">,
<dtml-if date>date = <dtml-sqlvar date type="string">, <dtml-else>date = <dtml-sqlvar "_.DateTime()" type="string">, </dtml-if>
method_id = <dtml-sqlvar method_id type="string">,
processing_node = -1,
processing_node = <dtml-sqlvar processing_node type="int">,
processing = -1,
priority = <dtml-sqlvar priority type="int">,
broadcast = <dtml-sqlvar broadcast type="int">,
message = <dtml-sqlvar message type="string">
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