From 73673127f55ec27ec6672863bac288e7ab6cb0a5 Mon Sep 17 00:00:00 2001 From: Antony Chazapis Date: Tue, 10 Apr 2012 11:32:32 +0300 Subject: [PATCH] Include instance in queue messages. --- snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py | 4 ++-- snf-pithos-backend/pithos/backends/modular.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py b/snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py index c304a6e..feb011e 100644 --- a/snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py +++ b/snf-pithos-backend/pithos/backends/lib/rabbitmq/queue.py @@ -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): diff --git a/snf-pithos-backend/pithos/backends/modular.py b/snf-pithos-backend/pithos/backends/modular.py index 576ec80..0dfd580 100644 --- a/snf-pithos-backend/pithos/backends/modular.py +++ b/snf-pithos-backend/pithos/backends/modular.py @@ -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. -- 1.7.10.4