qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Qpid > QMFv2 API Proposal
Date Mon, 15 Feb 2010 20:10:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=qpid&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/qpid/QMFv2+API+Proposal">QMFv2 API Proposal</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~kgiusti@redhat.com">Ken Giusti</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h1><a name="QMFv2APIProposal-Proposalfor%22NextGeneration%22QMFAPI"></a>Proposal for "Next Generation" QMF API</h1>


<h2><a name="QMFv2APIProposal-Goals"></a>Goals</h2>

<ul>
	<li>Simplify QMF API</li>
</ul>


<ul>
	<li>Use new QPID Messaging API</li>
</ul>


<ul>
	<li>Implement QMF protocol via QPID Map messages</li>
</ul>


<ul>
	<li>Improve thread safety by minimizing the callback notification mechanism.</li>
</ul>


<ul>
	<li>Move to a work-queue based event model.</li>
</ul>



<h2><a name="QMFv2APIProposal-ComponentAddressing"></a>Component Addressing</h2>

<p>QMF uses AMQP messaging as the means for communications between Console and Agent components.  Thus instances of Agents and Consoles must have addresses which uniquely identify them within the AMQP messaging domain.</p>

<p>QMF uses AMQP string types to represent Agent and Console addresses.  These strings are assigned by the application, and their contents are opaque to the QMF implementation.</p>

<p>A QMF address is composed of two parts - an optional <em>domain</em> string, and a mandatory <em>name</em> string.  The domain string is used to construct the name of the AMQP exchange to which the component's name string will be bound.  If not supplied, the value of the domain defaults to "default".  Both Agents and Components must belong to the same domain in order to communicate.</p>

<p>When a Console or Agent is instantiated, it will create a receiving endpoint (source) on the AMQP message domain.  The endpoint's address will be sent as the <em>reply_to</em> field for all messages originating from that Console or Agent.   The address of the endpoint is created from the value of the domain and name strings, using the following format:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>    "qmf.&lt;domain-string&gt;.direct/&lt;name-string&gt;"
</pre>
</div></div>


<h2><a name="QMFv2APIProposal-DataModel"></a>Data Model</h2>

<h3><a name="QMFv2APIProposal-RepresentationofManagmentData"></a>Representation of Managment Data</h3>

<p>The QMF data model supports two methods for representing management data:</p>

<ol>
	<li>arbitrarily structured data</li>
	<li>data with a formally defined structure</li>
</ol>


<p>Arbitrarily structured data is the simpliest method for representing data under QMF.  It consists of a set of named data values.  Each data value is represented by a primitive AMQP data type.  The data is accessed using the data's name as a key.  QMF represents arbitrarily structured data as a map of AMQP data types indexed by a name string.</p>

<p>Data that has a formally defined structure extends the data representation by associating the data with a Schema.  The Schema describes the structure of all instances of data that are based on that Schema. This is akin to a record type in database design.</p>

<p>Both types of data representations can be managed by an agent.  Managed data includes:</p>

<ol>
	<li>an object identifier</li>
	<li>object lifecycle state</li>
</ol>


<p>An object identifier uniquely addresses a data object within the domain of its managing agent.  QMF represents the object identifier as an opaque string.  An object identifier can be assigned to the object by the agent when the object is instantiated.  Alternatively, a schema can define an object identifier by defining an ordered list of names of data items.  In this case, the object identifier string is built by concatenating the string representations of the value of each named data item.  This approach is similar to defining index fields within a database record.</p>

<p>For example, assume a managed object with the following map of data item values:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"field1" : "foo",
 "field2" : "bar",
 "field3" : 42,
 "field4" : "baz"}
</pre>
</div></div>

<p>and assume the data item list defined by the managed object's schema is:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>["field1", "field3"]
</pre>
</div></div>

<p>The identifier for this data object would be:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>"foo42"
</pre>
</div></div>



<h4><a name="QMFv2APIProposal-QmfDataClass"></a>QmfData Class</h4>

<p>QMF defines the QmfData class to represent an atomic unit of managment data.  The QmfData class defines a collection of named data values.  Optionally, a string tag, or "sub-type" may be associated with each data item.  This tag may be used by an application to annotate the data item.</p>

<p>When representing formally defined data, a QmfData instance is assigned a Schema.</p>

<p>When representing managed data, a QmfData instance is assigned an object identifier (either explicitly, or via the Schema).</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class QmfData:
      &lt;constructor&gt;( _values=map of "name"=&lt;AMQP Type&gt; pairs,
                     _subtypes=optional map of "name"=&lt;AMQP String&gt; pairs for subtype information,
                     _tag=optional, application-specific tag applied to this QmfData instance
                     _object_id=optional AMQP string that uniquely identifies this QmfData instance.
                     _schema=optional &lt;class SchemaClass&gt; reference
                     _const=False )
      &lt;constructor&gt;( _map=map representation of QmfData, as generated by mapEncode() method,
                     _schema=optional &lt;class SchemaClass&gt; reference
                     _const=False)
      .is_managed(): returns True if object identifier string assigned, else False.
      .is_described(): returns True if schema is associated with this instance
      .get_tag(): return this object's tag if present, else None
      .get_value(name): return the value of the named data item, returns None if named property is not present.
      .has_value(name): returns True if the named data item is present in the map, else False.
      .set_value(name, value, subType=None): set the value of the named data item. Creates a new item if the named data does not exist. Raises an exception if _const is True.
      .get_subtype(name): returns the sub type description string, else None if not present.
      .set_subtype(name, subType): set or modify the subtype associated with name.
      .get_object_id(): returns the object id string associated with the object instance, or None if no id assigned.
      .get_schema_class_id: returns the identifier of the Schema that describes the structure of the data, or None if no schema.
      .map_encode(): returns a map representation of the QmfData instance, suitable for use by the constructor.
</pre>
</div></div>

<p>QMF uses a map encoding to represent a QmfData class in an AMQP message. The map encoding of an instance of the QmfData Class is made up of the following elements:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_values" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> Map containing all the "name"=&lt;AMQP Type&gt; pairs for this object. </td>
</tr>
<tr>
<td class='confluenceTd'> "_subtype" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> Map containing all "name"=&lt;AMQP String&gt; subtype entries for this object. </td>
</tr>
<tr>
<td class='confluenceTd'> "_tag" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> Any AMQP-supported type </td>
<td class='confluenceTd'> Application-specific tag for this object. </td>
</tr>
<tr>
<td class='confluenceTd'> "_object_id" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Unique identifier for this data object. </td>
</tr>
<tr>
<td class='confluenceTd'> "_schema_id" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> Map containing the SchemaClassId for this object. </td>
</tr>
</tbody></table>



<h4><a name="QMFv2APIProposal-QmfEventClass"></a>QmfEvent Class</h4>

<p>QMF supports event management functionality.  An event is a notification that is sent by an Agent to alert Console(s) of a change in some aspect of the system under management.  Like QMF Data, Events may be formally defined by a Schema or not.   Unlike QMF Data, Events are not manageable entities - they have no lifecycle.  Events simply indicate a point in time where some interesting action occurred.</p>

<p>An instance of an event is represented by the QmfEvent class.</p>

<p>An AMQP timestamp value is associated with each QmfEvent instance.  It indicates the moment in time the event occurred.  This timestamp is mandatory.</p>

<p>A <em>severity level</em> may be associated with each QmfEvent instance.  The following severity levels are supported:</p>

<ul>
	<li>"emerg" - system is unusable</li>
	<li>"alert" - action must be taken immediately</li>
	<li>"crit" - the system is in a critical condition</li>
	<li>"err" - there is an error condition</li>
	<li>"warning" - there is a warning condition</li>
	<li>"notice" - a normal but significant condition</li>
	<li>"info" - a purely informational message</li>
	<li>"debug" - messages generated to debug the application</li>
</ul>


<p>The default severity is "notice".</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class QmfEvent(QmfData):
      &lt;constructor&gt;( timestamp,
                     _severity=&lt;string&gt;,
                     _values=map of "name"=&lt;AMQP Type&gt; pairs,
                     _subtypes=optional map of "name"=&lt;AMQP String&gt; pairs for subtype information,
                     _tag=optional, application-specific tag applied to this QmfEvent instance
                     _schema=optional &lt;class SchemaEventClass&gt; )
       &lt;constructor&gt;( _map= map encoding of a QmfEvent instance,
                     _schema=optional &lt;class SchemaEventClass&gt; )
      .get_timestamp(): return a timestamp indicating when the Event occurred.
      .get_severity(): return the severity associated with the Event.
      .map_encode(): return a map encoding of the Event.
