Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

JmxConstants.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2004 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk.
00022  * Contributor(s): _______________________.
00023  */
00024 
00025 package org.objectweb.cjdbc.common.jmx;
00026 
00027 import javax.management.ObjectName;
00028 
00029 /**
00030  * This class contains static information on the jmx services.
00031  * 
00032  * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
00033  * @version 1.0
00034  */
00035 public final class JmxConstants
00036 {
00037   /** Overall Debug tag for Jmx calls */
00038   public static final boolean DEBUG                      = false;
00039 
00040   /** Keep connection alive ? */
00041   public static final boolean KEEP_CONNECTION_ALIVE      = true;
00042 
00043   /** Default domain name for JMX */
00044   public static final String  JMX_DEFAULT_DOMAIN_NAME    = "jmx";
00045   /** Default Jmx type */
00046   public static final String  JMX_DEFAULT_MBEAN_TYPE     = "mbean";
00047 
00048   /** Reference name for Jndi */
00049   public static final String  JndiName                   = "jrmp";
00050 
00051   /** The default jmx name for the agent to connect to */
00052   public static final String  DEFAULT_JMX_AGENT_NAME     = "default";
00053 
00054   /** RMI Adaptor */
00055   public static final String  ADAPTOR_TYPE_RMI           = "rmiAdaptor";
00056 
00057   /** ssl config for rmi */
00058   public static final String  CONNECTOR_RMI_SSL          = "jmx.rmi.ssl";
00059 
00060   /** Http adaptor */
00061   public static final String  ADAPTOR_TYPE_HTTP          = "httpAdaptor";
00062 
00063   /** jmx authenticator username */
00064   public static final String  CONNECTOR_AUTH_USERNAME    = "jmx.auth.username";
00065   /** jmx authenticator password */
00066   public static final String  CONNECTOR_AUTH_PASSWORD    = "jmx.auth.password";
00067 
00068   /** Default RMI port number value. */
00069   public static final int     DEFAULT_JMX_RMI_PORT       = 1090;
00070 
00071   /** Default JMX server HTTP adaptor port value. */
00072   public static final int     DEFAULT_JMX_HTTP_PORT      = 8090;
00073 
00074   /**
00075    * This is in the xsl transformation file, so we should leave as is. Other
00076    * domain are filtered.
00077    */
00078   public static final String  CJDBC_DOMAIN_NAME          = "c-jdbc";
00079 
00080   /** the controller mbean type */
00081   public static final String  CJDBC_TYPE_CONTROLLER      = "controller";
00082   /** the virtual database mbean type */
00083   public static final String  CJDBC_TYPE_VIRTUALDATABASE = "virtualdatabase";
00084   /** the data collector mbean type */
00085   public static final String  CJDBC_TYPE_DATACOLLECTOR   = "datacollector";
00086   /** the backend mbean type */
00087   public static final String  CJDBC_TYPE_BACKEND         = "backend";
00088   /** the recovery log mbean type */
00089   private static final String CJDBC_TYPE_RECOVERYLOG     = "recoverylog";
00090   /** the cache mbean type */
00091   private static final String CJDBC_TYPE_CACHE           = "cache";
00092   /** the request manager mbean type */
00093   private static final String CJDBC_TYPE_REQUEST_MANAGER = "requestmanager";
00094 
00095   private static final String CJDBC_TYPE_LOAD_BALANCER   = "loadbalancer";      ;
00096 
00097   /**
00098    * Get the associated jmx object name
00099    * 
00100    * @param name the name of the mbean
00101    * @param type the c-jdbc type of the mbean
00102    * @return the associated object name, no exception is thrown as the object
00103    *         name calculated is always valid ex;
00104    *         c-jdbc:type:=&lt;type&gt;:name:=&lt;name&gt;
00105    */
00106   public static ObjectName getJmxObjectName(String name, String type)
00107   {
00108     try
00109     {
00110       return new ObjectName(CJDBC_DOMAIN_NAME + ":type=" + type + ",name="
00111           + name);
00112     }
00113     catch (Exception e)
00114     {
00115       e.printStackTrace();
00116       // impossible?
00117       return null;
00118     }
00119   }
00120 
00121   /**
00122    * Get the associated controller object name
00123    * 
00124    * @return c-jdbc:type:=&lt;controller&gt;:name:=&lt;name&gt;
00125    */
00126   public static ObjectName getControllerObjectName()
00127   {
00128     return getJmxObjectName(CJDBC_TYPE_CONTROLLER, CJDBC_TYPE_CONTROLLER);
00129   }
00130 
00131   /**
00132    * Get the associated virtualdatabase object name
00133    * 
00134    * @param name the name of the virtualdatabase
00135    * @return c-jdbc:type:=&lt;virtualdatabase&gt;:name:=&lt;name&gt;
00136    */
00137   public static ObjectName getVirtualDbObjectName(String name)
00138   {
00139     return getJmxObjectName(name, CJDBC_TYPE_VIRTUALDATABASE);
00140   }
00141 
00142   /**
00143    * Get the associated data collector object name
00144    * 
00145    * @return c-jdbc:type:=&lt;datacollector&gt;:name:=&lt;name&gt;
00146    */
00147   public static ObjectName getDataCollectorObjectName()
00148   {
00149     return getJmxObjectName(CJDBC_TYPE_DATACOLLECTOR, CJDBC_TYPE_DATACOLLECTOR);
00150   }
00151 
00152   /**
00153    * Get the associated data collector object name
00154    * 
00155    * @param vdbName name of the virtual database
00156    * @param name name of the backend
00157    * @return c-jdbc:type:=&lt;datacollector&gt;:name:=&lt;name&gt;
00158    */
00159   public static ObjectName getDatabaseBackendObjectName(String vdbName,
00160       String name)
00161   {
00162     return getJmxObjectName(vdbName + "--" + name, CJDBC_TYPE_BACKEND);
00163   }
00164 
00165   /**
00166    * Get the associated recovery log object name
00167    * 
00168    * @param vdbName name of the virtual database
00169    * @return c-jdbc:type:=&lt;recoverylog&gt;:name:=&lt;name&gt;
00170    */
00171   public static ObjectName getRecoveryLogObjectName(String vdbName)
00172   {
00173     return getJmxObjectName(vdbName + "--recoverylog", CJDBC_TYPE_RECOVERYLOG);
00174   }
00175 
00176   /**
00177    * Get the associated cache object name
00178    * 
00179    * @param vdbName name of the virtual database
00180    * @return c-jdbc:type:=&lt;cache&gt;:name:=&lt;name&gt;
00181    */
00182   public static ObjectName getCacheObjectName(String vdbName)
00183   {
00184     return getJmxObjectName(vdbName + "--cache", CJDBC_TYPE_CACHE);
00185   }
00186 
00187   /**
00188    * Get the associated request manager object name
00189    * 
00190    * @param vdbName name of the virtual database
00191    * @return c-jdbc:type:=&lt;requestmanager&gt;:name:=&lt;name&gt;
00192    */
00193   public static ObjectName getRequestManagerObjectName(String vdbName)
00194   {
00195     return getJmxObjectName(vdbName + "--requestmanager",
00196         CJDBC_TYPE_REQUEST_MANAGER);
00197   }
00198 
00199   /**
00200    * Retrieve the owning database objectname of this backend's objectname
00201    * 
00202    * @param backend the objectname of the backend
00203    * @return the objectname of the owning database.
00204    */
00205   public static ObjectName getVirtualDbObjectNameFromBackend(ObjectName backend)
00206   {
00207     String name = backend.toString();
00208     int ind1 = name.indexOf("name=") + 5;
00209     int ind2 = name.indexOf("--", ind1);
00210     String vdbName = name.substring(ind1, ind2);
00211     return getJmxObjectName(vdbName, CJDBC_TYPE_VIRTUALDATABASE);
00212   }
00213 
00214   /**
00215    * Get the associated request manager object name
00216    * 
00217    * @param name name of the virtual database
00218    * @return c-jdbc:type:=&lt;--loadbalancer&gt;:name:=&lt;name&gt;
00219    */
00220   public static ObjectName getLoadBalancerObjectName(String name)
00221   {
00222     return getJmxObjectName(name + "--loadbalancer", CJDBC_TYPE_LOAD_BALANCER);
00223   }
00224 
00225   /**
00226    * C-JDBC rules to determine if a mbean need authentication or not. By default
00227    * all the mbeans need authentication apart from the controller mbean and the
00228    * data collector mbean
00229    * 
00230    * @param mbean <tt>ObjectName</tt> of the mbean to test
00231    * @return <tt>true</tt> if the call to the mbean should have a user and a
00232    *         password attribute attached to it.
00233    */
00234   public static boolean mbeanNeedAuthentication(ObjectName mbean)
00235   {
00236     return (mbean.toString().indexOf(CJDBC_TYPE_CONTROLLER) == -1 && mbean
00237         .toString().indexOf(CJDBC_TYPE_DATACOLLECTOR) == -1);
00238   }
00239 
00240 }

Generated on Mon Apr 11 22:01:32 2005 for C-JDBC by  doxygen 1.3.9.1