Include instance in queue messages.
authorAntony Chazapis <chazapis@gmail.com>
Tue, 10 Apr 2012 08:32:32 +0000 (11:32 +0300)
committerAntony Chazapis <chazapis@gmail.com>
Tue, 10 Apr 2012 08:32:32 +0000 (11:32 +0300)
snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py
snf-pithos-backend/pithos/backends/modular.py

index c304a6e..feb011e 100644 (file)
@@ -44,8 +44,8 @@ class Queue(object):
         self.conn = exchange_connect(exchange)
         self.client_id = params['client_id']
     
-    def send(self, message_key, user, resource, value, details):
-        body = Receipt(self.client_id, user, resource, value, details).format()
+    def send(self, message_key, user, instance, resource, value, details):
+        body = Receipt(self.client_id, user, instance, resource, value, details).format()
         exchange_send(self.conn, message_key, body)
     
     def close(self):
index 576ec80..0dfd580 100644 (file)
@@ -79,6 +79,7 @@ DEFAULT_BLOCK_PATH = 'data/'
 
 QUEUE_MESSAGE_KEY_PREFIX = 'pithos.%s'
 QUEUE_CLIENT_ID = 'pithos'
+QUEUE_INSTANCE_ID = '1'
 
 ( CLUSTER_NORMAL, CLUSTER_HISTORY, CLUSTER_DELETED ) = range(3)
 
@@ -1010,12 +1011,12 @@ class ModularBackend(BaseBackend):
         account_node = self._lookup_account(account, True)[1]
         total = self._get_statistics(account_node)[1]
         details.update({'user': user, 'total': total})
-        self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('resource.diskspace',), account, 'diskspace', size, details))
+        self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('resource.diskspace',), account, QUEUE_INSTANCE_ID, 'diskspace', float(size), details))
     
     def _report_object_change(self, user, account, path, details={}):
         logger.debug("_report_object_change: %s %s %s %s", user, account, path, details)
         details.update({'user': user})
-        self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('object',), account, 'object', path, details))
+        self.messages.append((QUEUE_MESSAGE_KEY_PREFIX % ('object',), account, QUEUE_INSTANCE_ID, 'object', path, details))
     
     # Policy functions.