</pre>
</div></div>

<p>The map encoding of an instance of the QmfEvent class extends the map of the parent class with the following class properites:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_timestamp" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> AMQP Timestamp </td>
<td class='confluenceTd'> Time the event occurred. </td>
</tr>
<tr>
<td class='confluenceTd'> "_severity" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Event severity </td>
</tr>
</tbody></table>




<h3><a name="QMFv2APIProposal-Schema"></a>Schema</h3>

<p>Schemas are used by QMF to describe the structure of management data and events.  The use of Schemas is optional.</p>

<h4><a name="QMFv2APIProposal-SchemaTypes"></a>Schema Types</h4>

<p>There are two classes (or types) of Schema - those that describe data objects, and those that describe event objects.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>SchemaTypeData:
SchemaTypeEvent:
</pre>
</div></div>

<p>These types may be represented by the strings "_data" and "_event",<br/>
respectively.</p>

<h4><a name="QMFv2APIProposal-SchemaIdentifier"></a>Schema Identifier</h4>

<p>Schema are identified by a combination of their package name and class<br/>
name.  A hash value over the body of the schema provides a revision<br/>
identifier.  The class SchemaClassId represents this Schema<br/>
identifier.</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SchemaClassId:
      &lt;constructor&gt;( package=&lt;package-name-str&gt;,
                     class=&lt;class-name-str&gt;,
                     type=&lt;SchemaTypeData|SchemaTypeEvent&gt;)
                     hash=&lt;hash-str, format="%08x-%08x-%08x-%08x"&gt;,
      .get_package_name(): returns &lt;package-name-str&gt;
      .get_class_name(): returns &lt;class-name-str&gt;
      .get_hash_string(): returns &lt;hash-str, "%08x-%08x-%08x-%08x"&gt;
      .get_type(): returns SchemaTypeObject or SchemaTypeEvent
      .map_encode(): returns a map encoding of the instance.
</pre>
</div></div>

<p>If the hash value is not supplied, then the value of the hash string will be set to None. This will be the case when a SchemaClass is being dynamically constructed, and a proper hash is not yet available.</p>

<p>The map encoding of a SchemaClassId:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_package_name" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> The name of the associated package. </td>
</tr>
<tr>
<td class='confluenceTd'> "_class_name" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> The name of the class within the package. </td>
</tr>
<tr>
<td class='confluenceTd'> "_type" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> The type of schema, either "data" or "event". </td>
</tr>
<tr>
<td class='confluenceTd'> "_hash_str" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> The MD5 hash of the schema, in the format "%08x-%08x-%08x-%08x" </td>
</tr>
</tbody></table>

<h4><a name="QMFv2APIProposal-SchemaForDescribingThePropertiesofaDataItem"></a>Schema For Describing The Properties of a Data Item</h4>

<p>The SchemaProperty class describes a single data item in a QmfData object.  A SchemaProperty is a list of named attributes and their values.  QMF defines a set of primitive attributes.  An application can extend this set of attributes with application-specific attributes.</p>

<p>QMF reserved attribute names all start with the underscore character ("_").  Do not create an application-specific attribute with a name starting with an underscore.</p>

<p>Once instantiated, the SchemaProperty is immutable.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SchemaProperty:
      &lt;constructor&gt;( name=&lt;name-value&gt;,
                     type=&lt;type-value&gt;,
                     ...)
      .get_type(): AMQP typecode for encoding/decoding the property data
      .get_access(): "RC"=read/create, "RW"=read/write, "RO"=read only (default)
      .is_optional(): True if this property is optional
      .get_unit(): string describing units (optional)
      .get_min(): minimum value (optional)
      .get_max(): maximum value (optional)
      .get_max_len(): maximum length for string values (optional)
      .get_desc(): optional string description of this Property
      .get_direction(): "I"=input, "O"=output, or "IO"=input/output (required for method arguments, otherwise optional)
      .get_subtype(): string indicating the formal application type for the data, example: "URL", "Telephone number", etc.
      .is_polled(): True if changes to the data cannot be practically monitored by an Agent.  Such a data item can only
          be queried or polled - not published on change.
      .get_reference(): if type==objId, name (str) of referenced class (optional)
      .is_parent_ref(): True if this property references an object in which this object is in a child-parent relationship.
      .get_attribute("name"): get the value of the attribute named "name". This method can be used to retrieve
          application-specific attributes.  "name" should start with the prefix "x-"
      .map_encode(): returns a map encoding of the instance.
</pre>
</div></div>

<p>The map encoding of a SchemaProperty's body:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_qmf_type" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> integer </td>
<td class='confluenceTd'> The QMF type code indicating the value's data type. </td>
</tr>
<tr>
<td class='confluenceTd'> "_access" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> The access allowed to this property, default "RO" </td>
</tr>
<tr>
<td class='confluenceTd'> "_optional" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> True if this property is optional, default False </td>
</tr>
<tr>
<td class='confluenceTd'> "_unit" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Description of the units used to express this property. </td>
</tr>
<tr>
<td class='confluenceTd'> "_min" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> integer </td>
<td class='confluenceTd'> The minimum allowed value for this property </td>
</tr>
<tr>
<td class='confluenceTd'> "_max" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> integer </td>
<td class='confluenceTd'> The maximun allowed value for this property </td>
</tr>
<tr>
<td class='confluenceTd'> "_maxlen" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> integer </td>
<td class='confluenceTd'> For string types, this is the maximum length in bytes required to represent the longest permittable instance of this string. </td>
</tr>
<tr>
<td class='confluenceTd'> "_desc" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Human-readable description of this property. </td>
</tr>
<tr>
<td class='confluenceTd'> "_dir" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Direction for an argument when passed to a Method call: "I", "O", "IO", default value: "I" </td>
</tr>
<tr>
<td class='confluenceTd'> "_subtype" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Type information for use by the application. </td>
</tr>
<tr>
<td class='confluenceTd'> "_polled" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> True if this property can only be queried/polled. Default False. </td>
</tr>
<tr>
<td class='confluenceTd'> "_reference" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> unknown? </td>
</tr>
<tr>
<td class='confluenceTd'> "_parent_ref" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> boolean </td>
<td class='confluenceTd'> True if this property references an object in which this object is in a child-parent relationship. Default False </td>
</tr>
<tr>
<td class='confluenceTd'> "x-"&lt;varies&gt; </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> Any AMQP type </td>
<td class='confluenceTd'> An application-defined attribute. </td>
</tr>
</tbody></table>



<h4><a name="QMFv2APIProposal-SchemaForDescribingMethodCalls"></a>Schema For Describing Method Calls</h4>

<p>The SchemaMethod class describes a method call's parameter list.  The parameter list is represented by an unordered map of SchemaProperty entries indexed by parameter name.</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SchemaMethod:
      &lt;constructor&gt;( [args=&lt;map of "name":&lt;SchemaProperty&gt; entries&gt;],
                     desc="description of the method")
      .get_desc(): return human-readable description of the method.
      .get_argument_count(): return the number of arguments
      .get_arguments(): returns a copy of the map of "name":&lt;SchemaProperty&gt;
      .get_argument("name"): return the SchemaProperty for the parameter "name"

      .add_argument("name", SchemaProperty): adds an additional argument to the parameter list.
      .map_encode(): returns a map encoding of the SchemaMethod instance
</pre>
</div></div>


<p>The map encoding of a SchemaMethod:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_desc" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> string </td>
<td class='confluenceTd'> Description of the method. </td>
</tr>
<tr>
<td class='confluenceTd'> "_arguments" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> Map of "name":&lt;SchemaProperty&gt; values, one for each argument to the method. </td>
</tr>
</tbody></table>


<p>Note that the "dir" SchemaProperty attribute applies to each<br/>
argument.  If "dir" is not specified, it is assumed to be "I".</p>


<h4><a name="QMFv2APIProposal-SchemaforDataObjectsandEvents"></a>Schema for Data Objects and Events</h4>

<p>The structure of QmfData objects is formally defined by the class SchemaObjectClass.</p>

<p>The structure of QmfEvent objects is formally defined by the class SchemaEventClass.</p>

<p>Both of these classes derive from the virtual base SchemaClass.</p>

<p>Agent applications may dynamically construct instances of these objects by adding properties and methods at run time. However, once the Schema is made public, it must be considered immutable, as the hash value must be constant once the Schema is in use.</p>

