[Batchserver-cvs] batchserver/src/org/jmonks/batchserver/framework/management/jmxmp JMXMPConnectorHe
Brought to you by:
suresh_pragada
From: Suresh <sur...@us...> - 2006-03-28 04:56:06
|
Update of /cvsroot/batchserver/batchserver/src/org/jmonks/batchserver/framework/management/jmxmp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2222 Added Files: JMXMPConnectorHelper.java RepositoryJMXMPConnectorHelper.java Removed Files: JMXMPJobConnectorServerHelper.java RepositoryJMXMPJobConnectorServerHelper.java Log Message: no message --- NEW FILE: RepositoryJMXMPConnectorHelper.java --- package org.jmonks.batchserver.framework.management.jmxmp; import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; import java.util.List; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXServiceURL; import org.apache.log4j.Logger; import org.jmonks.batchserver.framework.JobContext; /** * <p> * This connector is based on JMX Messaging protocol and uses the framework * reposiotry as the lookup location to register and unregister the JMX Service URL. * </p> * * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public class RepositoryJMXMPConnectorHelper extends JMXMPConnectorHelper { private static Logger logger=Logger.getLogger(RepositoryJMXMPConnectorHelper.class); /** * @see org.jmonks.batchserver.framework.management.JobConnectorHelper@init(java.util.Map) */ public void init(java.util.Map configProps) { logger.trace("Entering init") ; /** * Because this uses the repository defined for this framework as the * lookup location, this implementation does not require any properties * in configuration file to initialize the lookup location. */ logger.trace("Exiting init") ; } /** * Registers the jmx connector server with the given job name in the repository * defined for this framework. * * @param jobName Name of the job to be used in the registration. * @param jmxConnectorServer JMX connector server identifies where all the manager and montiro mbeans are configured. * * @return Returns true, if it successfully registred in repository, false, otherwise. * * @throws IllegalArgumentException If job name paramter or jmxConnectorServer parameter is null. */ public boolean registerConnectorServer(String jobName,JMXConnectorServer jmxConnectorServer) { logger.trace("Entering registerConnectorServer") ; if(jobName==null) throw new IllegalArgumentException("job name cannot be null to registerd jmx service url."); if(jmxConnectorServer==null) throw new IllegalArgumentException("jmx connector server cannot be null to registerd jmx connector server."); JMXServiceURL jmxServiceURL=jmxConnectorServer.getAddress(); boolean registered=JobContext.getReposiotry().registerJobMgmtMntrInfo(jobName, jmxServiceURL.toString()); logger.debug(jobName + " with the service url " + jmxServiceURL.toString() + " registered in repository = " + registered); logger.trace("Exiting registerConnectorServer") ; return registered; } /** * Unregisters the jmx connector server registered in repository with the given * job name. * * @param jobName Name of the job the connector server registered with. * * @return Returns true, if it successfully unregistered, false otherwise. * * @throws IllegalArgumentException If job name paramter is null. */ public boolean unregisterConnectorServer(String jobName) { logger.trace("Entering unregisterConnectorServer"); if(jobName==null) throw new IllegalArgumentException("job name cannot be null to unregister the service url."); boolean unregistered=JobContext.getReposiotry().unregisterJobMgmtMntrInfo(jobName); logger.debug(jobName + " mgmt and mntr information unregistered = " + unregistered); logger.trace("Exiting unregisterConnectorServer") ; return unregistered; } /** * Gets all the job names registered in the repository as a list. * * @return Returns the list of all the job names registered in repository. */ public List getRegisteredJobList() { return (List)JobContext.getReposiotry().getAllRegisteredMgmtMntrInfo().keySet(); } /** * Returns the JMX connector client for the given job name. * * @return Returns the JXM connector client for the given job name, * null, if it doesnt find or could not create the JMX connector client. * * @throws IllegalArgumentException If job name argument is null. */ public JMXConnector createConnector(String jobName) { if(jobName==null) throw new IllegalArgumentException("job name cannot be null to create the connector."); String serviceURL=(String)JobContext.getReposiotry().lookupJobMgmtMntrInfo(jobName); JMXConnector jmxConnector=null; if(serviceURL==null) jmxConnector=null; else { try { JMXServiceURL jmxServiceURL=new JMXServiceURL(serviceURL); jmxConnector=JMXConnectorFactory.newJMXConnector(jmxServiceURL, new HashMap()); } catch(MalformedURLException exception) { exception.printStackTrace(); logger.error(exception.getMessage(), exception); } catch(IOException exception) { exception.printStackTrace(); logger.error(exception.getMessage(), exception); } } return jmxConnector; } } --- RepositoryJMXMPJobConnectorServerHelper.java DELETED --- --- NEW FILE: JMXMPConnectorHelper.java --- /* * JMXMPConnectorHelper.java * * Created on March 22, 2006, 9:27 PM * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */ package org.jmonks.batchserver.framework.management.jmxmp; import java.io.IOException; import java.net.MalformedURLException; import java.util.HashMap; import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServerFactory; import javax.management.remote.JMXServiceURL; import org.apache.log4j.Logger; import org.jmonks.batchserver.framework.management.JobConnectorHelper; /** * <p> * JMXMPConnectorHelper creates the JMX connector server based on the JMX Messaging * protocol and leaves the lookup location details to the class going to implement this * abstract class. The machine the job being run will be used as the host name and * the port will be selected automatically by the JMX connector server factory. * </p> * @author Suresh Pragada * @version 1.0 * @since 1.0 */ public abstract class JMXMPConnectorHelper extends JobConnectorHelper { private static Logger logger=Logger.getLogger(JMXMPConnectorHelper.class); /** * JMX Messaging Protocol URL to be used to create the connector server. */ private static final String JMXMP_SERVICE_URL = "service:jmx:jmxmp://"; /** * Creates the JMX connector server based on JMX Messaging protocol. This does * not defined the host name and port name in the URL. So, the machine job * being run will be used as the host and port will be automatically choosen. * * @return Returns the JMX connector server, null, if it cannot create the connector server. */ public JMXConnectorServer createConnectorServer() { JMXServiceURL jmxServiceURL=null; JMXConnectorServer jmxConnectorServer=null; try { jmxServiceURL=new JMXServiceURL(JMXMPConnectorHelper.JMXMP_SERVICE_URL); jmxConnectorServer=JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, new HashMap(), null); } catch(MalformedURLException exception) { exception.printStackTrace(); logger.error(exception.getMessage(), exception); } catch(IOException exception) { exception.printStackTrace(); logger.error(exception.getMessage(), exception); } return jmxConnectorServer; } } --- JMXMPJobConnectorServerHelper.java DELETED --- |