List of usage examples for javax.management ObjectName ObjectName
public ObjectName(String name) throws MalformedObjectNameException
From source file:com.cisco.oss.foundation.monitoring.RMIMonitoringAgent.java
public ObjectInstance registerMBean(Object object) { String objName = FoundationMonitoringConstants.DOMAIN_NAME + ":name=" + ComponentInfo.INSTANCE.getName(); if ((ComponentInfo.INSTANCE.getInstance() != null) && (!ComponentInfo.INSTANCE.getInstance().trim().equals(""))) { objName = objName + ",instance=" + ComponentInfo.INSTANCE.getInstance(); }/*from www . j a v a2 s . c o m*/ objName = objName + ",contentSource=" + object.getClass().getSimpleName(); try { return mbs.registerMBean(object, new ObjectName(objName)); } catch (Exception e) { LOGGER.error("Problem registering bean: {}. error is: {}", objName, e, e); throw new IllegalArgumentException(e); } }
From source file:com.cisco.oss.foundation.monitoring.RMIMonitoringAgent.java
private void registerComponentInfo() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { String strMonComponentObjectName = Utility.getObjectName("ComponentInfo", this.exposedObject); this.componentInfoObjectName = new ObjectName(strMonComponentObjectName); mbs.registerMBean(ComponentInfo.INSTANCE, this.componentInfoObjectName); }
From source file:com.groupon.odo.proxylib.BackupService.java
/** * Returns an MBeanServer with the specified name * * @param name//from www.j a v a2 s . com * @return */ private MBeanServer getServerForName(String name) { try { MBeanServer mbeanServer = null; final ObjectName objectNameQuery = new ObjectName(name + ":type=Service,*"); for (final MBeanServer server : MBeanServerFactory.findMBeanServer(null)) { if (server.queryNames(objectNameQuery, null).size() > 0) { mbeanServer = server; // we found it, bail out break; } } return mbeanServer; } catch (Exception e) { } return null; }
From source file:com.spotify.reaper.cassandra.JmxProxy.java
/** * Checks if table exists in the cluster by instantiating a MBean for that table. *//*from www .ja v a 2 s . c o m*/ public boolean tableExists(String ks, String cf) { try { String type = cf.contains(".") ? "IndexColumnFamilies" : "ColumnFamilies"; String nameStr = String.format("org.apache.cassandra.db:type=*%s,keyspace=%s,columnfamily=%s", type, ks, cf); Set<ObjectName> beans = mbeanServer.queryNames(new ObjectName(nameStr), null); if (beans.isEmpty() || beans.size() != 1) { return false; } ObjectName bean = beans.iterator().next(); JMX.newMBeanProxy(mbeanServer, bean, ColumnFamilyStoreMBean.class); } catch (MalformedObjectNameException | IOException e) { String errMsg = String.format("ColumnFamilyStore for %s/%s not found: %s", ks, cf, e.getMessage()); LOG.warn(errMsg, e); return false; } return true; }
From source file:com.sun.grizzly.http.jk.common.ChannelNioSocket.java
public void registerRequest(Request req, MsgContext ep, int count) { if (this.domain != null) { try {/* w ww . j a va 2 s. c o m*/ RequestInfo rp = req.getRequestProcessor(); rp.setGlobalProcessor(global); ObjectName roname = new ObjectName(getDomain() + ":type=RequestProcessor,worker=" + getChannelName() + ",name=JkRequest" + count); ep.setNote(JMXRequestNote, roname); Registry.getRegistry(null, null).registerComponent(rp, roname, null); } catch (Exception ex) { LoggerUtils.getLogger().log(Level.WARNING, "Error registering request"); } } }
From source file:com.cisco.oss.foundation.monitoring.RMIMonitoringAgent.java
private void registerMonitoringConfiguration() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException { MonitorAndManagementSettings monitorAndManagementSettings = getMonitorAndManagementSettings(); String strMonConfigObjectName = Utility.getObjectName("MonitorAndManagementSettings", this.exposedObject); this.monitorAndManagementSettingsObjectName = new ObjectName(strMonConfigObjectName); mbs.registerMBean(monitorAndManagementSettings, this.monitorAndManagementSettingsObjectName); }
From source file:be.fgov.kszbcss.rhq.websphere.component.server.WebSphereServerComponent.java
private OperationResult changeMessageEndpointState(boolean pause) throws Exception { AdminClient adminClient = getServer().getAdminClient(); for (ObjectName endpointObjectName : adminClient .queryNames(new ObjectName("WebSphere:type=J2CMessageEndpoint,*"), null)) { J2CMessageEndpoint endpoint = getServer().getMBeanClient(endpointObjectName) .getProxy(J2CMessageEndpoint.class); if (pause) { endpoint.pause();/*from w w w. jav a 2 s. c o m*/ } else { endpoint.resume(); } } return null; }
From source file:com.groupon.odo.proxylib.BackupService.java
/** * Get a list of strings(scheme + host + port) that the specified connector is running on * * @param name// w ww . j av a 2 s. com * @return */ private ArrayList<String> getConnectorStrings(String name) { ArrayList<String> connectorStrings = new ArrayList<String>(); try { MBeanServer mbeanServer = getServerForName(name); Set<ObjectName> objs = mbeanServer.queryNames(new ObjectName("*:type=Connector,*"), null); String hostname = InetAddress.getLocalHost().getHostName(); InetAddress[] addresses = InetAddress.getAllByName(hostname); for (Iterator<ObjectName> i = objs.iterator(); i.hasNext();) { ObjectName obj = i.next(); String scheme = mbeanServer.getAttribute(obj, "scheme").toString(); String port = obj.getKeyProperty("port"); connectorStrings.add(scheme + "://localhost:" + port); logger.info("Adding: {}", scheme + "://localhost:" + port); } } catch (Exception e) { } return connectorStrings; }
From source file:com.cisco.oss.foundation.monitoring.RMIMonitoringAgent.java
private void registerServices() { try {//w w w . j av a 2 s .c om String strMonConfigObjectName = Utility.getObjectName("ServiceInfo", this.exposedObject); servicesObjectName = new ObjectName(strMonConfigObjectName); mbs.registerMBean(ServiceInfo.INSTANCE, servicesObjectName); } catch (MalformedObjectNameException e) { LOGGER.trace("Failed to register services" + e.getMessage()); } catch (InstanceAlreadyExistsException e) { LOGGER.trace("Failed to register services" + e.getMessage()); } catch (MBeanRegistrationException e) { LOGGER.trace("Failed to register services" + e.getMessage()); } catch (NotCompliantMBeanException e) { LOGGER.trace("Failed to register services" + e.getMessage()); } }
From source file:io.fabric8.mq.autoscaler.MQAutoScaler.java
private ObjectName getBrokerJMXRoot(J4pClient client) throws Exception { String type = "org.apache.activemq:brokerName=*,type=Broker"; String attribute = "BrokerName"; ObjectName objectName = new ObjectName(type); J4pResponse<J4pReadRequest> result = client.execute(new J4pReadRequest(objectName, attribute)); JSONObject jsonObject = result.getValue(); return new ObjectName(jsonObject.keySet().iterator().next().toString()); }