<p>QMF defines the following classes to represent data and event schema:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SchemaClass(QmfData):
      &lt;constructor&gt;( classId=&lt;class SchemaClassId&gt;,
                     _desc=optional AMQP string containing a human-readable description for this schema)
      .get_class_id(): return the SchemaClassId that identifies this Schema instance.
      .generate_hash(): generate a hash over the body of the schema, and return a string representation of the hash in format  "%08x-%08x-%08x-%08x"
</pre>
</div></div>


<p>The map encoding of an instance of the SchemaClass class extends the map of its parent class with elements for the following class properties.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_schema_id" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> Map containing the SchemaClassId for this object. </td>
</tr>
</tbody></table>



<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SchemaObjectClass(SchemaClass):
      &lt;constructor&gt;( classId=&lt;class SchemaClassId&gt;,
                     _desc=optional AMQP string containing a human-readable description for this schema,
                     _props=map of "name"=&lt;SchemaProperty&gt; instances,
                     _meths=map of "name"=&lt;SchemaMethod&gt; instances,
                     _id_names=(optional) ordered list of "name"s used to identify the properties whose values are used to construct the object identifier)

      .get_id_names(): return an ordered list of names of the values that are used to construct the key for identifying
          unique instances of this class.  Returns None if no list defined.
      .get_property_count(): return the count of SchemaProperty's in this instance.
      .get_properties(): return a map of "name":&lt;SchemaProperty&gt; entries for each value in the object.
      .get_property("name"): return the SchemaProperty associated with "name", else None if "name" value does not exist.

      .get_method_count(): return the count SchemaMethod's in this instance.
      .get_methods(): return a map of "name":&lt;SchemaMethod&gt; entries for each method associated with the object.
      .get_method("name"): return the SchemaMethod associated with the "name", else None if "name" does not exist or is not a method.

      .add_property("name", SchemaProperty): add a new property.
      .add_method("name", SchemaMethod): add a new method.
      .set_id_names([name-list]): set the value of the order list of names to use when constructing the object identifier.
</pre>
</div></div>

<p>The map encoding of an instance of the SchemaObjectClass class extends the map of its parent class with elements for the following class properties.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_primary_key" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> list </td>
<td class='confluenceTd'> Order list of property names used to construct the primary key for objects defined by this schema </td>
</tr>
</tbody></table>




<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SchemaEventClass(SchemaClass):
      &lt;constructor&gt;( classId=&lt;class SchemaClassId&gt;,
                     _desc=optional AMQP string containing a human-readable description for this event,
                     _props=map of "name":SchemaProperty instances)
      .get_property_count(): return the number of properties.
      .get_properties(): return a map of "name":&lt;SchemaProperty&gt; entries for each property in the event.
      .get_property("name"): return the SchemaProperty associated with "name".

      .add_property("name", SchemaProperty): add a new property.
</pre>
</div></div>


<p>The map encoding of a SchemaEventClass instance uses the same format as the map for the SchemaClass.</p>





<h3><a name="QMFv2APIProposal-DataManagement"></a>Data Management</h3>

<p>QMF allows data managment via the Query, Subscription, and Method Call actions.</p>

<h4><a name="QMFv2APIProposal-Queries"></a>Queries</h4>

<p>A Query is a mechanism for interrogating the management database.  A Query represents a selector which is sent to an Agent.  The Agent applies the Query against its management database, and returns those objects which meet the constraints described in the query.</p>

<p>A Query must specify the class of information it is selecting.  This class of information is considered the <em>target</em> of the query.  Any data objects selected by the query will be of the type indicated by the <em>target</em>.</p>

<p>A Query may also specify a <em>selector</em> which is used as a filter against the set of all <em>target</em> instances.  Only those instances accepted by the filter will be returned in response to the query.</p>

<p>Queries are expressed using the following map syntax:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what":&lt;target&gt;,
           &lt;selector_type&gt;:&lt;selector_params&gt;}
}
</pre>
</div></div>

<p>Where:</p>

<p>The value of the "what" key is a map that specifies the <em>target</em> for the Query.  The Agent will return a list of instances of <em>target</em> types that match the query.</p>

<p><em>&lt;target&gt;</em> is implemented as a map with a single element in the format:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"&lt;target name string&gt;": &lt;optional map of target qualifiers&gt;}
</pre>
</div></div>

<p>QMF defines the following values for <em>&lt;target name string&gt;</em>:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Target </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "schema_package" </td>
<td class='confluenceTd'> Query against the set of known packages.  Returns a list of package name strings. </td>
</tr>
<tr>
<td class='confluenceTd'> "schema_id" </td>
<td class='confluenceTd'> Query against the set of SchemaClass objects, return a list of SchemaClassId instances for the objects that match. </td>
</tr>
<tr>
<td class='confluenceTd'> "schema" </td>
<td class='confluenceTd'> Query against the set of SchemaClass objects, and return a list of matched SchemaClass instances. </td>
</tr>
<tr>
<td class='confluenceTd'> "object_id" </td>
<td class='confluenceTd'> Query against the set of managed QmfData objects, return a list of name strings for all matching instances. </td>
</tr>
<tr>
<td class='confluenceTd'> "object" </td>
<td class='confluenceTd'> Query against the set of managed objects, return a list of matching QmfData instances. </td>
</tr>
<tr>
<td class='confluenceTd'> "agent" </td>
<td class='confluenceTd'> Query against all agents within the current QMF domain, return a list of name strings for each matching agent.  Used only by the "agent-locate" message. </td>
</tr>
<tr>
<td class='confluenceTd'> more tbd ... </td>
<td class='confluenceTd'> ... </td>
</tr>
</tbody></table>

<p>The value of the <em>&lt;target name string&gt;</em> map entry is ignored for now, its use is TBD.</p>

<p>The <em>selector_type</em> is optional.  If it is not present, then the Query has no filter.  The Agent will return every instance of type <em>target</em> it has.  If <em>selector_type</em> is present, it may be one of the following supported values:</p>

<ul>
	<li>"id" - an exact match against the <em>target's</em> unique identifier.</li>
	<li>"where" - a logical expression to apply to the <em>target</em>.</li>
	<li>...more tbd...</li>
</ul>


<p>Only one <em>selector_type</em> is allowed in the Query at a time.</p>


<h5><a name="QMFv2APIProposal-%22id%22Selector"></a>"id" Selector</h5>

<p>A Query with an <em>id</em> selector is used to find one particular instance of a given <em>target</em> type.  The value of the "id" keyword is a type that suitably represents an exact identifier for the <em>target</em> type.  The Agent will return the first instance that matches the identifier.</p>

<p><em>id</em> selectors are only valid for the following subset of <em>targets</em>:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Target </th>
<th class='confluenceTh'> Selector Description </th>
</tr>
<tr>
<td class='confluenceTd'> "schema" </td>
<td class='confluenceTd'> A SchemaClassId </td>
</tr>
<tr>
<td class='confluenceTd'> "object" </td>
<td class='confluenceTd'> String containing the object identifier </td>
</tr>
<tr>
<td class='confluenceTd'> "agent" </td>
<td class='confluenceTd'> String containing the name of the agent </td>
</tr>
</tbody></table>

<p>The Agent will return no matches should a Query using an <em>id</em> selector specify a target name not in the above subset.</p>


<h5><a name="QMFv2APIProposal-%22Where%22Selector"></a>"Where" Selector</h5>

<p>A Query with a <em>where</em> selector describes a logical expression that is used to filter the target set.  This logical expression is built from a set of boolean operations that are applied against the target's data.  These boolean operations may be combined using logical operations.</p>

<p>The Agent will apply the logical expression against every instance of the target type, and return the set of instances for which the expression evaluates as True.</p>

<p>The value of the "where" keyword is a list representation of a predicate expression.  QMF will support the following syntax for predicate expressions:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>PREDICATE-EXP: [LOGIC-OP LOGIC-ARG]
LOGIC-ARG: PREDICATE-EXP
LOGIC-ARG: BOOL-EXP LOGIC-ARG
LOGIC-ARG: BOOL-EXP

BOOL-EXP: [BOOL-OP BOOL-ARG]
BOOL-ARG: VARIABLE BOOL-ARG
BOOL-ARG: CONST BOOL-ARG
BOOL-ARG:

CONST: [QUOTE NAME]
CONST: [QUOTE ATOMIC]
CONST: ATOMIC

VARIABLE: [UNQUOTE NAME]
VARIABLE: NAME

