1 24 25 package org.objectweb.cjdbc.common.jmx; 26 27 import javax.management.ObjectName ; 28 29 35 public final class JmxConstants 36 { 37 38 public static final boolean DEBUG = false; 39 40 41 public static final boolean KEEP_CONNECTION_ALIVE = true; 42 43 44 public static final String JMX_DEFAULT_DOMAIN_NAME = "jmx"; 45 46 public static final String JMX_DEFAULT_MBEAN_TYPE = "mbean"; 47 48 49 public static final String JndiName = "jrmp"; 50 51 52 public static final String DEFAULT_JMX_AGENT_NAME = "default"; 53 54 55 public static final String ADAPTOR_TYPE_RMI = "rmiAdaptor"; 56 57 58 public static final String CONNECTOR_RMI_SSL = "jmx.rmi.ssl"; 59 60 61 public static final String ADAPTOR_TYPE_HTTP = "httpAdaptor"; 62 63 64 public static final String CONNECTOR_AUTH_USERNAME = "jmx.auth.username"; 65 66 public static final String CONNECTOR_AUTH_PASSWORD = "jmx.auth.password"; 67 68 69 public static final int DEFAULT_JMX_RMI_PORT = 1090; 70 71 72 public static final int DEFAULT_JMX_HTTP_PORT = 8090; 73 74 78 public static final String CJDBC_DOMAIN_NAME = "c-jdbc"; 79 80 81 public static final String CJDBC_TYPE_CONTROLLER = "controller"; 82 83 public static final String CJDBC_TYPE_VIRTUALDATABASE = "virtualdatabase"; 84 85 public static final String CJDBC_TYPE_DATACOLLECTOR = "datacollector"; 86 87 public static final String CJDBC_TYPE_BACKEND = "backend"; 88 89 private static final String CJDBC_TYPE_RECOVERYLOG = "recoverylog"; 90 91 private static final String CJDBC_TYPE_CACHE = "cache"; 92 93 private static final String CJDBC_TYPE_REQUEST_MANAGER = "requestmanager"; 94 95 private static final String CJDBC_TYPE_LOAD_BALANCER = "loadbalancer"; ; 96 97 106 public static ObjectName getJmxObjectName(String name, String type) 107 { 108 try 109 { 110 return new ObjectName (CJDBC_DOMAIN_NAME + ":type=" + type + ",name=" 111 + name); 112 } 113 catch (Exception e) 114 { 115 e.printStackTrace(); 116 return null; 118 } 119 } 120 121 126 public static ObjectName getControllerObjectName() 127 { 128 return getJmxObjectName(CJDBC_TYPE_CONTROLLER, CJDBC_TYPE_CONTROLLER); 129 } 130 131 137 public static ObjectName getVirtualDbObjectName(String name) 138 { 139 return getJmxObjectName(name, CJDBC_TYPE_VIRTUALDATABASE); 140 } 141 142 147 public static ObjectName getDataCollectorObjectName() 148 { 149 return getJmxObjectName(CJDBC_TYPE_DATACOLLECTOR, CJDBC_TYPE_DATACOLLECTOR); 150 } 151 152 159 public static ObjectName getDatabaseBackendObjectName(String vdbName, 160 String name) 161 { 162 return getJmxObjectName(vdbName + "--" + name, CJDBC_TYPE_BACKEND); 163 } 164 165 171 public static ObjectName getRecoveryLogObjectName(String vdbName) 172 { 173 return getJmxObjectName(vdbName + "--recoverylog", CJDBC_TYPE_RECOVERYLOG); 174 } 175 176 182 public static ObjectName getCacheObjectName(String vdbName) 183 { 184 return getJmxObjectName(vdbName + "--cache", CJDBC_TYPE_CACHE); 185 } 186 187 193 public static ObjectName getRequestManagerObjectName(String vdbName) 194 { 195 return getJmxObjectName(vdbName + "--requestmanager", 196 CJDBC_TYPE_REQUEST_MANAGER); 197 } 198 199 205 public static ObjectName getVirtualDbObjectNameFromBackend(ObjectName backend) 206 { 207 String name = backend.toString(); 208 int ind1 = name.indexOf("name=") + 5; 209 int ind2 = name.indexOf("--", ind1); 210 String vdbName = name.substring(ind1, ind2); 211 return getJmxObjectName(vdbName, CJDBC_TYPE_VIRTUALDATABASE); 212 } 213 214 220 public static ObjectName getLoadBalancerObjectName(String name) 221 { 222 return getJmxObjectName(name + "--loadbalancer", CJDBC_TYPE_LOAD_BALANCER); 223 } 224 225 234 public static boolean mbeanNeedAuthentication(ObjectName mbean) 235 { 236 return (mbean.toString().indexOf(CJDBC_TYPE_CONTROLLER) == -1 && mbean 237 .toString().indexOf(CJDBC_TYPE_DATACOLLECTOR) == -1); 238 } 239 240 } | Popular Tags |