~ubuntu-cloud-archive/ubuntu/precise/nova/trunk

« back to all changes in this revision

Viewing changes to nova/rpc/common.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandleman
  • Date: 2012-01-13 09:51:10 UTC
  • mfrom: (1.1.40)
  • Revision ID: package-import@ubuntu.com-20120113095110-ffd6163drcg77wez
Tags: 2012.1~e3~20120113.12049-0ubuntu1
[Chuck Short]
* New upstream version.
* debian/nova_sudoers, debian/nova-common.install, 
  Switch out to nova-rootwrap. (LP: #681774)
* Add "get-origsource-git" which allows developers to 
  generate a tarball from github, by doing:
  fakeroot debian/rules get-orig-source-git
* debian/debian/nova-objectstore.logrotate: Dont determine
  if we are running Debian or Ubuntu. (LP: #91379)

[Adam Gandleman]
* Removed python-nova.postinst, let dh_python2 generate instead since
  python-support is not a dependency. (LP: #907543)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# vim: tabstop=4 shiftwidth=4 softtabstop=4
 
2
 
 
3
# Copyright 2010 United States Government as represented by the
 
4
# Administrator of the National Aeronautics and Space Administration.
 
5
# All Rights Reserved.
 
6
# Copyright 2011 Red Hat, Inc.
 
7
#
 
8
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
 
9
#    not use this file except in compliance with the License. You may obtain
 
10
#    a copy of the License at
 
11
#
 
12
#         http://www.apache.org/licenses/LICENSE-2.0
 
13
#
 
14
#    Unless required by applicable law or agreed to in writing, software
 
15
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 
16
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 
17
#    License for the specific language governing permissions and limitations
 
18
#    under the License.
 
19
 
 
20
 
1
21
from nova import exception
2
22
from nova import flags
3
23
from nova import log as logging
26
46
        self.value = value
27
47
        self.traceback = traceback
28
48
        super(RemoteError, self).__init__(**self.__dict__)
 
49
 
 
50
 
 
51
class Connection(object):
 
52
    """A connection, returned by rpc.create_connection().
 
53
 
 
54
    This class represents a connection to the message bus used for rpc.
 
55
    An instance of this class should never be created by users of the rpc API.
 
56
    Use rpc.create_connection() instead.
 
57
    """
 
58
    def close(self):
 
59
        """Close the connection.
 
60
 
 
61
        This method must be called when the connection will no longer be used.
 
62
        It will ensure that any resources associated with the connection, such
 
63
        as a network connection, and cleaned up.
 
64
        """
 
65
        raise NotImplementedError()
 
66
 
 
67
    def create_consumer(self, topic, proxy, fanout=False):
 
68
        """Create a consumer on this connection.
 
69
 
 
70
        A consumer is associated with a message queue on the backend message
 
71
        bus.  The consumer will read messages from the queue, unpack them, and
 
72
        dispatch them to the proxy object.  The contents of the message pulled
 
73
        off of the queue will determine which method gets called on the proxy
 
74
        object.
 
75
 
 
76
        :param topic: This is a name associated with what to consume from.
 
77
                      Multiple instances of a service may consume from the same
 
78
                      topic. For example, all instances of nova-compute consume
 
79
                      from a queue called "compute".  In that case, the
 
80
                      messages will get distributed amongst the consumers in a
 
81
                      round-robin fashion if fanout=False.  If fanout=True,
 
82
                      every consumer associated with this topic will get a
 
83
                      copy of every message.
 
84
        :param proxy: The object that will handle all incoming messages.
 
85
        :param fanout: Whether or not this is a fanout topic.  See the
 
86
                       documentation for the topic parameter for some
 
87
                       additional comments on this.
 
88
        """
 
89
        raise NotImplementedError()
 
90
 
 
91
    def consume_in_thread(self):
 
92
        """Spawn a thread to handle incoming messages.
 
93
 
 
94
        Spawn a thread that will be responsible for handling all incoming
 
95
        messages for consumers that were set up on this connection.
 
96
 
 
97
        Message dispatching inside of this is expected to be implemented in a
 
98
        non-blocking manner.  An example implementation would be having this
 
99
        thread pull messages in for all of the consumers, but utilize a thread
 
100
        pool for dispatching the messages to the proxy objects.
 
101
        """
 
102
        raise NotImplementedError()