Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "COSMOS Design 204959"

(New page: == '''Adding support for the CMDBf query service on top of the SML repository''' == === '''Change History''' === {|{{BMTableStyle}} !align="left"|Name: !align="left"|Date: !align="left"|...)
 
m ('''Change History''')
 
(70 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== '''Adding support for the CMDBf query service on top of the SML repository''' ==
+
== '''Provide reusable CMDBf APIs for adopters that intend to provide a CMDBf query/registration service''' ==
  
 
=== '''Change History''' ===
 
=== '''Change History''' ===
Line 7: Line 7:
 
!align="left"|Revised Sections:
 
!align="left"|Revised Sections:
 
|-
 
|-
|David Whiteman
+
|Ali Mehregani
|8/21/2007
+
|10/04/2007
 
|<ul><li>Initial version</li></ul>
 
|<ul><li>Initial version</li></ul>
 
|-
 
|-
|David Whiteman
+
|David Whiteman
|8/27/2007
+
|10/05/2007
|<ul><li>Added use cases</li></ul>
+
|<ul><li>Added details regarding service transformations</li></ul>
|-
+
|Ali Mehregani
+
|8/28/2007
+
|<ul>
+
  <li> Modified purpose & requirements </li>
+
  <li> Added implementation details & task breakdown </li>
+
</ul>
+
 
|-
 
|-
|David Whiteman
+
|Valentina Popescu
|8/28/2007
+
|10/23/2007
|<ul>
+
|<ul><li>Updated SML Repository definition.</li></ul>
<li>Expanded use cases</li>
+
<li>Added test coverage</li>
+
</ul>
+
 
|}
 
|}
  
Line 67: Line 57:
 
|
 
|
 
|}
 
|}
 
* -  includes other committer work (e.g. check-in, contribution tracking)
 
  
 
== ''' Terminologies/Acronyms''' ==
 
== ''' Terminologies/Acronyms''' ==
Line 92: Line 80:
 
|-
 
|-
 
|SML Repository
 
|SML Repository
|repository of SML documents hosted in COSMOS with an established API (see [https://bugs.eclipse.org/bugs/show_bug.cgi?id=179828 bugzilla 179828])
+
|The SML Repository describes any SML model ( an SML model is a set of SML compliant resources ) together with a set of COSMOS API used to add new SML resources to the SML model and to query the SML model.
 
|-
 
|-
 
|Query service
 
|Query service
 
|MDRs make data available to Clients via a Query service. Queries may select and return items, relationships, and/or graphs containing items and relationships.
 
|MDRs make data available to Clients via a Query service. Queries may select and return items, relationships, and/or graphs containing items and relationships.
 +
|-
 +
|Registration service
 +
|This service is used to register a set of supported items and relationships with a federating CMDB.
 
|}
 
|}
  
 
== ''' Purpose ''' ==
 
== ''' Purpose ''' ==
 
