blob: 43162da80251e218f99c810165cf671b4e5c2522 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<head>
<title>Apache Felix - ProbeGuide</title>
<link rel="icon" href="/res/favicon.ico">
<link rel="stylesheet" href="/res/site.css" type="text/css" media="all">
<link rel="stylesheet" href="/res/codehilite.css" type="text/css" media="all">
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
</head>
<body>
<div class="title">
<div class="logo">
<a href="https://felix.apache.org/">
<img border="0" alt="Apache Felix" src="/res/logo.png">
</a>
</div>
<div class="header">
<a href="https://www.apache.org/">
<img border="0" alt="Apache" src="/res/apache.png">
</a>
</div>
</div>
<div class="menu">
<style type="text/css">
/* The following code is added by mdx_elementid.py
It was originally lifted from http://subversion.apache.org/style/site.css */
/*
* Hide class="elementid-permalink", except when an enclosing heading
* has the :hover property.
*/
.headerlink, .elementid-permalink {
visibility: hidden;
}
h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
<p><a href="/news.html">News</a> <br />
<a href="/license.html">License</a> <br />
<a href="/downloads.cgi">Downloads</a> <br />
<a href="/documentation.html">Documentation</a> <br />
<a href="/documentation/community/project-info.html">Project Info</a> <br />
<a href="/documentation/community/contributing.html">Contributing</a> <br />
<a href="/sitemap.html">Site Map</a> <br />
<a href="https://www.apache.org/">ASF</a> <br />
<a href="https://www.apache.org/security/">Security</a> <br />
<a href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a> <br />
<a href="https://www.apache.org/foundation/thanks.html">Sponsors</a> </p>
<iframe
src="https://www.apache.org/ads/button.html"
style="border-width:0; float: left"
frameborder="0"
scrolling="no"
width="135"
height="135">
</iframe>
</div>
<div class="main">
<div class="breadcrump" style="font-size: 80%;">
<a href="/">Home</a>&nbsp;&raquo&nbsp;<a href="/documentation.html">Documentation</a>&nbsp;&raquo&nbsp;<a href="/documentation/subprojects/mosgi-managed-osgi-framework.html">MOSGi Managed OSGi framework</a>
</div>
<h1>ProbeGuide</h1>
<style type="text/css">
/* The following code is added by mdx_elementid.py
It was originally lifted from http://subversion.apache.org/style/site.css */
/*
* Hide class="elementid-permalink", except when an enclosing heading
* has the :hover property.
*/
.headerlink, .elementid-permalink {
visibility: hidden;
}
h2:hover > .headerlink, h3:hover > .headerlink, h1:hover > .headerlink, h6:hover > .headerlink, h4:hover > .headerlink, h5:hover > .headerlink, dt:hover > .elementid-permalink { visibility: visible }</style>
<h1 id="developping-probes-for-mosgi-framework">Developping probes for MOSGi framework<a class="headerlink" href="#developping-probes-for-mosgi-framework" title="Permanent link">&para;</a></h1>
<p>{quote}</p>
<p>{quote}
MOSGi is a management infrastructure for OSGi gateways remote management. The architecture relies on JMX management infrastructure and is classically build on a three layered system:</p>
<p>!ManagementLayers.png!
<em> The probe layer: are low layer elements that drive the gateway. They can either get information from the gateway (gateway status) or set information on it (install a bundle),
</em> The Agent layer: there is one agent per gateway and is responsible for maintaining access to a list of available probes,
* The Manager layer is the remote environment that can communicate with the agent to get information from the gateway through the probes</p>
<p>There are various way to implements this architecture (CIM/Wbem, Snmp, JMX). We have choose to use the JMX proposal because it is standardized in the java virtual machine since jdk1.5.</p>
<h1 id="jmx-management-infrastructure-synthesis">JMX management infrastructure synthesis<a class="headerlink" href="#jmx-management-infrastructure-synthesis" title="Permanent link">&para;</a></h1>
<p>Sun JMX proposal defines the following elements :</p>
<p>!JMXLayers.png!
<em> The agent is the registry for probes called MBeans and is accessed through connectors.
</em> MBeans are java objects that register themselves to the agent under some name
* Connectors are end points were external managers can communicate with. There are currently two available connectors : an xml/http connector and a rmi based connector. We are using the rmi connector (JSR160).</p>
<p>In the JMX world probes are represented as MBeans. They are java singleton object that declare a single interface to the agent. This interface is registered under a unique name within the agent namespace. The JMX namespace is structured as a domainname:mbeanname unique name. The following html page represents an example of this kind of namespace (we use the httpconnector connector with the agent to get this information).</p>
<p>!jmxmx4jhtml.png!</p>
<p>These are various mbeans deployed on a specific gateway. We can identify 4 columns : the mbean registered name (and domain), its implementation, a comment and a function to unregister it.</p>
<p>Mbeans are component that declare a management interface that should have a syntactic name similar to the class they instrument. For instance the class foo.Test should implement a management interface whose name is foo.TestMBean. The registration mechanism associates a implementation (conform to the management interface) with an objectName (a unique identifier). The corresponding call is something like :aMbeanServer.register(aMBeanImplementation, anObjectName);. There are many kinds of MBeans (standard, dynamic, model and simple) but their description is out of the scope of this document.</p>
<h1 id="mosgi-probe-developpement">MOSGi probe developpement<a class="headerlink" href="#mosgi-probe-developpement" title="Permanent link">&para;</a></h1>
<p>Our management infrastructure proposes a framework for deploying standard mbean within OSGi gateways. It also embeds a reference to a graphical part (manager view) directly in the Mbean itself. Thus the management console is automatically populated with client part of the management system.</p>
<h2 id="gateway-probes">Gateway probes<a class="headerlink" href="#gateway-probes" title="Permanent link">&para;</a></h2>
<p>These probes are developed in conformance to the following elements.
<em> A probe must be registered under the domain TabUI. It means that they will have a corresponding tab in our management console.
</em> A probe must implement a management interface conform to the JMX specification (ie : foo.LinuxProbe --&gt; foo.LinuxProbeMBean)
<em> The management interface must extend TabIfc (which declares a single method : getBundleName()). This methods returns an url were the management console should find a tab that can establish a management dialog with the probe.
</em> The probe is made available as a standard OSGi Mbean that will make its registration during the bundleActivator start method.</p>
<p>The following picture illustrates relations between these elements.</p>
<p>!MOSGiProbeClasses.png!</p>
<p>For instance a Probe that declares a single management function <em>int getValue()</em>;should provide the following interface:</p>
<div class="codehilite"><pre><span class="n">package</span> <span class="n">foo</span><span class="p">;</span>
<span class="n">import</span> <span class="n">insa</span><span class="p">.</span><span class="n">jmxconsole</span><span class="p">.</span><span class="n">gui</span><span class="p">.</span><span class="n">service</span><span class="p">.</span><span class="n">TabIfc</span><span class="p">;</span>
<span class="n">public</span> <span class="n">interface</span> <span class="n">ProbeMBean</span> <span class="n">extends</span> <span class="n">TabIfc</span> <span class="p">{</span>
<span class="n">public</span> <span class="n">int</span> <span class="n">getValue</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>
<p>And the following class:</p>
<div class="codehilite"><pre><span class="n">package</span> <span class="n">foo</span><span class="p">;</span>
<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">BundleActivator</span><span class="p">;</span>
<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">BundleContext</span><span class="p">;</span>
<span class="n">import</span> <span class="n">org</span><span class="p">.</span><span class="n">osgi</span><span class="p">.</span><span class="n">framework</span><span class="p">.</span><span class="n">ServiceReference</span><span class="p">;</span>
<span class="n">import</span> <span class="n">insa</span><span class="p">.</span><span class="n">jmxconsole</span><span class="p">.</span><span class="n">gui</span><span class="p">.</span><span class="n">service</span><span class="p">.</span><span class="n">TabIfc</span><span class="p">;</span>
<span class="n">import</span> <span class="n">javax</span><span class="p">.</span><span class="n">management</span><span class="p">.</span><span class="n">MBeanServer</span><span class="p">;</span>
<span class="n">public</span> <span class="n">class</span> <span class="n">Probe</span> <span class="n">implements</span> <span class="n">BundleActivator</span><span class="p">,</span><span class="n">ProbeMBean</span><span class="p">{</span>
<span class="o">//////////////////////////////////////////</span>
<span class="o">//</span> <span class="n">BundleActivator</span> <span class="n">Interface</span> <span class="o">//</span>
<span class="o">//////////////////////////////////////////</span>
<span class="o">/*</span> <span class="n">The</span> <span class="n">probe</span> <span class="n">lifecycle</span> <span class="n">is</span> <span class="n">linked</span> <span class="n">to</span> <span class="n">the</span> <span class="n">bundle</span> <span class="n">lifecycle</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">void</span> <span class="n">start</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">bc</span><span class="p">){</span>
<span class="o">/*</span> <span class="n">Here</span> <span class="n">we</span> <span class="n">register</span> <span class="n">the</span> <span class="n">Mbean</span> <span class="n">within</span> <span class="n">the</span> <span class="n">agent</span> <span class="o">*/</span>
<span class="n">ServiceReference</span> <span class="n">sr</span> <span class="p">=</span> <span class="n">context</span><span class="p">.</span><span class="n">getServiceReference</span><span class="p">(</span><span class="n">MBeanServer</span><span class="p">.</span><span class="n">class</span><span class="p">.</span><span class="n">getName</span><span class="p">());</span>
<span class="k">if</span> <span class="p">(</span><span class="n">sr</span>!<span class="p">=</span><span class="n">null</span><span class="p">){</span>
<span class="n">MBeanServer</span> <span class="n">server</span> <span class="p">=</span> <span class="p">(</span><span class="n">MbeanServer</span><span class="p">)</span><span class="n">this</span><span class="p">.</span><span class="n">bc</span><span class="p">.</span><span class="n">getService</span><span class="p">(</span><span class="n">sr</span><span class="p">);</span>
<span class="n">server</span><span class="p">.</span><span class="n">registerMBean</span><span class="p">(</span><span class="n">this</span><span class="p">,</span> <span class="n">new</span> <span class="n">ObjectName</span><span class="p">(</span>&quot;<span class="n">TabUI</span><span class="p">:</span><span class="n">name</span><span class="p">=</span><span class="n">Probe</span>&quot;<span class="p">);</span>
<span class="p">}</span>
<span class="p">}</span>
<span class="n">public</span> <span class="n">void</span> <span class="n">stop</span><span class="p">(</span><span class="n">BundleContext</span> <span class="n">bc</span><span class="p">){...}</span>
<span class="o">///////////////////////////</span>
<span class="o">//</span> <span class="n">Management</span> <span class="n">interface</span> <span class="o">//</span>
<span class="o">///////////////////////////</span>
<span class="n">public</span> <span class="n">int</span> <span class="n">getValue</span><span class="p">(){</span><span class="k">return</span> 10<span class="p">;}</span>
<span class="o">/*</span> <span class="n">A</span> <span class="n">getIfc</span> <span class="k">function</span> <span class="n">comes</span> <span class="n">from</span> <span class="n">RemoteIfc</span> <span class="n">interface</span> <span class="n">that</span> <span class="n">enable</span> <span class="n">the</span> <span class="n">manager</span> <span class="p">(</span><span class="n">remote</span> <span class="n">console</span><span class="p">)</span> <span class="n">to</span>
<span class="n">a</span> <span class="n">bundle</span> <span class="n">that</span> <span class="n">can</span> <span class="n">communicate</span> <span class="n">whith</span> <span class="n">this</span> <span class="n">probe</span> <span class="n">from</span> <span class="n">a</span> <span class="n">remote</span> <span class="n">URL</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">String</span> <span class="n">getBundleName</span><span class="p">(){</span>
<span class="k">return</span> &quot;<span class="n">http</span><span class="p">:</span><span class="o">//</span><span class="n">somewhere</span><span class="o">/</span><span class="n">agraphicaltab</span><span class="p">.</span><span class="n">jar</span>&quot;
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>Once the probe is made as a bundle it can be deployed on the remote gateway. Then a manager (management console) can ask communicate with the gateway agent to manage the probe.</p>
<h2 id="mosgi-jmxconsole-architecture">MOSGi JmxConsole architecture<a class="headerlink" href="#mosgi-jmxconsole-architecture" title="Permanent link">&para;</a></h2>
<p>When a probe is deployed on a remote gateway it is manageable by standard management consoles like JConsole, MC4J... We have developed our own management console that is able to manage probe in a more dedicated approach.</p>
<p>The management console is based on a plugin mechanism. Each plugin is represented as a tab and each tab manages a probe. The console is launched with two bundles. Remotegui.jar is the execution framework and remotecomponent.jar contains a sole remote logger service that gets remote notification from gateways. The screen represented the gateway status after it has been launched.!EmptyConsole.png!
The left panel identifies connected gateways,
The upper center panel is an container for tabs from managed gateways,</p>
<p>The lower center panel contains the remote logger display that shows notifications from remote gateways.
When the user selects a gateway (green flag) the console will do the following actions :
1. Ask all MBeans in the TabUI domain.
1. For each of these MBean, get the URL of bundle that provides the tab. This is done through the call to getBundleName( ) method in RemoteIfc interface.
1. Install the bundle on the gateway</p>
<p>For instance if the user selects the green point he gets the following tabs.</p>
<p>!TabbedConsole.png!</p>
<p>4 probes have been deployed on the remote gateway and 4 graphical tabs have been installed.</p>
<h2 id="graphical-tab-integration">Graphical tab integration<a class="headerlink" href="#graphical-tab-integration" title="Permanent link">&para;</a></h2>
<p>When developing a probe one shall provide a corresponding MOSGi tab. It should follow these guidelines.
<em> It should be a bundle in order to be remotely installed on the console
</em> It should implement Plugin interface with is the jmxconsole container interface specification.</p>
<p>The plugin is mainly conform to the java beans specification development. The jmxconsole acts as a bean container and each tab is a bean in this infrastructure. This is the general architecture of a Tab class.!MOSGiConsoleTabClasses.png!</p>
<p>The plugin interface has the following structure:</p>
<div class="codehilite"><pre><span class="n">package</span> <span class="n">insa</span><span class="p">.</span><span class="n">jmxconsole</span><span class="p">.</span><span class="n">gui</span><span class="p">.</span><span class="n">service</span><span class="p">;</span>
<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">awt</span><span class="p">.</span><span class="n">Component</span><span class="p">;</span>
<span class="n">import</span> <span class="n">java</span><span class="p">.</span><span class="n">beans</span><span class="p">.</span><span class="n">PropertyChangeListener</span><span class="p">;</span>
<span class="n">public</span> <span class="n">interface</span> <span class="n">Plugin</span> <span class="n">extends</span> <span class="n">PropertyChangeListener</span><span class="p">{</span>
<span class="n">public</span> <span class="n">String</span> <span class="n">getName</span><span class="p">();</span> <span class="o">/*</span> <span class="n">The</span> <span class="n">name</span> <span class="n">of</span> <span class="n">the</span> <span class="n">tab</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">Component</span> <span class="n">getGUI</span><span class="p">();</span> <span class="o">/*</span> <span class="n">This</span> <span class="n">is</span> <span class="n">called</span> <span class="n">by</span> <span class="n">the</span> <span class="n">container</span> <span class="n">to</span> <span class="n">get</span> <span class="n">the</span> <span class="n">graphical</span> <span class="n">component</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">void</span> <span class="n">registerServicePlugin</span><span class="p">();</span> <span class="o">/*</span> <span class="n">This</span> <span class="n">is</span> <span class="n">called</span> <span class="n">by</span> <span class="n">the</span> <span class="n">framework</span> <span class="n">when</span> <span class="n">a</span> <span class="n">new</span> <span class="n">gateway</span> <span class="n">is</span> <span class="n">selected</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">void</span> <span class="n">unregisterServicePlugin</span><span class="p">();</span>
<span class="o">/*</span> <span class="n">see</span> <span class="n">before</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">String</span> <span class="n">pluginLocation</span><span class="p">();</span> <span class="o">/*</span> <span class="n">This</span> <span class="n">a</span> <span class="n">unique</span> <span class="n">identifier</span> <span class="n">of</span> <span class="n">the</span> <span class="n">plugin</span> <span class="o">*/</span>
<span class="o">/*</span> <span class="n">These</span> <span class="n">are</span> <span class="n">constants</span> <span class="n">that</span> <span class="n">enable</span> <span class="n">communication</span> <span class="n">between</span> <span class="n">container</span> <span class="n">and</span> <span class="n">plugins</span><span class="p">.</span> <span class="n">They</span> <span class="n">are</span> <span class="n">treated</span> <span class="n">in</span> <span class="n">the</span>
<span class="n">propertyChange</span> <span class="k">function</span> <span class="n">brought</span> <span class="n">by</span> <span class="n">the</span> <span class="n">javabean</span> <span class="n">API</span> <span class="o">*/</span>
<span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">NEW_NODE_SELECTED</span><span class="p">=</span>&quot;<span class="n">newNodeSelected</span>&quot;<span class="p">;</span>
<span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">NEW_NODE_READY</span><span class="p">=</span>&quot;<span class="n">newNodeReady</span>&quot;<span class="p">;</span>
<span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">NEW_NODE_CONNECTION</span><span class="p">=</span>&quot;<span class="n">newNodeConnection</span>&quot;<span class="p">;</span>
<span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">EMPTY_NODE</span><span class="p">=</span>&quot;<span class="n">emptyNode</span>&quot;<span class="p">;</span>
<span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">PLUGIN_ADDED</span><span class="p">=</span>&quot;<span class="n">pluggin_added</span>&quot;<span class="p">;</span>
<span class="n">public</span> <span class="n">static</span> <span class="n">final</span> <span class="n">String</span> <span class="n">PLUGIN_REMOVED</span><span class="p">=</span>&quot;<span class="n">pluggin_removed</span>&quot;<span class="p">;</span>
<span class="p">}</span>
</pre></div>
<p>Implementation tabs are provided as open-source code. You can find various implementation of this interface in felix repository in the <em>mosgi.managedelements.xxx.tab</em> elements.</p>
<h2 id="function-call-sequence">Function call sequence<a class="headerlink" href="#function-call-sequence" title="Permanent link">&para;</a></h2>
<p>The next figure presents a function call sequence when using MOSGi framework.</p>
<div class="timestamp" style="margin-top: 30px; font-size: 80%; text-align: right;">
Rev. 1700393 by cziegeler on Tue, 1 Sep 2015 06:04:06 +0000
</div>
<div class="trademarkFooter">
Apache Felix, Felix, Apache, the Apache feather logo, and the Apache Felix project
logo are trademarks of The Apache Software Foundation. All other marks mentioned
may be trademarks or registered trademarks of their respective owners.
</div>
</div>
</body>
</html>