ATOMIC: any non-string type
NAME: string

QUOTE: "quote"
UNQUOTE: "unquote"

LOGIC-OP: string
BOOL-OP: string
</pre>
</div></div>

<p>In the above expressions, the left and right braces indicate lists.  For example, BOOL-EXP is a list containing a BOOL-OP followed by BOOL-ARG.</p>

<p>A BOOL-EXP is a boolean test that is applied against the target.  BOOL-OP defines the boolean operation that is performed on the arguments.  QMF will define a set of string literals representing the supported boolean operations.  At minimum, the following boolean operators are defined:</p>

<ul>
	<li>"eq" - equality</li>
	<li>"ne" - inequality</li>
	<li>"lt" - arithmetical/lexical less-than</li>
	<li>"le" - arithmetical/lexical less-than-or-equal</li>
	<li>"gt" - arithmetical/lexical greater-than</li>
	<li>"ge" - arithmetical/lexical greater-than-or-equal</li>
	<li>"re_match" - string regular expression match (one argument)</li>
	<li>"exists" - True if named value is present in target, else False (one argument)</li>
	<li>"true" - always true (no arguments)</li>
	<li>"false" - always false (no arguments)</li>
	<li>&lt;more tbd&gt;</li>
</ul>


<p>All operators are binary unless otherwise noted.</p>

<p>LOGIC-OP defines the logical operation that is applied to its arguments.  QMF will define a set of string literals representing supported logical operations.  At minimum, the following logical operators will be defined:</p>

<ul>
	<li>"and" - logical AND, all arguments must evaluate to True.</li>
	<li>"or" - logical OR, at least one argument must evaluate to True</li>
	<li>"not" - logical NOT, all arguments must evaluate to False</li>
	<li>&lt;more tbd&gt;</li>
</ul>


<p>Logic operations are "short-circuiting".  That is, evaluation ceases as soon as the truth value of the expression is determined.  For example, the evaluation of an "and" expression stops when the first argument that evaluates as False is found.</p>

<p>QMF considers string arguments in boolean expressions to be names of data values in the target object.   When evaluating a predicate expression, QMF will fetch the value of the named data item from each candidate target object.  The value is then used in the boolean expression.  In other words, QMF considers string arguments to be variables in the expression.  In order to indicate that a string should be treated as a literal instead, the string must be quoted using the "quote" expression.</p>

<p>For example, the following boolean expression contains the data item named "employee" against the string literal "Joey Jojo":</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>        ["eq" "employee" ["quote" "Joey Jojo"]]
</pre>
</div></div>


<p>In implementation, predicate expressions are nested lists. The first element of all lists is the operator keyword string.  The remaining list elements are arguments to the operator.</p>

<p>Examples:</p>

<p>Assume a QmfData type defines fields named "name", "address" and "town".  The following predicate expression matches any instance with a name field set to "tross", or any instance where the name field is "jross", the address field is "1313 Spudboy Lane" and the town field is "Utopia":</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre> ["or" ["eq" "name" ["quote" "tross"]]
       ["and" ["eq" "name" ["quote" "jross"]]
              ["eq" "address" ["quote" "1313 Spudboy Lane"]]
              ["eq" ["quote" "Utopia"] "town"]
       ]
]
</pre>
</div></div>

<p>Assume a QmfData type with fields "name" and "age".  A predicate to find all instances with name matching the regular expression "?ross" with an optional age field that is greater than the value 29 or less than 12 would be:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>["and" ["re_match" "name" ["quote" "?ross"]]
       ["and" ["exists" "age"]
              ["or" ["gt" "age" 27] ["lt" "age" 12]]
       ]
]
</pre>
</div></div>


<p>The valid set of <em>&lt;name&gt;</em> values in an predicate expression is determined by the <em>target</em> of the Query.  QMF reserves a set of <em>&lt;name&gt;</em> values it recognizes. The tables below list the set of name strings allowed for each type of <em>target</em>, and what these names evaluate to from the <em>target</em> instance.</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Target "schema_package" valid names </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_package_name" </td>
<td class='confluenceTd'> Evaluates to the schema's package name string. </td>
</tr>
</tbody></table>


<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Target "schema_id" and "schema" valid names </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_package_name" </td>
<td class='confluenceTd'> Evaluates to the schema's package name string. </td>
</tr>
<tr>
<td class='confluenceTd'> "_class_name" </td>
<td class='confluenceTd'> Evaluates to the schema's class name string. </td>
</tr>
<tr>
<td class='confluenceTd'> "_type" </td>
<td class='confluenceTd'> Evaluates to the schema's type string ("_data" or "_event"). </td>
</tr>
<tr>
<td class='confluenceTd'> "_hash_str" </td>
<td class='confluenceTd'> Evaluates to the schema's hash string value. </td>
</tr>
<tr>
<td class='confluenceTd'> "_schema_id" </td>
<td class='confluenceTd'> Evaluates to the schema's full identifier (SchemaClassId). </td>
</tr>
<tr>
<td class='confluenceTd'> &lt;property-name&gt; </td>
<td class='confluenceTd'> Name of a property defined by the schema. Evaluates to the name string, or None if the property is not defined. </td>
</tr>
<tr>
<td class='confluenceTd'> &lt;method-name&gt; </td>
<td class='confluenceTd'> Name of a method defined by the schema.  Evaluates to the name string, or None if the method is not defined. </td>
</tr>
</tbody></table>


<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Target "agent_info" valid names </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_name" </td>
<td class='confluenceTd'> Evaluates to the agent's name string. </td>
</tr>
</tbody></table>


<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Target "object_id" and "object" valid names </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "_package_name" </td>
<td class='confluenceTd'> If schema assigned, evaluates to the schema's package name string, else None. </td>
</tr>
<tr>
<td class='confluenceTd'> "_class_name" </td>
<td class='confluenceTd'> If schema assigned, evaluates to the schema's class name string, else None. </td>
</tr>
<tr>
<td class='confluenceTd'> "_hash_str" </td>
<td class='confluenceTd'> If schema assigned, evaluates to the schema's hash string value, else None. </td>
</tr>
<tr>
<td class='confluenceTd'> "_schema_id" </td>
<td class='confluenceTd'> If schema assigned, evaluates to the schema's full identifier (SchemaClassId), else None. </td>
</tr>
<tr>
<td class='confluenceTd'> "_object_id" </td>
<td class='confluenceTd'> Evaluates to the identifying name string. </td>
</tr>
<tr>
<td class='confluenceTd'> "_update_ts" </td>
<td class='confluenceTd'> Evaluates to the last update timestamp. </td>
</tr>
<tr>
<td class='confluenceTd'> "_create_ts" </td>
<td class='confluenceTd'> Evaluates to the creation timestamp. </td>
</tr>
<tr>
<td class='confluenceTd'> "_delete_ts" </td>
<td class='confluenceTd'> Evaluates to the deletion timestamp. </td>
</tr>
<tr>
<td class='confluenceTd'> &lt;value-name&gt; </td>
<td class='confluenceTd'> Specifies the name of a data item in the QmfData data object. Evaluates to the value of the data item. </td>
</tr>
</tbody></table>


<p>QMF reserved <em>&lt;name&gt;</em> values all start with the underscore character "_".  Do not create value or method names starting with an underscore.</p>

<p>The QmfQuery class represents a query:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class QmfQuery:
      &lt;constructor&gt;(target=&lt;target name&gt;,
                    _target_params=None,
                    _predicate=(optional)&lt;predicate map&gt;,
                    _id=(optional)&lt;target-identifier&gt;)
      &lt;constructor&gt;(map=Map representation of a QmfQuery, as generated by .map_encode())
      .get_target(): return target name
      .get_target_param(): return params.
      .get_selector(): returns QmfQuery.ID or QmfQuery.PREDICATE
      .get_id(): return identifier if selector type is QmfQuery.ID, else None
      .get_predicate(): return predicate expression if selector type is QmfQuery.PREDICATE
      .evaluate(QmfData): evaluate query against a QmfData instance.  Returns True if query matches the instance, else false.
      .map_encode(): returns a map encoding of the QmfQuery instance
</pre>
</div></div>

<p>The map encoding of a QmfQuery:</p>