+
This enhancement is associated with [https://bugs.eclipse.org/bugs/show_bug.cgi?id=204959 bugzilla 204959].
According to the CMDBf specification, an MDR requires the implementation of the following services to be fully integrated with a federating CMDB:
+
<p>
<ol>
+
The purpose of this enhancement is to refactor the CMDBf query code to make it more reusable.  The SML repository already defines a set of APIs related to the CMDBf query.  This set needs to be migrated to org.eclipse.cosmos.dc.cmdbf.query so that it can be reused by contributors who intend to provide a query service for a data provider.
<li> Registration </li>
+
</p>
<li> Query </li>
+
</ol>
+
  
 
<p>
 
<p>
During the [[Cosmos Release Plan#Release Milestones|i6 time-frame]] a query service will be implemented for the SML repository.  The service will allow clients to query the available data with the XML query language described in the CMDBf specification.  The output of the query will also be in XML format, which the client is expected to understand.
+
Another purpose of this enhancement is to implement the registration transformation code, and provide reusable APIs for the CMDBf registration service.
 
</p>
 
</p>
  
 
<p>
 
<p>
Currently clients are expected to interact with the SML repository via a set of convenience APIsThis enhancement does not imply the removal of such APIs.  They may need to slightly be modified to accompany the new changes but they can still be reused by clients who have no intentions of leveraging the new query service.
+
This document will detail out the structure of the code and the minimum API set required to be implemented by contributorsThe document will include code snippets to illustrate the simplicity in leveraging the available APIs.  As part of the implementation of this enhancement the SML repository will be modified based on the refactored code.  The set of classes provided in org.eclipse.cosmos.dc.cmdbf.query will be divided into the following sets:
  
Since the current consumers of the SML repository convenience APIs don't exploit the full range of query capabilities afforded by the query service, a programming interface will also be available to allow queries to be submitted using the XML schema described in the CMDBf standard.
+
# CMDBfCommon.jar
</p>
+
# CMDBfQueryTransformation.jar
 +
# CMDBfQueryService.jar
 +
# CMDBfRegistrationTransformation.jar
 +
# CMDBfRegistrationService.jar
  
 +
<br/>
 +
The CMDBfCommon module will include any code that will be required by two or more of the other modules.  The dependency of the modules is discussed in more details under the 'Implementation Detail' section.
 +
 +
The set included under CMDBfQueryTransformation.jar will contain any necessary code for clients who intend to build a CMDBf query and consume a query response.  It performs the following transformations:
 +
 +
* CMDBf XML query document > POJO representation of the query
 +
* POJO representation of the query > CMDBf XML query document
 +
* CMDBf XML query response > POJO representation of the query response
 +
* POJO representation of the query response > CMDBf XML query response
 +
<br/>
 +
 +
Adopters can choose to use CMDBfQueryTransformation.jar as is or have it tweaked based on their needs.  What will be included in this jar file will be a concrete implementation of the transformations.
 +
 +
Similarly, CMDBfRegistrationTransformation.jar will include a concrete implementation of the transformation required from an XML registration request to a POJO representation (and vice-versa).
 +
</p>
 
<p>
 
<p>
There will likely be common set of code between the COSMOS client and the SML repositoryIt's expected that this common set will reside under the data collection subprojectOne of the primary objectives of this document is to identify this reusable set of common code.
+
CMDBfQueryService.jar will contain the necessary code for processing a query that conforms to CMDBfThis set will allow the user to provide implementation of selector handlers that are specific to a data providerCMDBfQueryService.jar cannot be used as-is and will require a minimum API set to be implemented.
 +
 
 +
Similarly, CMDBfRegistrationService.jar can be used by contributors to help in processing a registration request.
 
</p>
 
</p>
  
 
== ''' Requirements ''' ==
 
== ''' Requirements ''' ==
 +
The following is the list of requirements that this enhancement will address:
  
This section lists the requirements of this enhancement:
+
# Checking the conformance of a CMDBf query against its schema
# Querying the SML repository using the XML query format specified in the CMDBf specification
+
# Checking the conformance of a CMDBf registration request against its schema
# Producing query results to clients using the XML response format specified in the CMDBf specification
+
# Transformation of CMDBf XML query from/to a POJO representation
 +
# Transformation of CMDBf XML registration from/to a POJO representation
 +
# A common method of processing a CMDBf query
 +
# A common method of processing a registration request
  
== ''' Use Cases ''' ==
+
== ''' Implementation Detail ''' ==
  
For the following use cases, the SML repository acting as an MDR will contain the data described in the <code>org.eclipse.cosmos.rm.example.datacenter</code> COSMOS plug-in:
+
The plug-in org.eclipse.cosmos.dc.cmdbf.query will be refactored to org.eclipse.cosmos.dc.cmdbf.services.  The new plug-in will include a source folder for each of the modules mentioned earlier.  The dependency of each module is depicted in the diagram below.  The successive sections discuss the transformation and the processing APIs that will be included as part of this plug-in.
  
==== '''Use Case 1: Retrieve All Computers Using Red Hat Linux 8''' ====
+
[[Image:CMDBf-Dependency.png]]
# Client connects to the SML repository
+
# Client submits request for the CMDBf query service operation
+
# Client sets the argument of the operation to a query that will retrieve: all computers with an installed OS with a brand name of "Red Hat 8"
+
# Client runs the operation
+
# Client retrieves the response from the operation's output
+
  
==== '''Use Case 2: Retrieve All Computers With At Least 2000 MB RAM''' ====  
+
== Transformations ==
# Client connects to the SML repository
+
=== Query ===
# Client submits client request for the CMDBf query service operation
+
# Client sets the argument of the operation to a query that will retrieve: all computers with a RAM value greater than or equal to 2000 MB.
+
# Client runs the operation
+
# Client retrieves the response from the operation's output
+
  
==== '''Use Case 3: Retrieve All Server Software''' ====
+
[http://cmdbf.org/CMDBf-v0.95.pdf CMDBf] specifies an XML-based syntax by which queries are submitted to the query service, which reports back a query result from the available MDRs, also using XML syntax.  As part of our implementation of the query service, we internally accept POJOs to represent a graph of the query, and return the query result as a set of POJOs. The job of the transformers is to convert POJOs to and from the XML syntax detailed in the CMDBf specification. 
# Client connects to the SML repository
+
# Client submits client request for the CMDBf query service operation
+
# Client sets the argument of the operation to a query that will retrieve: all server software.
+
# Client runs the operation
+
# Client retrieves the response from the operation's output
+
  
==== '''Use Case 4: Retrieve Serial Numbers and Disk Drive Capacities''' ====
+
As part of [[COSMOS Design 200222]], a set of query transformations and an SML-repository-specific query service were designed and implemented.  In an effort to make these components reusable, the query transformations will be refactored to share common components needed by other libraries in this design.  The initial candidate classes to be moved to the common module are <tt>IXMLWritable</tt>, <tt>QueryServiceUtil</tt> (which will be renamed) and some of the fields in <tt>IQueryTransformerConstants</tt> (the ones pertaining to character constants and general SAX parsing).
# Client connects to the SML repository
+
# Client submits client request for the CMDBf query service operation
+
# Client sets the argument of the operation to a query that will retrieve: the serial numbers and disk drive capacities of all computers.
+
# Client runs the operation
+
# Client retrieves the response from the operation's output
+
  
==== '''Use Case 5: Retrieve All Non-database Software on Linux Machines''' ====
+
In addition, the previously implemented packages will be renamed to include the word "provisional", which in the [http://www.eclipse.org/tptp/home/documents/process/development/api_contract.html API contract specifications] we are reusing from the TPTP project, indicates that the APIs are experimental and will be evolved into stable public APIs.  
# Client connects to the SML repository
+
# Client submits client request for the CMDBf query service operation
+
# Client sets the argument of the operation to a query that will retrieve: all software installed on Linux machines that is not a relational database.
+
# Client runs the operation
+
# Client retrieves the response from the operation's output
+
  
== ''' Implementation Detail ''' ==
+
Here is a simple example that illustrates the incoming query input transformation:
  
The following section details out the implementation of the CMDBf query service for the SML repository.  As mentioned before, the SML repository has defined a set of convenience APIs that it is currently leveraged by clients.  The implementation of this enhancement will need to understand queries based on the CMDBf specification and make use of the convenience APIs to fetch the required data.
+
<tt>InputStream inputStream = new ByteArrayInputStream(example1().getBytes());<br>
 +
Query query = QueryInputTransformer.transform(inputStream);</tt>
  
=== Scope ===
+
Assume that <tt>example1()</tt> returns a String containing the XML syntax for a <query> as specified in the CMDBf spec.
<p>
+
Using the <code>instanceIdSelector</code> under the <code>itemTemplate</code> is equivalent to fetching documents with an <code>org.eclipse.cosmos.rm.repository.provisional.resource.ISMLMetadata</code> that has a specific ID.  The property, xpath, and the record type selectors will all be supported under the <code>itemTemplate</code> element.  Clients will also be able to use the <code>propertySubsetDirective</code> to return a set of desired properties, instead of full records.
+
</p>
+
  
<p>
+
=== Registration ===
The only valid relationship between items stored in an SML repository is the <i>'references'</i> relationship.  Item i1 <i>references</i> i2 if and only if there exists an inter-document reference of i2 in the SML document representation of i1.  All <code>relationshipTemplate</code> elements should include a record type selector with:
+
<ul>
+
<li>namespace = "http://cosmos.org" </li>
+
<li>localName = "references" </li>
+
</ul>
+
No other selectors should be used in conjunction with this relationship. 
+
</p>
+
  
<p>
+
CMDBf specifies a registration service by which MDRs register items and relationships with the federating CMDBThe process for registration involves an XML-based transaction, similar to how the query service works. This enhancement will provide a transformer to convert a registration request from XML to a POJO graph structure, and will also provide the reverse of that transformation.  In addition, it will provide another transformer that will convert a registration response output by the MDR from a POJO graph structure to the XML-based syntax expected by the CMDBf spec, and will again provide a reverse of that transformation.  The reverse transformations are needed by some clients of the registration service, and also are useful in unit testing of the implementation.
The list below summarizes the scope of this enhancement:
+
* This enhancement will not provide an implementation of a federating CMDB
+
* The client will directly access the MDR and get data through the query service
+
* There will only be one MDR in COSMOS for i6. This will be the COSMOS SML repository
+
* The Registration service, as described by the CMDBf spec will not be implemented for i6 (Since there is no federating CMDB available)
+
* The SML Repository MDR can be referenced with the ID: http://cosmos.org/rm/sml/repository
+
</p>
+
  
=== Architecture ===
+
The following new classes will provide these transformations:
<p>
+
The flow diagram below depicts how the query service will process an input. The service will apply the selectors in the following order:
+
<ol>
+
<li>instanceIdSelector</li>
+
<li>recordTypeSelector</li>
+
<li>propertyValueSelector</li>
+
<li>xpath1Selector</li>
+
</ol>
+
The instance and record type selectors are faster and effective mechanisms of narrowing the result set for a query, whereas the property and xpath selectors are more processor intensive operations that are applied in the end. 
+
</p>
+
  
<p>
+
org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.RegistrationInputTransformer
[[Image:QueryService-FlowDiagram.png]]
+
org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.RegistrationOutputTransformer
</p>
+
  
<p>
+
The following are the transformation APIs on the RegistrationInputTransformer class:
The CMDBf query service will be implemented as an operation of the SML repository. Similar to the validation, import, and export operations, a client will first need to establish a connection to the repository to obtain the CMDBf query operationThe operation will take an input stream as argument and will produce an input stream as output. The argument is expected to be set to the XML query and the output will be the query response.
+
 
</p>
+
  static public RegisterRequest transform(InputStream)
 +
static public InputStream transform(RegisterRequest)
 +
 
 +
The following are the transformation APIs on the RegistrationOutputTransformer class:
 +
 
 +
static public RegisterResponse transform(InputStream)
 +
static public InputStream transform(RegisterResponse)
 +
 
 +
RegisterRequest and RegisterResponse POJOs will consist of APIs and classes that match or closely mirror the corresponding element names in the CMDBf data modelRegisterRequest will reside in the <tt>org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.input.artifacts</tt> package and RegisterResponse will live in the <tt>org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.response.artifacts</tt> package.
 +
 
 +
Here is a simple example that illustrates the incoming registration input transformation:
 +
 
 +
<tt>InputStream inputStream = new ByteArrayInputStream(example1().getBytes());<br>
 +
RegisterRequest registerRequest = RegistrationInputTransformer.transform(inputStream);</tt>
 +
 
 +
Assume that <tt>example1()</tt> returns a String containing the XML syntax for a <registerRequest> as specified in the CMDBf spec.
 +
 
 +
== Services ==
 +
=== Query ===
  
 +
The class diagram below displays the interfaces and default implementations that will be included for the query service.  All that a contributor is required to do is to register the classes that will be used as handlers for the selectors.  The default implementation of the CMDBf query operation will look up the appropriate handlers and will invoke them accordingly.
 +
<br/><br/><br/>
 
<p>
 
<p>
There will be a reusable component under the data collection subproject that will need to transform an XML query into a graph that is understandable by the query service.  There also needs to be a common component to convert a graph representing a query response into an XML document that conforms to the CMDBf standard.  The image below depicts the interaction between the query service provider, the SML repository, and the query service.  The input and output transformers are reusable components that will reside under the data collection subproject.  There needs to be a mirror operation provided for the output transformation to convert an XML query response into a graph representation.  This is useful for clients that intend to traverse through a POJO representation of the response.
+
[[Image:QueryService-v1.png]]
 
</p>
 
</p>
  
 
<p>
 
<p>
[[Image:QueryService-Interactions.png]]
+
The following is a snippet of code that illustrates how a contributor can register a set of selector handlers with the default implementation of <code>ISelectorHandlerFactory</code>.:
</p>
+
  
<p> The diagram above does not include the sequence of steps needed for a client to access a query service end pointIt only depicts the layer that will reside behind a WSDM end point that the COSMOS client will remotely access.  The end-to-end interaction between the client and the query service should be described in the design of: https://bugs.eclipse.org/bugs/show_bug.cgi?id=200244There needs to be a systematic method defined for a client to access the query service of MDRs. </p>
+
<code>
 +
<pre>
 +
SelectorHandlerFactory.getInstance().addHandlers
 +
(
 +
        new URI ("http://cosmos.org/mdrId"),
 +
        ISelectorHandlerFactory.ITEM_TEMPLATE,
 +
        new String[]
 +
        {
 +
            "org.eclipse.cosmos.sample.handlers.InstanceIdHandler",
 +
            "org.eclipse.cosmos.sample.handlers.RecordTypeHandler",
 +
            "org.eclipse.cosmos.sample.handlers.PropertyValueHandler",
 +
            "org.eclipse.cosmos.sample.handlers.XPath1Handler"
 +
        }
 +
);
 +
</pre>
 +
</code>
 +
 
 +
Once the selectors are registered a client can make use of the CMDBf query service using the default implementation of <code>ICMDBfQueryOperation</code>The argument passed into the <code>initialize</code> method represents a data provider that will be passed to each of the selector handlers.  The selector handlers can cast the argument to a specific type that can process native queries that is understandable by a specific data provider.  The following snippet of code illustrates how the query operation can be invoked:
 +
 
 +
<code>
 +
<pre>
 +
// Create a CMDBf query operation object and have it initialized
 +
CMDBfQueryOperation cmdbfQueryOperation = new CMDBfQueryOperation();
 +
cmdbfQueryOperation.initialize(new SampleDataProvider());
 +
 +
// Execute the query
 +
Query query = retrieveQuery();
 +
cmdbfQueryOperation.execute(query);
 +
</pre>
 +
</code>
 +
 
 +
Assuming <code>retrieveQuery()</code> will return a POJO representation of a CMDBf query.
 +
 
 +
=== Registration ===
 +
The diagram below shows the relationship between the classes of the registration service.  The APIs are very symmetric to the ones provided for the query service.  An adopter will need to subscribe register handlers for specific MDR IDs.  The subscribed register handlers will be invoked if the MDR ID of the registration request matches that of the ID associated with the handler.
 +
 
 +
[[Image:RegistrationService-v2.png]]
 +
 
 +
The snippet of code below shows how a client can subscribe a registration handler.  <code>CustomRegistrationHandler</code> is expected to be an implementation of <code>IRegisterHandler</code>.
 +
 
 +
<code>
 +
<pre>
 +
 
 +
RegisterHandlerSubscription.getInstance().addHandler
 +
(
 +
      new URI("http://cosmos.org/mdrId"),
 +
      new CustomRegistrationHandler()
 +
  );
 +
</pre>
 +
</code>
 +
 
 +
The default implementation of <code>ICMDBfRegistrationOperation</code> can be used to process a registration request.  The snippet below shows how a client can use the operation:
 +
 
 +
<code>
 +
<pre>
 +
// Perform the initialization
 +
CMDBfRegistrationOperation registrationOperation = new CMDBfRegistrationOperation();
 +
registrationOperation.initialize(new SampleDataProvider());
 +
 +
// Execute the operation
 +
Registration registration = retrieveRegistration();
 +
registrationOperation.execute(registration);
 +
</pre>
 +
</code>
 +
 
 +
Assuming <code>retrieveRegistration()</code> will return a POJO representation of a CMDBf registration request.
  
 
== ''' Test Coverage ''' ==
 
== ''' Test Coverage ''' ==
 +
 
Unit tests will need to perform the following tests:
 
Unit tests will need to perform the following tests:
  
* Complex tests outlined in the Use Cases section of this document
+
* Transform a RegisterRequest POJO to XML and back to a POJO, and compare the start and end POJOs
* Tests using an instance selector, one with 0 results and one with exactly 1 result.  More than one result will be logged as a failure.
+
* Transform a RegisterResponse POJO to XML and back to a POJO, and compare the start and end POJOs
* Tests using a property value selector, one for each of the following operators:
+
* Process an empty query
** equal (caseSensitive attribute set to true, set to false, and omitted; negate set to true, false, or omitted; string, boolean, time, and integer types used)
+
* Processing a query with just one item
** less (negate set to true, false, or omitted; string, time, and integer types used)
+
* Processing a query with a relationship and no items
** lessOrEqual (negate set to true, false, or omitted; string, time, and integer types used)
+
* Processing a query with matching items and an unmatched relationship
** greater (negate set to true, false, or omitted; string, time, and integer types used)
+
* Processing a query with matching items and a matched relationship
** greaterOrEqual (negate set to true, false, or omitted; string, time, and integer types used)
+
* Processing a query with a relationship that has cardinality
** contains (caseSensitive attribute set to true, set to false, and omitted; negate set to true, false, or omitted)
+
* Processing a query with unregistered selector handlers
** like (caseSensitive attribute set to true, set to false, and omitted; negate set to true, false, or omitted)
+
* Processing an empty registration request
** isNull (negate set to true, false, or omitted)
+
* Processing a registration request with one item
* Tests using a record type selector:
+
* Processing a registration request with matched items and missing relationship
** type is exact type match
+
* Processing a registration request with matched items and a relationship
** type requested is supertype of existing record
+
* Processing a registration request with a relationship and no items
* Tests using an XPath selector:
+
* Processing a registration request with missing registration handlers
** using correct syntax for expression, with and without results
+
** using incorrect syntax for expression
+
* Tests combining 2 item templates and a relationship template, that use a drop selector to exclude the relationship template and the 2nd item template
+
* Tests using a property subset directive
+
** with two properties listed
+
** with no properties listed
+
* Tests using relationship cardinality, using minimum, maximum, and both attributes
+
  
 
== ''' Task Breakdown ''' ==
 
== ''' Task Breakdown ''' ==
<p>
 
The following section includes the tasks required to complete this enhancement along with a PERT chart that displays the dependencies of each task.
 
</p>
 
<p>
 
[[image:QueryService-PertChart.png]]
 
</p>
 
<p>
 
# Create graph representation of query input and response
 
# Create the input transformer
 
# Create the output transformer
 
# Add in the query service as an SML repository operation
 
# Create a generic framework for implementing selectors
 
# Add in the instance id selector
 
# Create JUnit tests for the instance id selector
 
# Add in the record type selector
 
# Create JUnit tests for the record type selector
 
# Add in the property value selector
 
# Create JUnit tests for the property value selector
 
# Add in the xpath selector
 
# Create JUnit tests for the xpath selector
 
# Implement the property subset directive
 
# Ensure that all selectors work with <code>itemTemplate</code> elements
 
# Implement the relationship template constraint
 
# Add Junit tests for querying items and relationships
 
</p>
 
  
== '''Open Issues/Questions '''==
+
The following section includes the tasks required to complete this enhancement <!--along with a PERT chart that displays the dependencies of each task-->.
  
All reviewer feedback should go in the [[Talk:COSMOS_Design_200222|Talk page for 200222]].
+
[[image:CMDBf-PertChart-v1.png]]
 +
 
 +
 
 +
# Refactor plugin, package and class names in cmdbf.query plugin to represent the 5 different jar configurations
 +
# Refactor the JUnits for the query transformation
 +
# Create graph representation of registration request and response
 +
# Create the registration input transformer
 +
# Create the registration output transformer
 +
# Add in JUnits for the registration transformer
 +
# Add in the APIs for processing a CMDBf query
 +
# Implement a generic implementation of the CMDBf query processor
 +
# Add in JUnits for the CMDBf query APIs
 +
# Modify the SML repository to make use of the new API set
 +
# Add in the APIs for processing a CMDBf registration request
 +
# Implement a generic implementation of the CMDBf registration processor
 +
# Add in JUnits for the registration APIs
 +
 
 +
== '''Open Issues/Questions '''==
  
Issues (and potential errors) regarding the CMDBf spec, v0.95.  Email responses from a member of the CMDBf expert group are marked in <font color=red>red</font>.
+
All reviewer feedback should go in the [[Talk:COSMOS_Design_204959|Talk page for 204959]].
All of the examples and psuedo-schema in section 4.3.1 for <tt><prefixMapping></tt> have the attributes "prefix" and "'''value'''".  However, the data model XSD in appendix B (and on the CMDBf site) lists the following as the two <tt>prefixMapping</tt> attributes as "prefix" and "'''namespace'''".  When I wrote some <tt><query></tt> testcases based on the samples in the CMDBf spec, the schema validation failed.
+
* In the query result example in section 4.4, both <relationship> instances have the same recordId as each other. <font color=red>Agree</font>
+
* In the relationship records in that example, the "foo" namespace maps to http://example.com/computerModel in both cases?  Earlier, "comp" was used with that same URL, so it would seem the URL would need to be changed in the "foo" case, or the "foo" example should use "comp" again. <font color=red>Agree</font>
+
* On line 1205, it says <nowiki>"http://example.com/administers/PeteTheLabLabTechToLabMachineA"</nowiki>.  Note the "LabLab" typo. <font color=red>Agree</font>
+
* All of the included examples (such as on line 1086) begin with <tt><query></tt>.  I believe they should instead look like this: <tt><query xmlns="http://schemas.cmdbf.org/0-9-5/datamodel"></tt> Making this change will make the query service code a lot easier to write, as the SAX validating parser only works if it has the correct <code>xmlns</code> value.  It looks like some revisions of the document did include an <code>xmlns</code> attribute, but for some reason it was not included in the current one available at cmdbf.org. <font color=red>That's definitely the namespace for the <query> so including it is certainly correct & you should feel free to do so.</font>
+
* Line 757 should be </contains> instead of </stringContains> <font color=red>Agree</font>
+
* According to the pseudo schema of xpath1Selector, there are 0 or more prefix mappings that can be included under <xpath1Selector>.  The CMDBf data model schema does not specify a minOccurs/maxOccurs for the prefixMapping element.  <code><xs:element name="prefixMapping" type="cmdbf:PrefixMappingType" /></code> should be: <code><xs:element name="prefixMapping" type="cmdbf:PrefixMappingType" minOccurs="0" maxOccurs="unbounded"/></code>
+
 
----
 
----
 
[[Category:COSMOS_Bugzilla_Designs]]
 
[[Category:COSMOS_Bugzilla_Designs]]

Latest revision as of 11:22, 23 October 2007

Provide reusable CMDBf APIs for adopters that intend to provide a CMDBf query/registration service

Change History

Name: Date: Revised Sections:
Ali Mehregani 10/04/2007
  • Initial version
David Whiteman 10/05/2007
  • Added details regarding service transformations
Valentina Popescu 10/23/2007
  • Updated SML Repository definition.

Workload Estimation

Rough workload estimate in person weeks
Process Sizing Names of people doing the work
Design 1 David/Ali
Code 2 David/Ali
Test 1 David/Ali
Documentation 0.4
Build and infrastructure 0.2
Code review, etc.* 0.2
TOTAL 4.8

Terminologies/Acronyms

The terminologies/acronyms below are commonly used throughout this document. The list below defines each term regarding how it is used in this document:

Term Definition
MDR management data repository
CMDBf specification for a CMDB that federates between multiple MDRs[1]
federating CMDB the CMDB that federates between MDRs, offering a common access point to clients and correlating identifying record data
CMDB configuration management database
SML Repository The SML Repository describes any SML model ( an SML model is a set of SML compliant resources ) together with a set of COSMOS API used to add new SML resources to the SML model and to query the SML model.
Query service MDRs make data available to Clients via a Query service. Queries may select and return items, relationships, and/or graphs containing items and relationships.
Registration service This service is used to register a set of supported items and relationships with a federating CMDB.

Purpose

This enhancement is associated with bugzilla 204959.

The purpose of this enhancement is to refactor the CMDBf query code to make it more reusable. The SML repository already defines a set of APIs related to the CMDBf query. This set needs to be migrated to org.eclipse.cosmos.dc.cmdbf.query so that it can be reused by contributors who intend to provide a query service for a data provider.

Another purpose of this enhancement is to implement the registration transformation code, and provide reusable APIs for the CMDBf registration service.

This document will detail out the structure of the code and the minimum API set required to be implemented by contributors. The document will include code snippets to illustrate the simplicity in leveraging the available APIs. As part of the implementation of this enhancement the SML repository will be modified based on the refactored code. The set of classes provided in org.eclipse.cosmos.dc.cmdbf.query will be divided into the following sets:

  1. CMDBfCommon.jar
  2. CMDBfQueryTransformation.jar
  3. CMDBfQueryService.jar
  4. CMDBfRegistrationTransformation.jar
  5. CMDBfRegistrationService.jar

The CMDBfCommon module will include any code that will be required by two or more of the other modules. The dependency of the modules is discussed in more details under the 'Implementation Detail' section. The set included under CMDBfQueryTransformation.jar will contain any necessary code for clients who intend to build a CMDBf query and consume a query response. It performs the following transformations:
  • CMDBf XML query document > POJO representation of the query
  • POJO representation of the query > CMDBf XML query document
  • CMDBf XML query response > POJO representation of the query response
  • POJO representation of the query response > CMDBf XML query response

Adopters can choose to use CMDBfQueryTransformation.jar as is or have it tweaked based on their needs. What will be included in this jar file will be a concrete implementation of the transformations. Similarly, CMDBfRegistrationTransformation.jar will include a concrete implementation of the transformation required from an XML registration request to a POJO representation (and vice-versa).

CMDBfQueryService.jar will contain the necessary code for processing a query that conforms to CMDBf. This set will allow the user to provide implementation of selector handlers that are specific to a data provider. CMDBfQueryService.jar cannot be used as-is and will require a minimum API set to be implemented. Similarly, CMDBfRegistrationService.jar can be used by contributors to help in processing a registration request.

Requirements

The following is the list of requirements that this enhancement will address:

  1. Checking the conformance of a CMDBf query against its schema
  2. Checking the conformance of a CMDBf registration request against its schema
  3. Transformation of CMDBf XML query from/to a POJO representation
  4. Transformation of CMDBf XML registration from/to a POJO representation
  5. A common method of processing a CMDBf query
  6. A common method of processing a registration request

Implementation Detail

The plug-in org.eclipse.cosmos.dc.cmdbf.query will be refactored to org.eclipse.cosmos.dc.cmdbf.services. The new plug-in will include a source folder for each of the modules mentioned earlier. The dependency of each module is depicted in the diagram below. The successive sections discuss the transformation and the processing APIs that will be included as part of this plug-in.

CMDBf-Dependency.png

Transformations

Query

CMDBf specifies an XML-based syntax by which queries are submitted to the query service, which reports back a query result from the available MDRs, also using XML syntax. As part of our implementation of the query service, we internally accept POJOs to represent a graph of the query, and return the query result as a set of POJOs. The job of the transformers is to convert POJOs to and from the XML syntax detailed in the CMDBf specification.

As part of COSMOS Design 200222, a set of query transformations and an SML-repository-specific query service were designed and implemented. In an effort to make these components reusable, the query transformations will be refactored to share common components needed by other libraries in this design. The initial candidate classes to be moved to the common module are IXMLWritable, QueryServiceUtil (which will be renamed) and some of the fields in IQueryTransformerConstants (the ones pertaining to character constants and general SAX parsing).

In addition, the previously implemented packages will be renamed to include the word "provisional", which in the API contract specifications we are reusing from the TPTP project, indicates that the APIs are experimental and will be evolved into stable public APIs.

Here is a simple example that illustrates the incoming query input transformation:

InputStream inputStream = new ByteArrayInputStream(example1().getBytes());
Query query = QueryInputTransformer.transform(inputStream);

Assume that example1() returns a String containing the XML syntax for a <query> as specified in the CMDBf spec.

Registration

CMDBf specifies a registration service by which MDRs register items and relationships with the federating CMDB. The process for registration involves an XML-based transaction, similar to how the query service works. This enhancement will provide a transformer to convert a registration request from XML to a POJO graph structure, and will also provide the reverse of that transformation. In addition, it will provide another transformer that will convert a registration response output by the MDR from a POJO graph structure to the XML-based syntax expected by the CMDBf spec, and will again provide a reverse of that transformation. The reverse transformations are needed by some clients of the registration service, and also are useful in unit testing of the implementation.

The following new classes will provide these transformations:

org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.RegistrationInputTransformer
org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.RegistrationOutputTransformer

The following are the transformation APIs on the RegistrationInputTransformer class:

static public RegisterRequest transform(InputStream)
static public InputStream transform(RegisterRequest)

The following are the transformation APIs on the RegistrationOutputTransformer class:

static public RegisterResponse transform(InputStream)
static public InputStream transform(RegisterResponse)

RegisterRequest and RegisterResponse POJOs will consist of APIs and classes that match or closely mirror the corresponding element names in the CMDBf data model. RegisterRequest will reside in the org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.input.artifacts package and RegisterResponse will live in the org.eclipse.cosmos.dc.cmdbf.services.provisional.registration.transform.response.artifacts package.

Here is a simple example that illustrates the incoming registration input transformation:

InputStream inputStream = new ByteArrayInputStream(example1().getBytes());
RegisterRequest registerRequest = RegistrationInputTransformer.transform(inputStream);

Assume that example1() returns a String containing the XML syntax for a <registerRequest> as specified in the CMDBf spec.

Services

Query

The class diagram below displays the interfaces and default implementations that will be included for the query service. All that a contributor is required to do is to register the classes that will be used as handlers for the selectors. The default implementation of the CMDBf query operation will look up the appropriate handlers and will invoke them accordingly.


QueryService-v1.png

The following is a snippet of code that illustrates how a contributor can register a set of selector handlers with the default implementation of ISelectorHandlerFactory.:

 SelectorHandlerFactory.getInstance().addHandlers
 (
        new URI ("http://cosmos.org/mdrId"), 
        ISelectorHandlerFactory.ITEM_TEMPLATE,
        new String[]
        {
             "org.eclipse.cosmos.sample.handlers.InstanceIdHandler",
             "org.eclipse.cosmos.sample.handlers.RecordTypeHandler",
             "org.eclipse.cosmos.sample.handlers.PropertyValueHandler",
             "org.eclipse.cosmos.sample.handlers.XPath1Handler"
        }
 );

Once the selectors are registered a client can make use of the CMDBf query service using the default implementation of ICMDBfQueryOperation. The argument passed into the initialize method represents a data provider that will be passed to each of the selector handlers. The selector handlers can cast the argument to a specific type that can process native queries that is understandable by a specific data provider. The following snippet of code illustrates how the query operation can be invoked:

 // Create a CMDBf query operation object and have it initialized
 CMDBfQueryOperation cmdbfQueryOperation = new CMDBfQueryOperation();
 cmdbfQueryOperation.initialize(new SampleDataProvider());
		
 // Execute the query
 Query query = retrieveQuery();
 cmdbfQueryOperation.execute(query);	

Assuming retrieveQuery() will return a POJO representation of a CMDBf query.

Registration

The diagram below shows the relationship between the classes of the registration service. The APIs are very symmetric to the ones provided for the query service. An adopter will need to subscribe register handlers for specific MDR IDs. The subscribed register handlers will be invoked if the MDR ID of the registration request matches that of the ID associated with the handler.

RegistrationService-v2.png

The snippet of code below shows how a client can subscribe a registration handler. CustomRegistrationHandler is expected to be an implementation of IRegisterHandler.


 RegisterHandlerSubscription.getInstance().addHandler
 (
      new URI("http://cosmos.org/mdrId"), 
      new CustomRegistrationHandler()
 );

The default implementation of ICMDBfRegistrationOperation can be used to process a registration request. The snippet below shows how a client can use the operation:

 // Perform the initialization
 CMDBfRegistrationOperation registrationOperation = new CMDBfRegistrationOperation();
 registrationOperation.initialize(new SampleDataProvider());
	
 // Execute the operation
 Registration registration = retrieveRegistration();
 registrationOperation.execute(registration);

Assuming retrieveRegistration() will return a POJO representation of a CMDBf registration request.

Test Coverage

Unit tests will need to perform the following tests:

  • Transform a RegisterRequest POJO to XML and back to a POJO, and compare the start and end POJOs
  • Transform a RegisterResponse POJO to XML and back to a POJO, and compare the start and end POJOs
  • Process an empty query
  • Processing a query with just one item
  • Processing a query with a relationship and no items
  • Processing a query with matching items and an unmatched relationship
  • Processing a query with matching items and a matched relationship
  • Processing a query with a relationship that has cardinality
  • Processing a query with unregistered selector handlers
  • Processing an empty registration request
  • Processing a registration request with one item
  • Processing a registration request with matched items and missing relationship
  • Processing a registration request with matched items and a relationship
  • Processing a registration request with a relationship and no items
  • Processing a registration request with missing registration handlers

Task Breakdown

The following section includes the tasks required to complete this enhancement .

CMDBf-PertChart-v1.png


  1. Refactor plugin, package and class names in cmdbf.query plugin to represent the 5 different jar configurations
  2. Refactor the JUnits for the query transformation
  3. Create graph representation of registration request and response
  4. Create the registration input transformer
  5. Create the registration output transformer
  6. Add in JUnits for the registration transformer
  7. Add in the APIs for processing a CMDBf query
  8. Implement a generic implementation of the CMDBf query processor
  9. Add in JUnits for the CMDBf query APIs
  10. Modify the SML repository to make use of the new API set
  11. Add in the APIs for processing a CMDBf registration request
  12. Implement a generic implementation of the CMDBf registration processor
  13. Add in JUnits for the registration APIs

Open Issues/Questions

All reviewer feedback should go in the Talk page for 204959.


Back to the top