API pour accéder aux données de Surveillance du chargement du portlet

Surveillance du chargement du portlet fournit une API permettant d'accéder aux données de surveillance. Vous pouvez utiliser cette API pour l'écriture d'un code personnalisé afin d'avoir accès à ces données.

Remarque : Cette API peut changer dans les prochaines versions du portail. Si vous utilisez cette API, vous devrez peut-être modifier votre code dans les versions ultérieures du portail afin de l'adapter aux changements d'API.

Interface métrique de chargement du portlet

L'objet PortletLoadMetrics est défini dans le package com.ibm.portal.plm.PortletLoadMetrics. Il contient les données métriques pour une PortletDefinition spécifique. L'interface ressemble à ceci :
package com.ibm.portal.plm;

/*
 *  This interface provides access to portlet metrics stored for Portlet Load Monitoring.
 */
public interface PortletLoadMetrics {

	/*
	 * Returns true if the portlet is enabled for rendering (either by admin or by PLM).
	 * If the portlet is disabled for rendering, this method returns false.
	 * 
	 * @return boolean true if the portlet is enabled either by admin or by PLM.
	 */
	public abstract boolean isPortletEnabled();

	/*
	 * Checks if the Portlet is currently enabled for rendering due to PLM constraints.
	 * If PLM disabled the portlet for rendering, this method returns false.
	 * 
	 * @return boolean true if the Portlet is enabled for rendering, 
                     false if the Portlet is disabled for rendering.
	 */
	public abstract boolean isPortletEnabledByPLM();

	/*
	 * Returns true if the portlet is manually enabled by the portal administrator.
	 * If the portal administrator disabled the portlet for rendering, this method returns false.
	 * 
	 * @return boolean true if the portlet is enabled for rendering by the portal administrator.
	 */
	public abstract boolean isPortletEnabledByAdmin();
	
	/*
	 * Returns the number of requests this portlet currently serves.
	 * 
	 * @return int number of requests this portlet currently serves.
	 */
	public abstract int getCurrentNumberOfRequests();

	/*
	 * Calculates the average response time for requests of this portlet in milliseconds.
	 * 
	 * @return int average response time of the portlet in milliseconds.
	 */
	public abstract int getAverageResponseTime();

Service métrique de chargement du portlet

isPortletLoadMetricsService se trouve dans le package com.ibm.portal.plm.service.PortletLoadMetricsService. Vous pouvez utiliser ce service pour accéder à des objets PortletLoadMetrics. Il vous permet également d'analyser des informations générales Surveillance du chargement du portlet connexes. Pour obtenir le PortletLoadMetricsService, vous devez effectuer une recherche JNDI comme suit :
     PortletLoadMetricsEnabled(ObjectID portletID) plm;
      javax.naming.Context ctx = new javax.naming.InitialContext();
      try {
           plm = (PortletLoadMetricsService 
              ctx.lookup(PortletLoadMetricsService.JNDI_NAME);
      } catch(javax.naming.NameNotFoundException ex) {
           ... error handling ...
      }
Une fois que vous avez réussi à obtenir le PortletLoadMetricsService, vous pouvez utiliser les méthodes définies dans l'interface PortletLoadMetrics :
public interface PortletLoadMetricsService {

	String JNDI_NAME = "portal:service/plm/PortletLoadMetrics";
	
	/**
	 * Determines if PLM is enabled for a given portlet. 
	 * 
	 * @param portletID ObjectID of the portlet.
	 * @return true If PLM is enable for a given portlet.
	 * 		   false If PLM is not enabled for a given portlet or if portlet does not exist.
	 */
	boolean isPortletLoadMetricsEnabled(ObjectID portletID); 

	/**
	 * Returns a PortletLoadMetrics object for the portlet. 
	 * Creates the PortletLoadMetrics if PLM is enabled for this portlet and
	 * it the PortletLoadMetrics object does not yet exist.
	 * 
	 * @param portletID ObjectID of the portlet.
	 * @return Reference to a PortletLoadMetrics object.
	 * 		   Null if PLM is not enabled for the specified portlet.
	 */
	PortletLoadMetrics getPortletLoadMetrics(ObjectID portletID);
	
	/**
	 * Returns a String object containing the portlet preference value set for maximum concurrent 
	 * requests allowed for this portlet.
	 * 
	 * @param portletID ObjectID of the portlet.
	 * @return String containing the portlet preference value set for maximum concurrent 
	 *         requests allowed for this portlet. Returns "null" if the portlet did not set the
	 *         portlet preference for maximum concurrent requests.
	 */
	String getMaximumRequestPreferenceValue(ObjectID portletID);
	
	/**
	 * Returns a String object containing the portlet preference value set for the  
	 * reactivation limit for this portlet (PLM self-healing)
	 * 
	 * @param portletID ObjectID of the portlet.
	 * @return String containing the portlet preference value set for the reactivation 
	 *         limit for this portlet (PLM self-healing). Returns "null" if the portlet 
	 *         did not set the portlet preference for the reactivation limit.
	 */
	String getMinimumRequestPreferenceValue(ObjectID portletID);
	
	/**
	 * Returns a String object containing the portlet preference value set for allowed average 
	 * response time for this portlet
	 * 
	 * @param portletID ObjectID of the portlet.
	 * @return String containing the portlet preference value set for allowed average 
	 *         response time for this portlet. Returns "null" if the portlet 
	 *         did not set the portlet preference for allowed average response time.
	 */
	String getAverageResponseTimePreferenceValue(ObjectID portletID);
	
	/**
	 * Returns a Map containing all PortletLoadMetrics objects.
	 * 
	 * @return Map<ObjectID, PortletLoadMetrics> containig all PortletLoadMetrics objects.
	 *         Key of the Map is the ObjectID of the PortletDefinition. 
	 *         The value of the Map is the PortletLoadMetrics object of the PortletDefinition.
	 */
	Map<ObjectID, PortletLoadMetrics> getAllPortletLoadMetricsObjects();

}