<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Index </th>
<th class='confluenceTh'> Optional </th>
<th class='confluenceTh'> Type </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> "what" </td>
<td class='confluenceTd'> N </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> The target map. </td>
</tr>
<tr>
<td class='confluenceTd'> "id" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> The identifier, map format determined by target type. </td>
</tr>
<tr>
<td class='confluenceTd'> "where" </td>
<td class='confluenceTd'> Y </td>
<td class='confluenceTd'> map </td>
<td class='confluenceTd'> The predicate map. </td>
</tr>
</tbody></table>


<h5><a name="QMFv2APIProposal-ExampleQueries"></a>Example Queries</h5>

<p>With the above syntax, QMF queries can be constructed using AMQP maps and lists. For example, a query for all known schema identifiers:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"schema_id":None}}}
</pre>
</div></div>

<p>Note that the absence of a "where" clause acts as a "match all"<br/>
directive. This query will return a list of all known SchemaId's.</p>

<p>A query for all schema identifiers whose package names are equal to the string "myPackage":</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"where": ["eq" "_package_name" ["quote" "myPackage"]],
           "what": {"schema_id": None}
          }
}
</pre>
</div></div>

<p>Query for the particular QmfData data object with the identifier "Agent007":</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"object":None},
           "id": "Agent007"}
}
</pre>
</div></div>

<p>Query for the particular SchemaObjectClass instance that has the package name "MyPackage", class name "MyClass", that has a hash string of 'b49cda2d-bbe53b97-9f6ee5d1-485ea3da':</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"schema":None},
           "id": {"_package_name": "MyPackage",
                  "_class_name": "MyClass",
                  "_type": "_data",
                  "_hash_str": "b49cda2d-bbe53b97-9f6ee5d1-485ea3da"}}
}
</pre>
</div></div>

<p>Query for all SchemaClass objects that match a given package and class<br/>
name:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"schema": None}
           "where": ["and" ["eq" "_package_name" ["quote" "myPackage"]]
                           ["eq" "_class_name" ["quote" "someClass"]]]
          }
}
</pre>
</div></div>

<p>Query all managed objects belonging to the "myPackage" package, of the class "myClass", whose object_id matches a given regular expression.  Return a list of matching object identifiers:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"object_id": None},
           "where": ["and" ["eq" "_package_name" ["quote" "myPackage]]
                           ["eq" ["quote" "myClass"] "_class_name"]
                           ["re_match" "_primary_key" ["quote" "foo*"]]
                    ]
          }
}
</pre>
</div></div>

<p>Query for all QmfData objects from a particular schema, whose "temperature" property is greater or equal to 50:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"object": None},
           "where": ["and" ["eq" "_package_name" ["quote" "aPackage]]
                           ["eq" ["quote" "someClass"] "_class_name"]
                           ["ge" "temperature" 50]
                    ]
          }
}
</pre>
</div></div>

<p>In the previous example, the agent will convert the value 50 to a type compatible with the type given by the "temperature" property's schema in order to do the comparison.</p>

