Previous topic

The nova.openstack.common.rpc.amqp Module

Next topic

The nova.openstack.common.rpc.dispatcher Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.openstack.common.rpc.common Module

class CommonRpcContext(**kwargs)

Bases: object

deepcopy()
elevated(read_deleted=None, overwrite=False)

Return a version of this context with admin flag set.

classmethod from_dict(values)
to_dict()
update_store()
class Connection

Bases: object

A connection, returned by rpc.create_connection().

This class represents a connection to the message bus used for rpc. An instance of this class should never be created by users of the rpc API. Use rpc.create_connection() instead.

close()

Close the connection.

This method must be called when the connection will no longer be used. It will ensure that any resources associated with the connection, such as a network connection, and cleaned up.

consume_in_thread()

Spawn a thread to handle incoming messages.

Spawn a thread that will be responsible for handling all incoming messages for consumers that were set up on this connection.

Message dispatching inside of this is expected to be implemented in a non-blocking manner. An example implementation would be having this thread pull messages in for all of the consumers, but utilize a thread pool for dispatching the messages to the proxy objects.

create_consumer(conf, topic, proxy, fanout=False)

Create a consumer on this connection.

A consumer is associated with a message queue on the backend message bus. The consumer will read messages from the queue, unpack them, and dispatch them to the proxy object. The contents of the message pulled off of the queue will determine which method gets called on the proxy object.

Parameters:
  • conf – An openstack.common.cfg configuration object.
  • topic – This is a name associated with what to consume from. Multiple instances of a service may consume from the same topic. For example, all instances of nova-compute consume from a queue called “compute”. In that case, the messages will get distributed amongst the consumers in a round-robin fashion if fanout=False. If fanout=True, every consumer associated with this topic will get a copy of every message.
  • proxy – The object that will handle all incoming messages.
  • fanout – Whether or not this is a fanout topic. See the documentation for the topic parameter for some additional comments on this.
create_worker(conf, topic, proxy, pool_name)

Create a worker on this connection.

A worker is like a regular consumer of messages directed to a topic, except that it is part of a set of such consumers (the “pool”) which may run in parallel. Every pool of workers will receive a given message, but only one worker in the pool will be asked to process it. Load is distributed across the members of the pool in round-robin fashion.

Parameters:
  • conf – An openstack.common.cfg configuration object.
  • topic – This is a name associated with what to consume from. Multiple instances of a service may consume from the same topic.
  • proxy – The object that will handle all incoming messages.
  • pool_name – String containing the name of the pool of workers
exception InvalidRPCConnectionReuse(message=None, **kwargs)

Bases: nova.openstack.common.rpc.common.RPCException

message = u'Invalid reuse of an RPC connection.'
exception RPCException(message=None, **kwargs)

Bases: exceptions.Exception

message = u'An unknown RPC related exception occurred.'
exception RemoteError(exc_type=None, value=None, traceback=None)

Bases: nova.openstack.common.rpc.common.RPCException

Signifies that a remote class has raised an exception.

Contains a string representation of the type of the original exception, the value of the original exception, and the traceback. These are sent to the parent as a joined string so printing the exception contains all of the relevant info.

message = u'Remote error: %(exc_type)s %(value)s\n%(traceback)s.'
exception Timeout(message=None, **kwargs)

Bases: nova.openstack.common.rpc.common.RPCException

Signifies that a timeout has occurred.

This exception is raised if the rpc_response_timeout is reached while waiting for a response from the remote side.

message = u'Timeout while waiting on RPC response.'
exception UnsupportedRpcVersion(message=None, **kwargs)

Bases: nova.openstack.common.rpc.common.RPCException

message = u'Specified RPC version, %(version)s, not supported by this endpoint.'
deserialize_remote_exception(conf, data)
serialize_remote_exception(failure_info)

Prepares exception data to be sent over rpc.

Failure_info should be a sys.exc_info() tuple.