Entering content frame

This graphic is explained in the accompanying text Example of Using Template Monitors

In our example, the resource provider can use the following template in the monitor-configuration.xml:

<summary name="VIP Clients" configuration-group="BankVIPClientsList">

    <object name="%0" configuration-group="BankVIPClient">

 

     <template-info template-name="BankVIPClientTemplate">

       <polled-by-template period="5" unit="MINUTE">

          <generating-resource name="BankResourceMBean" type="APPLICATION"/>

          <template-attribute-mapping>

             <invoked-resource-method name="listVIPClientIDs"/>

          </template-attribute-mapping> 

       </polled-by-template>

    </template-info>

 

 

     <text-monitor name="Client's Name" configuration-group="BankClientName">

        <monitored-resource name="BankResourceMBean" type="APPLICATION"/>

        <text-attribute-mapping>

           <text-attribute>

             <invoked-resource-method name="getClientName">

                <parameter position="0" type="int" value="%0"/>

             </invoked-resource-method>

           </text-attribute>

        </text-attribute-mapping>

     </text-monitor>

 

     <configuration-monitor name="Client's Address" configuration-group="BankClientAdress">

        <monitored-resource name="BankResourceMBean" type="APPLICATION"/>

        <configuration-attribute-mapping>

           <configuration-attribute>

             <invoked-resource-method name="getClientAddress">

                <parameter position="0" type="int" value="%0"/>

             </invoked-resource-method>

           </configuration-attribute>

        </configuration-attribute-mapping>

     </configuration-monitor>

 

     <long-monitor name="Client's Phone Number" configuration-group="BankClientPhone">

        <monitored-resource name="BankResourceMBean" type="APPLICATION"/>

        <long-attribute-mapping>

           <long-attribute>

             <invoked-resource-method name="getClientPhone">

                <parameter position="0" type="int" value="%0"/>

             </invoked-resource-method>

           </long-attribute>

        </long-attribute-mapping>

     </long-monitor>

 

 

    </object>

</summary>

 

What is interesting in the example above is the <template-info> element and the “%0” sign used in the description of the monitoring tree nodes.

The node under which the <template-info> element is situated is the root of a “template installable” part of the monitoring tree. In our case, the root is the object with configuration group “BankVIPClient”. All the nodes that are described below this root are not installed directly and instead become part of the template (the whole <object> element together with all the elements below it form the template) and are installed together as a sub-tree when dynamic data is provided/retrieved from the monitored resource. For example, if the monitored resource returns the array {0, 1}, two objects with names “0” and “1” will be installed and below each of them there will be three monitors for each of the client’s attributes mentioned before.

Apart from denoting the root of a template, the <template-info> element is used for specifying how dynamic data is provided by the resource MBean to the monitoring framework. In our case, the monitoring framework checks every five minutes for new entities. Another option is the resource MBean to send this data actively using JMX notifications.

The dynamic data listing all the entities (mapping to sub-trees in the monitoring tree) is sent as a one- or two-dimensional array. In the more general case of two-dimensional arrays, each row in the array represents a single entity and is used for the installation of one sub-tree. In order to instruct the template how the data supplied has to be used when installing the sub-tree, the sign “%” is used, followed by a number. The number (starting from 0) is the consecutive number of the value in the entity’s row. In the more simple case with one-dimensional array, only “%0” can be used as there is only one value for each entity.

To get an idea about the case when a two-dimensional array is used, you can imagine that the resource developer does not like to have the clientIDs as names of the objects in the monitoring tree, but prefers a name instead that provides more information. In this case, he/she can return a two-dimensional array in the listVIPClientIDs method where the first value in the row is the clientID and the second value is a descriptive name for this ID. Then in the template, instead of using “%0” as a name, “%1” can be used (while “%0” will still be used as a parameter in the invoked methods in the monitors described below). That is, we will keep everything as it is except for the <object> element which will turn to:

<object name="%1" configuration-group="BankVIPClient">

 

As a result, the objects will be shown with more descriptive names.

Note

One restriction that exists when working with templates is that overlapping templates is not allowed, that is, it is not possible to have a template inside another template.

 

Leaving content frame