<p>Query for all objects that match the given schema, which have a property named "state" which does not match the regular expression "$Error*", or whose "owner" property is not set to "Cartman".</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>{"query": {"what": {"object": None},
           "where": ["and" ["eq" "_package_name" ["quote" "aPackage]]
                           ["eq" ["quote" "someClass"] "_class_name"]
                           ["or" ["not" ["re_match" "state" ["quote" "$Error"]]]
                                 ["ne" "owner" ["quote" "Cartman"]]
                           ]
                    ]
          }
}
</pre>
</div></div>



<h4><a name="QMFv2APIProposal-Subscriptions"></a>Subscriptions</h4>

<p>A subscription allows a Console application to monitor specific management data for changes in its state. A Console creates a subscription with an Agent based on a Query.  The Query specifies the set of management data that is to be monitored. When the Agent detects changes to the data within the selected set, a notification is sent to the subscribing Console(s).&nbsp; The notification contains a snapshot of the of the changed data.&nbsp;</p>

<p>A subscription remains in effect for a predetermined amount of time, as configured on the Agent.&nbsp; Once the subscription expires, no further notifications are generated should the data change.&nbsp; A console may elect to refresh a subscription prior to its expiration.&nbsp;&nbsp; Alternatively, a Console may explicitly cancel the subscription when the data no longer needs to be monitored.</p>



<h4><a name="QMFv2APIProposal-InvokingMethods"></a>Invoking Methods</h4>

<p>QMF allows a Console application to perform a "remote procedure call" on the Agent.  The procedure - or <em>method</em> &#45; call executes on the Agent. On completion a result is passed back to the Console.  Method calls can be associated with an instance of a data object, or applied to the Agent as a whole.</p>

<p>The structure of a method call may be described by the schema associated with the object.  The schema can define a name for the method and a description of its input and output parameters. The SchemaMethod class is used for this purpose.</p>

<p>The value(s) returned to the Console when the method call completes are represented by the MethodResult class.  The MethodResult class indicates whether the method call succeeded or not, and, on success, provides access to all data returned by the method call.  Returned data is provided in a map indexed by the name of the parameter. The map contains only those parameters that are classified as "output" by the SchemaMethod.</p>

<p>Should a method call result in a failure, this failure is indicated by the presence of an error object in the MethodResult.  This object is represented by a QmfData object.  The structure of this QmfData object is application-defined, but should contain a description of the reason for the failure. There are no returned parameters when a method call fails.</p>

<p>A successful method invokation is indicated by the absence of the QmfData error object in the MethodResult.</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class MethodResult:
      &lt;constructor&gt;( QmfData &lt;exception&gt; | &lt;map of properties&gt; )
      .succeeded(): returns True if the method call executed without error.
      .get_exception(): returns the QmfData error object if method fails, else None
      .get_arguments(): returns a map of "name"=&lt;value&gt; pairs of all returned arguments.
      .get_argument(&lt;name&gt;): returns value of argument named "name".
</pre>
</div></div>



<h4><a name="QMFv2APIProposal-ManagementEvents"></a>Management Events</h4>

<p>An event is a notification that is sent by an Agent to alert Console(s) of a change in some aspect of the system under management.  Agents publish events asynchronously.  Consoles have the option of receiving events from a given Agent.</p>

<p>To publish an event, the Agent application must call the <em>raise_event()</em> method, passing an instance of a QmfEvent object.  The Agent publishes the QmfEvent instance.</p>

<p>To receive events, the Console application must enable event reception on a per-agent basis.  The Console application does this by calling the <em>enable_events()</em> method on the desired Agent instance.  Published events from the Agent will then appear on the Console's work-queue.  The Console application may disable events by invoking the Agent's <em>disable_events()</em> method.</p>


<h4><a name="QMFv2APIProposal-WorkQueueEventModel."></a>Work-Queue Event Model.</h4>

<p>The original QMF API defined a set of callback methods that a Console or Agent application needed to provide in order to process asynchronous QMF events.  Each asynchonous event defined its own callback method.</p>

<p>The new API replaces this callback model with a work-queue approach. All asynchronous events are represented by a WorkItem object.  When a QMF event occurs it is translated into a WorkItem object and placed in a FIFO queue.  It is left to the application to drain this queue as needed.</p>

<p>This new API does require the application to provide a single callback.  The callback is used to notify the application that WorkItem object(s) are pending on the work queue.  This callback is invoked by QMF when one or more new WorkItem objects are added to the queue.  To avoid any potential threading issues, the application is <em>not</em> allowed to call any QMF API from within the context of the callback.  The purpose of the callback is to notify the application to schedule itself to drain the work queue at the next available opportunity.</p>

<p>For example, a console application may be designed using a <tt>select()</tt> loop.  The application waits in the <tt>select()</tt> for any of a number of different descriptors to become ready.  In this case, the callback could be written to simply make one of the descriptors ready, and then return.  This would cause the application to exit the wait state, and start processing pending events.</p>

<p>The callback is represented by the Notifier virtual base class.  This base class contains a single method.  An application derives a custom notification handler from this class, and makes it available to the Console or Agent object.</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class Notifier:
    .indication():  Called when the internal work queue becomes non-empty due to the arrival of one or more WorkItems.
        This method will be called by the internal QMF management thread - it is illegal to invoke any QMF APIs from
        within this callback.  The purpose of this callback is to indicate that the application should schedule itself
        to process the work items.
</pre>
</div></div>


<p>The WorkItem class represents a single notification event that is read from the work queue:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class WorkItem:
    .get_type(): Identifies the type of work item.
    .get_handle(): returns the reply handle for an asynchronous operation, if present.
    .get_params(): Returns the payload of the work item.  The type of this object is determined by the type of the workitem.
</pre>
</div></div>

<p>Console and Agent-specific WorkItem types are defined.</p>



<h2><a name="QMFv2APIProposal-ConsoleApplicationModel"></a>Console Application Model</h2>

<p>This section describes the API that is specific to Console components.</p>

<p>A QMF console component is represented by a Console class.  This class is the topmost object of the console application's object model.</p>

<p>A Console is composed of the following objects:</p>

<ul>
	<li>a connection to the AMQP bus</li>
	<li>a queue of inbound work items</li>
	<li>a collection of all known schemas</li>
	<li>a list of all known remote Agents</li>
	<li>a cache of known data object proxies</li>
</ul>


<p>The connection to the AMQP bus is used to communicate with remote Agents.  The queue is used as a source for notifications coming from remote Agents.</p>


<h3><a name="QMFv2APIProposal-QmfConsoleDataClass"></a>QmfConsoleData Class</h3>

<p>The QmfData class is subclassed to provide a Console specific representation of management data.</p>

<p>The Console application represents a managed data object by the QmfConsoleData class.  The Console has "read only" access to the data values in the data object via this class.  The Console can also invoke the methods defined by the object via this class.  The actual data stored in this object is cached from the Agent.  In order to update the cached values, the Console invokes the instance's refresh() method.</p>

<p>Note that the refresh() and invoke_method() methods require communication with the remote Agent.  As such, they may block.  For these two methods, the Console has the option of blocking in the call until the call completes.  Optionally, the Console can receive a notification asynchronously when the operation is complete.  See below for more detail regarding synchronous and asynchronous API calls.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class QmfConsoleData(QmfData):
      .get_timestamps(): returns a list of timestamps describing the
                        lifecycle of the object.  All timestamps are
                        represented by the AMQP timestamp type.
                        [0] = time of last update from Agent,
                        [1] = creation timestamp
                        [2] = deletion timestamp, or zero if not deleted.
      .get_create_time(): returns the creation timestamp
      .get_update_time(): returns the update timestamp
      .get_delete_time(): returns the deletion timestamp, or zero if not yet deleted.
      .is_deleted(): True if deletion timestamp not zero.

      .refresh([reply-handle | timeout]): request that the Agent update the value of this object's contents.
      .invoke_method(name, inArgs{}, [[reply-handle] | [timeout]]): invoke the named method on this instance.
</pre>
</div></div>



<h3><a name="QMFv2APIProposal-AsychronousEventModel."></a>Asychronous Event Model.</h3>

<p>The Console application must support the following WorkItem types:</p>

<ul>
	<li>AGENT_ADDED</li>
	<li>AGENT_DELETED</li>
	<li>NEW_PACKAGE</li>
	<li>NEW_CLASS</li>
	<li>OBJECT_UPDATE</li>
	<li>EVENT_RECEIVED</li>
	<li>AGENT_HEARTBEAT</li>
	<li>SUBSCRIPTION_RESPONSE</li>
	<li>SUBSCRIPTION_INDICATION</li>
</ul>


<p>These WorkItem types are described in detail below:</p>

<h4><a name="QMFv2APIProposal-AGENTADDED"></a>AGENT_ADDED</h4>

<p>When the QMF Console receives the first heartbeat from an Agent, an AGENT_ADDED WorkItem is pushed onto the work-queue.  The WorkItem's get_param() call returns a map which contains a reference to the new Console Agent instance.   The reference is indexed from the map using the key string "agent".  There is no handle associated with this WorkItem.</p>

<p><em>Note:</em> If a new Agent is discovered as a result of the Console <em>find_agent()</em> method, then no AGENT_ADDED WorkItem is generated for that Agent.</p>

<h4><a name="QMFv2APIProposal-AGENTDELETED"></a>AGENT_DELETED</h4>

<p>When a known Agent stops sending heartbeat messages, the Console will time out that Agent.  On Agent timeout, an AGENT_DELETED WorkItem is pushed onto the work-queue.  The WorkItem's get_param() call returns a map which contains a reference to the Agent instance that has been deleted.  The reference is indexed from the map using the key string "agent".  There is no handle associated with this WorkItem.</p>

<p>The Console application must release all saved references to the Agent before returning the WorkItem.</p>

<h4><a name="QMFv2APIProposal-NEWPACKAGE"></a>NEW_PACKAGE</h4>

<p>TBD.</p>

<h4><a name="QMFv2APIProposal-NEWCLASS"></a>NEW_CLASS</h4>

<p>TBD.</p>

<h4><a name="QMFv2APIProposal-OBJECTUPDATE"></a>OBJECT_UPDATE</h4>

<p>TBD.</p>

<h4><a name="QMFv2APIProposal-EVENTRECEIVED"></a>EVENT_RECEIVED</h4>

<p><em>TBD</em></p>

<h4><a name="QMFv2APIProposal-SUBSCRIPTIONRESPONSE"></a>SUBSCRIPTION_RESPONSE</h4>

<p>The <em>SUBSCRIPTION_RESPONSE</em> WorkItem returns the result of a subscription request made by this Console.&nbsp; This WorkItem is generated when the Console's create_subscription() is called in an asychronous manner, rather than pending for the result.&nbsp;&nbsp;</p>


<p>The get_params() method of a <em>SUBSCRIPTION_RESPONSE&nbsp;</em> WorkItem will return an instance of the following object:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class SubscriptionParams:
      .get_subscription(): If the subscription is successful, this method returns a SubscriptionId object.
          Should the subscription fail, this method returns None, and get_error() can be used to obtain an
          application-specific QmfData error object.
      .get_expiration_date(): returns a datetime object containing the timestamp (utc) when the subscription
          will automatically expire if not renewed by the console.
      .get_error(): (optional) returns an application-specific QmfData object indicating why the subscription
          request failed.  Returns None if not supported.
</pre>
</div></div>

<p>The SubscriptionId object must be used when the subscription is refreshed or cancelled.&nbsp; The SubscriptionId must be passed to the Console's refresh_subscription() and cancel_subscription() methods.</p>

<p>The get_handle() method returns the application handle provided to the create_subscription() method call.</p>

<p>Once a subscription is created, the Agent that maintains the subscription will issue an initial update for the subscribed data.&nbsp; This update will contain the current values of the subscribed data, and will appear as the first <em>SUBSCRIPTION_INDICATION</em> WorkItem for this subscription.</p>


<h4><a name="QMFv2APIProposal-SUBSCRIPTIONINDICATION"></a>SUBSCRIPTION_INDICATION</h4>

<p>The <em>SUBSCRIPTION_INDICATION</em> WorkItem signals the arrival of an update to subscribed data from the Console.</p>

<p>The get_params() method will return a list of updated data objects.</p>

<p>The get_handle() method will return the application's subscription context handle originally supplied to the Console's create_subscription() method call for this subscription.</p>


<h4><a name="QMFv2APIProposal-"></a></h4>


<h4><a name="QMFv2APIProposal-"></a></h4>



<h3><a name="QMFv2APIProposal-LocalrepresentationofaremoteAgent."></a>Local representation of a remote Agent.</h3>

<p>The console application maintains a list of all known remote Agents. Each Agent is represented by the Agent class:</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class Agent:
      .get_name(): returns the identifying name string of the agent.  This name is used to send AMQP messages directly to this agent.
      .is_active(): returns True if the agent is alive (heartbeats have not timed out)
      .invoke_method(name, inArgs{}, [[reply-handle] | [timeout]]): invoke the named method against the agent.
      .enable_events(): allows reception of events from this agent.
      .disable_events(): prevents reception of events from this agent.
      .destroy(): releases this Agent instance.  Once called, the console application should not reference this instance again.
      ?tbd?
</pre>
</div></div>


<h3><a name="QMFv2APIProposal-TheConsoleObject."></a>The Console Object.</h3>

<p>The Console class is the top-level object used by a console application.  All QMF console functionality is made available by this object.  A console application must instatiate one of these objects.</p>

<p>As noted below, some Console methods require contacting a remote Agent.  For these methods, the caller has the option to either block for a (non-infinite) timeout waiting for a reply, or to allow the method to complete asynchonously.  When the asynchronous approach is used, the caller must provide a unique handle that identifies the request.  When the method eventually completes, a WorkItem will be placed on the work queue.  The WorkItem will contain the handle that was provided to the corresponding method call.</p>

<p>All blocking calls are considered thread safe - it is possible to have a multi-threaded implementation have multiple blocking calls in flight simultaineously.</p>

<p>If a name is supplied, it must be unique across all Consoles attached to the AMQP bus under the given domain.  If no name is supplied, a unique name will be synthesized in the format: "qmfc-&lt;hostname&gt;.&lt;pid&gt;"</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class Console:
      &lt;constructor&gt;(name=&lt;name-str&gt;,
                    domain=(optional) domain string for console's AMQP address,
                    notifier=&lt;class Notifier&gt;,
                    reply_timeout=&lt;default for all blocking calls&gt;,
                    agent_timeout=&lt;default timeout for agent heartbeat&gt;,
                    subscription_duration=&lt;default lifetime of a subscription&gt;)

      .destroy(timeout=None): Must be called to release Console's resources.

      .add_connection(QPID Connection): Connect the console to the AMQP cloud.

      .remove_connection(conn): Remove the AMQP connection from the console.  Un-does the add_connection() operation, and
          releases any agents associated with the connection.  All blocking methods are unblocked and given a failure status.
          All outstanding asynchronous operations are cancelled without producing WorkItems.

      .get_address():
          Get the AMQP address this Console is listening to (type str).

      .find_agent( name string, [timeout] ): Query for the presence of a specific agent in the QMF domain. Returns a
          class Agent if the agent is present.  If the agent is not already known to the console, this call will send
          a query for the agent and block (with default timeout override) waiting for a response.

      .enable_agent_discovery( [Query] ): Called to enable the asynchronous Agent Discovery process. Once enabled, AGENT_ADDED
          and AGENT_DELETED work items can arrive on the WorkQueue.  If a query is supplied, it will be used to filter agent
          notifications.

      .disable_agent_discovery(): Called to disable the async Agent Discovery process enabled by calling enable_agent_discovery().

      .get_workitem_count(): Returns the count of pending WorkItems that can be retrieved.

      .get_next_workitem([timeout=0]): Obtains the next pending work item, or None if none available.

      .release_workitem(wi): Releases a WorkItem instance obtained by getNextWorkItem(). Called when the application has finished
          processing the WorkItem.

      .get_agents(): Returns a list of available agents (class Agent)

      .get_agent( name string ): Return the class Agent for the named agent, if known.

      .get_packages( [class Agent] ): Returns a list of the names of all known packages.  If an optional Agent is provided, then
          only those packages available from that Agent are returned.

      .get_classes( [class Agent] ):  Returns a list of SchemaClassIds for all available Schema.  If an optional Agent is provided,
          then the returned SchemaClassIds are limited to those Schema known to the given Agent.

      .get_schema( class SchemaClassId [, class Agent]): Return a list of all available class SchemaClass across all known agents.
          If an optional Agent is provided, restrict the returned schema to those supported by that Agent.

      .get_objects( _SchemaClassId= | _package=, _class= |
                    _object_identifier=,
                   [timeout=],
                   [list-of-class-Agent] ): perform a blocking query for QmfConsoleObjects.  Returns a list (possibly empty) of matching
           objects. The selector for the query may be either:
           * class SchemaClassId - all objects whose schema match the schema identified by _SchemaClassId parameter.
           * package/class name - all objects whose schema are contained by the named package and class.
           * the object identified by _object_identifier
           This method will block until all known agents reply, or the timeout expires. Once the timeout expires, all
           data retrieved to date is returned. If a list of agents is supplied, then the query is sent to only those agents.

      .create_subscription( agent, class Query, app_context [, reply_handle] [, timeout] ): creates a subscription to the agent
          using the given Query.  The app_context is an application-provided handle that will accompany each subscription update
          send from the agent.  Subscription updates will appear as SUBSCRIPTION_INDICATION WorkItems on the Console's work queue.
          This method may be called asynchronously by providing a reply_handle argument.  When called asynchronously, the result
          of this method call is returned in a SUBSCRIPTION_RESPONSE WorkItem.  Timeout can be used to override the console's
          default reply timeout.  When called synchronously, this method returns a class SubscriptionParams object containing
          the result of the subscription request.

      .refresh_subscription( SubscriptionId [, duration=&lt;secs&gt;] ): (re)activates a subscription.  Uses the console default duration
          unless the duration is explicitly specified.

      .cancel_subscription( SubscriptionId ): terminates the given subscription.
</pre>
</div></div>


<h3><a name="QMFv2APIProposal-ExampleConsoleApplication"></a>Example Console Application</h3>

<p>The following pseudo-code performs a blocking query for a particular agent.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>logging.info( "Starting Connection" )
conn = Connection("localhost")
conn.connect()

logging.info( "Starting Console" )
myConsole = Console()
myConsole.add_connection( conn )

logging.info( "Finding Agent" )
myAgent = myConsole.find_agent( "com.aCompany.Examples.anAgent", _timeout=5 )

if myAgent:
   logging.info( "Agent Found: %s" % myAgent )
else:
   logging.info( "No Agent Found!")

logging.info( "Removing connection" )
myConsole.remove_connection( conn )

logging.info( "Destroying console:" )
myConsole.destroy( _timeout=10 )
</pre>
</div></div>


<p>The following pseudo-code performs a non-blocking query for all<br/>
agents.  It completes when at least one agent is found.</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class MyNotifier(Notifier):
    def __init__(self, context):
        self._myContext = context
        self.WorkAvailable = False

    def indication(self):
        print("Indication received! context=%d" % self._myContext)
        self.WorkAvailable = True

noteMe = MyNotifier( 668 )

logging.info( "Starting Connection" )
conn = Connection("localhost")
conn.connect()

myConsole = Console(notifier=noteMe)
myConsole.add_connection( conn )

myConsole.enable_agent_discovery()
logging.info("Waiting...")


while not noteMe.WorkAvailable:
    print("No work yet...sleeping!")
    time.sleep(1)


print("Work available = %d items!" % myConsole.getWorkItemCount())
wi = myConsole.get_next_workitem(timeout=0)
while wi:
    print("work item %d:%s" % (wi.getType(), str(wi.getParams())))
    wi = myConsole.get_next_workitem(timeout=0)


logging.info( "Removing connection" )
myConsole.remove_connection( conn )

logging.info( "Destroying console:" )
myConsole.destroy( 10 )
</pre>
</div></div>


<h2><a name="QMFv2APIProposal-AgentApplicationModel"></a>Agent Application Model</h2>

<p>This section describes the API that is specific to Agent components.</p>

<p>A QMF agent component is represented by a instance of the Agent class.  This class is the topmost object of the agent application's object model.  Associated with a particular agent are:</p>

<ul>
	<li>the set of objects managed by that agent</li>
	<li>the set of schema that describes the structured objects owned by the agent</li>
	<li>a collection of consoles that are interfacing with the agent</li>
</ul>


<p>The Agent class communicates with the application using the same work-queue model as the console.  The agent maintains a work-queue of pending requests.  Each pending request is associated with a handle.  When the application is done servicing the work request, it passes the response to the agent along with the handle associated with the originating request.</p>


<h3><a name="QMFv2APIProposal-QmfAgentDataClass"></a>QmfAgentData Class</h3>

<p>The Agent manages the data it represents by the QmfAgentData class - a derivative of the QmfData class.  The Agent is responsible for managing the values of the properties within the object, as well as servicing the object's method calls.  Unlike the Console, the Agent has full control of the state of the object.</p>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class QmfAgentData(QmfData):
      .destroy(): mark the object as deleted by setting the deletion timestamp to the current time.
      .set_value(name, value): update the value of the property.
      .inc_value(name, delta): add the delta to the property
      .dec_value(name, delta): subtract the delta from the property
      ?tbd?
</pre>
</div></div>


<p>An agent can support one of two different models for managing its database of QmfAgentData objects: internal or external store.</p>

<h3><a name="QMFv2APIProposal-InternalObjectStore"></a>Internal Object Store</h3>

<p>An agent that implements internal object store gives full responsibility for managing its data objects to the QMF infrastructure.  In this model, the application passes a reference for each managed object to the QMF agent.  The agent manages the set of objects internally, directly accessing the contents of the object in order to service console requests.</p>

<p>With this model, the application's complexity is reduced.  The application needs to instantiate the object and register it with the agent.  The application also maintains a reference to the object, as the application is responsible for updating the object's properties as necessary.</p>

<p>However, the application must still service method calls.  The agent notifies the application when a method call has been requested by a console.  The application services the method call, passing the result of the method back to the agent. The agent then relays the response to the originating console.</p>

<p>The application may decide to delete an object instance.  The application does this by invoking the destroy() method on the object. This notifies the agent, which will mark the object as deleted in its database. Once the application invokes the destroy() method on an object, it must no longer access the object.  The agent will clean up the object at a later point in time.</p>

<p>Internal object store is the default model for agent object managment.</p>

<h4><a name="QMFv2APIProposal-DataConsistency"></a>Data Consistency</h4>

<p>The internal object store requires sharing of the managed data between the agent and the application.  The application is responsible for keeping the data up to date, while the agent is responsible for providing the data to client consoles.  It is likely that these components may be implemented in separate execution contexts. This raises the possibility that a data item could be in the process of being written to by the application at the same moment the agent attempts to read it.  This could result in invalid data being read.</p>

<p>To prevent this from occuring, the QmfAgentObject class provides accessors for all data in the object. These accessors provide atomic access to the underlying data.  Therefore, both the agent and the application code <b>must</b> use these accessors to manipulate a shared object's data.</p>


<h3><a name="QMFv2APIProposal-ExternalObjectStore"></a>External Object Store</h3>

<p>An alternate agent implementation allows the application to take full responsibility for managing the objects.  With this model, all instances of managed objects exist external to the agent. When a console requests an action against an object, that action is transferred from the agent to the application.  The application then must process the request, and send the result to the agent.  The agent then sends a reply to the requesting console.</p>

<p>The model gives full control of the managed objects to the application, but usually requires more application development work.</p>


<h3><a name="QMFv2APIProposal-AgentClass"></a>Agent Class</h3>

<p>The base class for the agent object is the Agent class.  This base<br/>
class represents a single agent implementing internal store.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class Agent:
      &lt;constructor&gt;( name=&lt;name-string&gt;,
                     domain=(optional) domain string for agent's AMQP address,
                     notifier=class Notifier,
                     heartbeat_interval=30,
                     max_msg_size=0)
      .get_name(): return the name string of the agent.
      .set_connection( QPID Connection ): connect the agent to the AMQP cloud.
      .register_object_class( class SchemaObjectClass ): Register a schema for an object class with the agent.  The agent must
            have a registered schema for an object class before it can handle objects of that class.
      .register_event_class( class SchemaEventClass ) : Register a schema for an event class with the agent.  The agent must
            have a registered schema for an event class before it can handle events of that class.
      .raise_event( class QmfEvent ): Cause the agent to raise the given event.
      .add_object( class QmfAgentData ): passes a reference to an instance of a managed QMF object to the agent. The object's
          name must uniquely identify this object among all objects known to this agent.
      .get_workitem_count(): Returns the count of pending WorkItems that can be retrieved.
      .get_next_workitem([timeout=0]): Obtains the next pending work item, or None if none available.
      .release_workitem(wi): Releases a WorkItem instance obtained by get_next_workitem(). Called when the application has finished
          processing the WorkItem.
      .method_response(name="method name",
                       handle=&lt;handle from WorkItem&gt;,
                       out_args={output argument map}
                       error=&lt;QmfData&gt; ): Indicate to the agent that the application has completed processing a method
                       request. See the description of the METHOD_CALL WorkItem.
</pre>
</div></div>


<h3><a name="QMFv2APIProposal-AgentExternalClass"></a>AgentExternal Class</h3>


<p>The AgentExternal class must be used by those applications that implement the external store model. The AgentExternal class extends the Agent class by adding interfaces that notify the application when it needs to service a request for management operations from the agent.</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class AgentExternal(Agent):
      &lt;constructor&gt;(name=&lt;name-string&gt;,
                    domain=(optional) domain string for agent's AMQP address,
                    notifier= class Notifier,
                    heartbeat_interval=30,
                    max_msg_size=65535)
      .alloc_object_id( name="object name"): indicate to QMF that the named object is available to be managed.  Once this method returns,
          the agent will service requests from consoles referencing this data.
      .free_object_id( name="object name" ): indicate to QMF that the named object is no longer available to be managed.
      .query_response( handle=&lt;handle from WorkItem&gt;,
                      class QmfAgentObject): send a managed object in reply to a received query. Note that ownership of the object
          instance is returned to the caller on return from this call.
      .query_complete( handle=&lt;handle from WorkItem&gt;,
                      result=&lt;status code&gt; ):  Indicate to the agent that the application has completed processing a query request.
          Zero or more calls to the queryResponse() method should be invoked before calling query_complete().  If the query should
          fail - for example, due to authentication error - the result should be set to a non-zero error code ?TBD?.
      .subscription_response( handle=&lt;handle from WorkItem&gt;,
                             result=&lt;status code&gt;,
                             subscription_handle=&lt;application context&gt;): Indicate the status of a subscription request.  If result
          is zero, the subscription is accepted by the application, and an subscription handle is provided.  This handle must
          be passed to the application when the agent unsubscribes.
</pre>
</div></div>


<h3><a name="QMFv2APIProposal-AsychronousEventModel."></a>Asychronous Event Model.</h3>

<p>The Agent uses the same notification driven work-queue model as the Console.  In the Agent case, the following set of WorkItem types are supported:</p>

<ul>
	<li>METHOD_CALL</li>
	<li>QUERY</li>
	<li>SUBSCRIBE</li>
	<li>UNSUBSCRIBE</li>
</ul>


<p><em>Note Well</em>: In the case of an internal store agent implementation, only the METHOD_CALL work item is generated.  An external store agent must support all work item types.</p>

<h4><a name="QMFv2APIProposal-METHODCALL"></a>METHOD_CALL</h4>

<p>The <em>METHOD_CALL</em> WorkItem describes a method call that must be serviced by the application on behalf of this agent.</p>

<p>The get_params() method of a <em>METHOD_CALL</em> WorkItem will return an instance of the following object:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>class MethodCallParams:
      .get_name(): returns a string containing the name of the method call.
      .get_object_id(): returns the identifier for the object on which this
          method needs to be invoked.  Returns None iff there is no associated
          object (a method call against the agent itself).
      .get_args(): returns a map of input arguments for the method. Arguments
          are in "name"=&lt;value&gt; pairs.  Returns None if no arguments are supplied.
      .get_user_id(): returns authenticated user id of caller if present, else None.
</pre>
</div></div>

<p>On completion of the method call, the application must provide the result of the call to the Agent.  This is done by invoking the Agent's method_response() method.  The method_response() method must be passed the handle from the <em>METHOD_CALL</em> WorkItem.</p>

<p>On successful completion of a method call, any output arguments from the method call must be passed in the out_args map parameter, in name=&lt;value&gt; pairs.  The error parameter must be set to None.</p>

<p>If the method call fails the application must indicate the failure by passing a QmfData instance via the error parameter. The structure of this QmfData is application-specific, and meant to provide a description of the failure to the console.</p>


<h4><a name="QMFv2APIProposal-QUERY"></a>QUERY</h4>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>  QUERY parameters: ( class Query,
                      user_id=&lt;authenticated id of the user&gt; )

</pre>
</div></div>

<p>The QUERY WorkItem describes a query that the application must service. The application should call the query_response() method for each object that satisfies the query.  When complete, the application must call the query_complete() method.  If a failure occurs, the application should indicate the error to the agent by calling the query_complete() method with a description of the error.</p>

<h4><a name="QMFv2APIProposal-SUBSCRIBE"></a>SUBSCRIBE</h4>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>  SUBSCRIBE parameters: ( class Query,
                          user_id=&lt;authenticated id of the user&gt; )
</pre>
</div></div>

<p><b>TBD</b><br/>
The SUBSCRIBE WorkItem provides a query that the application should<br/>
monitor until the subscription is cancelled.  On receipt of this<br/>
WorkItem, the application should call the subscriptionResponse() agent<br/>
method to acknowledge the response.  Whenever the matching objects are<br/>
updated, the application should call queryResponse() for each updated<br/>
object, followed by a call to queryComplete() when done.  The<br/>
subscription remains in effect until an UNSUBSCRIBE WorkItem for the<br/>
subscription is received.</p>

<h4><a name="QMFv2APIProposal-UNSUBSCRIBE"></a>UNSUBSCRIBE</h4>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>  UNSUBSCRIBE parameters: ( &lt;handle associated with subscription&gt; )
</pre>
</div></div>

<p><b>TBD</b><br/>
Alerts the application that the corresponding subscription has been<br/>
cancelled.  The application should no longer supply query updates<br/>
against the subscribed query.</p>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/qpid/QMFv2+API+Proposal">View Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=5965629&revisedVersion=15&originalVersion=14">View Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/qpid/QMFv2+API+Proposal?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message