Apache Qpid : Management Design notes
This page last changed on Aug 26, 2008 by tross.
Status of This DocumentThis document does not track any current development activity. It is the specification of the management framework implemented in the M3 release of the C++ broker and will be left here for user and developer reference. Development continues on the Qpid Management Framework (QMF) for M4. If you are using M3, this is the document you need. If you are using the SVN trunk, please refer to Qpid Management Framework for up-to-date information. IntroductionThis document describes the management features that are used in the QPID C++ broker as of the M3 milestone. These features do not appear in earlier milestones nor are they implemented in the Java broker. This specification is not a standard and is not endorsed by the AMQP working group. When such a standard is adopted, the QPID implementation will be brought into compliance with that standard. Links
Design note for getting info in and out via JMXManagement Requirements
Definition of Terms
Operational Scenarios: Basic vs. ExtendedThe extensibility requirement introduces complexity to the management protocol that is unnecessary and undesirable for the user/developer that wishes only to manage QPID message brokers. For this reason, the protocol is partitioned into two parts: The basic protocol, which contains only the capability to manage a single broker; and the extended protocol, which provides the hooks for managing an extended set of components. A management console can be implemented using only the basic protocol if the extended capabilities are not needed. Architectural FrameworkThe Management ExchangeThe management exchange (called "qpid.management" currently) is a special type of exchange used for remote management access to the Qpid broker. The management exchange is an extension of the standard "Topic" exchange. It behaves like a topic exchange with the following exceptions:
Routing Key StructureAs noted above, the structure of the binding and routing keys used on the management exchange is important to the function of the management architecture. The routing key of a management message determines:
Placing this information in the routing key provides the ability to enforce access control at class, operation, and method granularity. It also separates the command structure from the content of the management message (i.e. element values) allowing the content to be encrypted and signed end-to-end while still allowing access control at the message-transport level. This means that special access control code need not be written for the management agent.
In both cases, the content of the message (i.e. method arguments, element values, etc.) is carried in the body segment of the message. The <package> namespace allows this management framework to be extended with the addition of other software packages. The ProtocolProtocol HeaderThe body segments of management messages are composed of sequences of binary-encoded data fields, in a manner consistent with the 0-10 version of the AMQP specification. All management messages begin with a message header: octet 0 1 2 3 4 5 6 7 +---------+---------+---------+---------+---------+---------+---------+---------+ | 'A' | 'M' | '1' | op-code | sequence | +---------+---------+---------+---------+---------+---------+---------+---------+ The first three octets contain the protocol magic number "AM1" which is used to identify the type and version of the message. The opcode field identifies the operation represented by the message Protocol Exchange PatternsThe following patterns are followed in the design of the protocol:
The Request-Response PatternIn the request-response pattern, a requestor sends a request message to one of its peers. The peer then does one of two things: If the request can be successfully processed, a single response message is sent back to the requestor. This response contains the requested results and serves as the positive acknowledgement that the request was successfully completed. If the request cannot be successfully completed, the peer sends a command complete message back to the requestor with an error code and error text describing what went wrong. The sequence number in the response or command complete message is the same as the sequence number in the request. Requestor Peer | | | --- Request (seq) ------------------------------------------> | | | | <----------------------------------------- Response (seq) --- | | | Requestor Peer | | | --- Request (seq) ------------------------------------------> | | | | <-------------------------- Command Complete (seq, error) --- | | | The Query-Indication PatternThe query-indication pattern is used when there may be zero or more answers to a question. In this case, the requestor sends a query message to its peer. The peer processes the query, sending as many indication messages as needed back to the requestor (zero or more). Once the last indication has been sent, the peer then sends a command complete message with a success code indicating that the query is complete. If there is an error in the query, the peer may reply with a command complete message containg an error code. In this case, no indication messages may be sent. All indication and command complete messages shall have the same sequence number that appeared in the query message. Requestor Peer | | | --- Query (seq) --------------------------------------------> | | | | <--------------------------------------- Indication (seq) --- | | <--------------------------------------- Indication (seq) --- | | <--------------------------------------- Indication (seq) --- | | <--------------------------------------- Indication (seq) --- | | <--------------------------------------- Indication (seq) --- | | | | <------------------------ Command Complete (seq, success) --- | | | Requestor Peer | | | --- Query (seq) --------------------------------------------> | | | | <-------------------------- Command Complete (seq, error) --- | | | The Unsolicited-Indication PatternThe unsolicited-indication pattern is used when one peer needs to send unsolicited information to another peer, or to broadcast information to multiple peers via a topic exchange. In this case, indication messages are sent with the sequence number field set to zero. Peer Peer | | | <----------------------------------- Indication (seq = 0) --- | | <----------------------------------- Indication (seq = 0) --- | | <----------------------------------- Indication (seq = 0) --- | | <----------------------------------- Indication (seq = 0) --- | | | Object IdentifiersManageable objects are tagged with a unique 64-bit object identifier. The object identifier space is owned and managed by the management broker. Objects managed by a single management broker shall have unique object identifiers. Objects managed by separate management brokers may have the same object identifier. If a management console is designed to manage multiple management brokers, it must use the broker identifier as well as the object identifier to ensure global uniqueness. 62 48 47 24 23 0 +-+-------------+-----------------------+-----------------------+ |0| sequence | bank | object | +-+-------------+-----------------------+-----------------------+ bit 63 - reserved, must be zero bits 63 .. 48 - broker boot sequence (32K) bits 47 .. 24 - bank (16M) bits 23 .. 0 - object (16M)
Establishing Communication Between Client and AgentCommunication is established between the management client and management agent using normal AMQP procedures. The client creates a connection to the broker and then establishes a session with its corresponding channel. Two private queues are then declared (only one if method invocation is not needed). A management queue is declared and bound to the qpid.management exchange. If the binding key is "mgmt.#", all management-related messages sent to the exchange will be received by this client. A more specific binding key will result in a more restricted set of messages being received (see the section on Routing Key Structure below). If methods are going to be invoked on managed objects, a second private queue must be declared so the client can receive method replies. This queue is bound to the amq.direct exchange using a routing key equal to the name of the queue. When a client successfully binds to the qpid.management exchange, the management agent schedules a schema broadcast to be sent to the exchange. The agent will publish, via the exchange, a description of the schema for all manageable objects in its control. Client Broker | | | --- AMQP Connection and Session Setup ----------------------> | | | | --- Queue.declare (private data queue) ---------------------> | | --- Bind queue to exchange 'qpid.management' key 'mgmt.#' --> | | | | --- Queue.declare (private method-reply queue) -------------> | | --- Bind queue to exchange 'amq.direct' --------------------> | | | | --- Broker Request -----------------------------------------> | | <---------------------------------------- Broker Response --- | | | | | | | | <------- Management schema via exchange 'qpid.management' --- | | | Broadcast of Configuration and Instrumentation UpdatesThe management agent will periodically publish updates to the configuration and instrumentation of management objects under its control. Under normal circumstances, these updates are published only if they have changed since the last time they were published. Configuration updates are only published if configuration has changed and instrumentation updates are only published if instrumentation has changed. The exception to this rule is that after a management client binds to the qpid.management exchange, all configuration and instrumentation records are published as though they had changed whether or not they actually did. Client Broker | | | <------------------ Object properties via 'mgmt.*.prop.#' --- | | | <------------------ Object statistics via 'mgmt.*.stat.#' --- | | | | | | | | Publish Interval | | | | | | | | V | <------------------ Object properties via 'mgmt.*.prop.#' --- | | <------------------ Object statistics via 'mgmt.*.stat.#' --- | | | Invoking a Method on a Managed ObjectWhen the management client wishes to invoke a method on a managed object, it sends a method request message to the qpid.management exchange. The routing key contains the object class and method name (refer to Routing Key Structure below). The method request must have a header entry (reply-to) that contains the name of the method-reply queue so that the method response can be properly routed back to the requestor. The method request contains a sequence number that is copied to the method reply. This number is opaque to the management agent and may be used by the management client to correlate the reply to the request. The asynchronous nature of requests and replies allows any number of methods to be in-flight at a time. Note that there is no guarantee that methods will be replied to in the order in which they were requested. Client Broker | | | --- Method Request (to exchange 'qpid.management') ---------> | | | | | | <--------------- Method Reply (via exchange 'amq.direct') --- | | | Messages for the Basic ScenarioThe principals in a management exchange are the management client and the management agent. The management agent is integrated into the QPID broker and the management client is a remote entity. A management agent may be managed by zero or more management clients at any given time. Additionally, a management client may manage multiple management agents at the same time. For authentication and access control, management relies on the mechanisms supplied by the AMQP protocol. Basic Opcodes
Broker Request MessageWhen a management client first establishes contact with the broker, it sends a Hello message to initiate the exchange. +-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'B' | 0 | +-----+-----+-----+-----+-----------------------+ The Broker Request message has no payload. Broker Response MessageWhen the broker receives a Broker Request message, it responds with a Broker Response message. This message contains an identifier unique to the broker. +-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'b' | 0 | +-----+-----+-----+-----+-----------------------+----------------------------+ | brokerId (uuid) | +----------------------------------------------------------------------------+ Command Completion Message+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'z' | seq | +-----+-----+-----+-----+-----------------------+ | Completion Code | +-----------------------+-----------------------------------------+ | Completion Text | +-----------------------------------------------------------------+ Class Query+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'Q' | seq | +-----+-----+-----+-----+-----------------------+----------+ | package name (str8) | +----------------------------------------------------------+ Class Indication+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'q' | seq | +-----+-----+-----+-----+-----------------------+----------+ | package name (str8) | +----------------------------------------------------------+ | class name (str8) | +----------------------------------------------------------+ | schema hash (bin128) | +----------------------------------------------------------+ Schema Request+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'S' | seq | +-----+-----+-----+-----+-----------------------+----------+ | packageName (str8) | +----------------------------------------------------------+ | className (str8) | +----------------------------------------------------------+ | schema-hash (bin128) | +----------------------------------------------------------+ Schema Response+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 's' | seq | +-----+-----+-----+-----+-----------------------+----------+ | packageName (str8) | +----------------------------------------------------------+ | className (str8) | +----------------------------------------------------------+ | schema-hash (bin128) | +-----------+-----------+-----------+-----------+----------+ | propCnt | statCnt | methodCnt | eventCnt | +-----------+-----------+-----------+-----------+----------------------------+ | propCnt property records | +----------------------------------------------------------------------------+ | statCnt statistic records | +----------------------------------------------------------------------------+ | methodCnt method records | +----------------------------------------------------------------------------+ | eventCnt event records | +----------------------------------------------------------------------------+ Each property record is an AMQP map with the following fields. Optional fields may optionally be omitted from the map.
Each statistic record is an AMQP map with the following fields:
method and event records contain a main map that describes the method or header followed by zero or more maps describing arguments. The main map contains the following fields:
Argument maps contain the following fields:
type codes are numerics with the following values:
access codes are numerics with the following values:
direction codes are numerics with the following values:
Heartbeat Indication+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'h' | 0 | +-----+-----+-----+-----+-----------------------+ | timestamp of current interval (datetime) | +-----------------------------------------------+ Configuration and Instrumentation Content MessagesContent messages are published when changes are made to the values of properties or statistics or when new management clients bind a queue to the management exchange. +-----+-----+-----+-------+-----------------------+ | 'A' | 'M' | '1' |'g/c/i'| seq | +-----+-----+-----+-------+-----------------------+--------+ | packageName (str8) | +----------------------------------------------------------+ | className (str8) | +----------------------------------------------------------+ | class hash (bin128) | +-----+-----+-----+-----+-----+-----+-----+-----+----------+ | timestamp of current sample (datetime) | +-----+-----+-----+-----+-----+-----+-----+-----+ | time object was created (datetime) | +-----+-----+-----+-----+-----+-----+-----+-----+ | time object was deleted (datetime) | +-----+-----+-----+-----+-----+-----+-----+-----+ | objectId (uint64) | +-----+-----+-----+-----+-----+-----+-----+-----+ | presence bitmasks (0 or more uint8 fields) | +-----+-----+-----+-----+-----+-----+-----+-----+------------------------+ | config/inst values (in schema order) | +------------------------------------------------------------------------+ All timestamps are uint64 values representing nanoseconds since the epoch (January 1, 1970). The objectId is a uint64 value that uniquely identifies this object instance. If any of the properties in the object are defined as optional, there will be 1 or more "presence bitmask" octets. There are as many octets as are needed to provide one bit per optional property. The bits are assigned to the optional properties in schema order (first octet first, lowest order bit first). For example: If there are two optional properties in the schema called "option1" and "option2" (defined in that order), there will be one presence bitmask octet and the bits will be assigned as bit 0 controls option1 and bit 1 controls option2. If the bit for a particular optional property is set (1), the property will be encoded normally in the "values" portion of the message. If the bit is clear (0), the property will be omitted from the list of encoded values and will be considered "NULL" or "not present". The element values are encoded by their type into the message in the order in which they appeared in the schema message. Get Query MessageA Get Request may be sent by the management console to cause a management agent to immediately send content information for objects of a class. +-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'G' | seq | +-----+-----+-----+-----+-----------------------+----------+ | Get request field table | +----------------------------------------------------------+ The content of a get request is a field table that specifies what objects are being requested. Most of the fields are optional and are available for use in more extensive deployments.
When the management agent receives a get request, it sends content messages describing the requested objects. Once the last content message is sent, it then sends a Command Completion message with the same sequence number supplied in the request to indicate to the requestor that there are no more messages coming. Method RequestMethod request messages have the following structure. The sequence number is opaque to the management agent. It is returned unchanged in the method reply so the calling client can correctly associate the reply to the request. The objectId is the unique ID of the object on which the method is to be executed. +-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'M' | seq | +-----+-----+-----+-----+-----------------------+ | objectId (uint64) | +-----------------------------------------------+ | methodName (str8) | +-----------------------------------------------+------------------------+ | input and bidirectional argument values (in schema order) | +------------------------------------------------------------------------+ Method ResponseMethod reply messages have the following structure. The sequence number is identical to that supplied in the method request. The status code (and text) indicate whether or not the method was successful and if not, what the error was. Output and bidirectional arguments are only included if the status code was 0 (STATUS_OK). +-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'm' | seq | +-----+-----+-----+-----+-----------------------+ | status code | +-----------------------+----------------------------------+ | status text (str8) | +-----------------------+----------------------------------+-------------+ | output and bidirectional argument values (in schema order) | +------------------------------------------------------------------------+ status code values are:
Messages for Extended ScenarioExtended Management ProtocolQpid supports management extensions that allow the management broker to be a central point for the management of multiple external entities with their own management schemas. Broker Remote Agent | | | <----------------------------------------- Attach Request --- | | --- Attach Response ----------------------------------------> | | | | <------------------------------------- Package Indication --- | | <------------------------------------- Package Indication --- | | | | <--------------------------------------- Class Indication --- | | <--------------------------------------- Class Indication --- | | <--------------------------------------- Class Indication --- | | <--------------------------------------- Class Indication --- | | <--------------------------------------- Class Indication --- | | | | --- Schema Request (class key) -----------------------------> | | <---------------------------------------- Schema Response --- | | | | --- Schema Request (class key) -----------------------------> | | <---------------------------------------- Schema Response --- | | | | | Extended Opcodes
Package Query+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'P' | seq | +-----+-----+-----+-----+-----------------------+ Package Indication+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'p' | seq | +-----+-----+-----+-----+-----------------------+----------+ | package name (str8) | +----------------------------------------------------------+ Attach Request+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'A' | seq | +-----+-----+-----+-----+-----------------------+----------+ | label (str8) | +-----------------------+----------------------------------+ | system-id (uuid) | +-----------------------+----------------------------------+ | requested objId bank | +-----------------------+ Attach Response (success)+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'a' | seq | +-----+-----+-----+-----+-----------------------+ | assigned broker bank | +-----------------------+ | assigned objId bank | +-----------------------+ Console Added Indication+-----+-----+-----+-----+-----------------------+ | 'A' | 'M' | '1' | 'x' | seq | +-----+-----+-----+-----+-----------------------+ |
![]() |
Document generated by Confluence on May 26, 2010 10:33 |