javax.management.MalformedObjectNameException Java Examples
The following examples show how to use
javax.management.MalformedObjectNameException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NamingResourcesMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Add a resource link reference for this web application. * * @param resourceLinkName New resource link reference name * @param type New resource link reference type */ public String addResourceLink(String resourceLinkName, String type) throws MalformedObjectNameException { NamingResources nresources = (NamingResources) this.resource; if (nresources == null) { return null; } ContextResourceLink resourceLink = nresources.findResourceLink(resourceLinkName); if (resourceLink != null) { throw new IllegalArgumentException ("Invalid resource link name - already exists'" + resourceLinkName + "'"); } resourceLink = new ContextResourceLink(); resourceLink.setName(resourceLinkName); resourceLink.setType(type); nresources.addResourceLink(resourceLink); // Return the corresponding MBean name ManagedBean managed = registry.findManagedBean("ContextResourceLink"); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), resourceLink); return (oname.toString()); }
Example #2
Source File: AbstractProtocol.java From tomcatsrc with Apache License 2.0 | 6 votes |
private ObjectName createObjectName() throws MalformedObjectNameException { // Use the same domain as the connector domain = adapter.getDomain(); if (domain == null) { return null; } StringBuilder name = new StringBuilder(getDomain()); name.append(":type=ProtocolHandler,port="); int port = getPort(); if (port > 0) { name.append(getPort()); } else { name.append("auto-"); name.append(getNameIndex()); } InetAddress address = getAddress(); if (address != null) { name.append(",address="); name.append(ObjectName.quote(address.getHostAddress())); } return new ObjectName(name.toString()); }
Example #3
Source File: CachingFileSystem.java From rubix with Apache License 2.0 | 6 votes |
public static void setLocalBookKeeper(BookKeeperService.Iface bookKeeper, String statsMbeanSuffix) { bookKeeperFactory = new BookKeeperFactory(bookKeeper); if (!Strings.isNullOrEmpty(statsMbeanSuffix)) { String mBeanName = statsMBeanBaseName + "," + statsMbeanSuffix; MBeanExporter exporter = new MBeanExporter(ManagementFactory.getPlatformMBeanServer()); try { if (ManagementFactory.getPlatformMBeanServer().isRegistered(new ObjectName(statsMBeanBaseName))) { exporter.unexport(statsMBeanBaseName); } if (!ManagementFactory.getPlatformMBeanServer().isRegistered(new ObjectName(mBeanName))) { exporter.export(mBeanName, statsMBean); } } catch (MalformedObjectNameException e) { log.error("Could not export stats mbean", e); } } }
Example #4
Source File: MemoryUserDatabaseMBean.java From tomcatsrc with Apache License 2.0 | 6 votes |
/** * Return the MBean Name for the specified group name (if any); * otherwise return <code>null</code>. * * @param groupname Group name to look up */ public String findGroup(String groupname) { UserDatabase database = (UserDatabase) this.resource; Group group = database.findGroup(groupname); if (group == null) { return (null); } try { ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group); return (oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for group [" + groupname + "]"); iae.initCause(e); throw iae; } }
Example #5
Source File: JMXUtils.java From herddb with Apache License 2.0 | 6 votes |
public static void unregisterDBManagerStatsMXBean() { if (platformMBeanServer == null) { return; } try { ObjectName name = new ObjectName("herddb.server:type=Server"); if (platformMBeanServer.isRegistered(name)) { try { platformMBeanServer.unregisterMBean(name); } catch (InstanceNotFoundException noProblem) { } } } catch (MalformedObjectNameException | MBeanRegistrationException e) { throw new HerdDBInternalException("Could not unregister MXBean " + e); } }
Example #6
Source File: JMXUtils.java From blazingcache with Apache License 2.0 | 6 votes |
public static <K, V> void registerStatisticsMXBean(BlazingCacheCache<K, V> cache, BlazingCacheStatisticsMXBean<K, V> bean) { if (platformMBeanServer == null) { throw new CacheException("PlatformMBeanServer not available", mBeanServerLookupError); } String cacheManagerName = safeName(cache.getCacheManager().getURI().toString()); String cacheName = safeName(cache.getName()); try { ObjectName name = new ObjectName("javax.cache:type=CacheStatistics,CacheManager=" + cacheManagerName + ",Cache=" + cacheName); if (platformMBeanServer.isRegistered(name)) { try { platformMBeanServer.unregisterMBean(name); } catch (InstanceNotFoundException noProblem) { } } platformMBeanServer.registerMBean(bean, name); } catch (MalformedObjectNameException | InstanceAlreadyExistsException | MBeanRegistrationException | NotCompliantMBeanException e) { throw new CacheException("Could not register MXBean " + e); } }
Example #7
Source File: MetadataNamingStrategy.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Reads the {@code ObjectName} from the source-level metadata associated * with the managed resource's {@code Class}. */ @Override public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException { Class<?> managedClass = AopUtils.getTargetClass(managedBean); ManagedResource mr = this.attributeSource.getManagedResource(managedClass); // Check that an object name has been specified. if (mr != null && StringUtils.hasText(mr.getObjectName())) { return ObjectNameManager.getInstance(mr.getObjectName()); } else { try { return ObjectNameManager.getInstance(beanKey); } catch (MalformedObjectNameException ex) { String domain = this.defaultDomain; if (domain == null) { domain = ClassUtils.getPackageName(managedClass); } Hashtable<String, String> properties = new Hashtable<String, String>(); properties.put("type", ClassUtils.getShortName(managedClass)); properties.put("name", beanKey); return ObjectNameManager.getInstance(domain, properties); } } }
Example #8
Source File: UserMBean.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
/** * Return the MBean Names of all groups this user is a member of. */ public String[] getGroups() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<String>(); Iterator<Group> groups = user.getGroups(); while (groups.hasNext()) { Group group = null; try { group = groups.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for group " + group); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #9
Source File: ObjectNameAddressUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
/** * Creates an ObjectName representation of a {@link PathAddress}. * @param domain the JMX domain to use for the ObjectName. Cannot be {@code null} * @param pathAddress the address. Cannot be {@code null} * @param context contextual objection that allows this method to cache state across invocations. May be {@code null} * @return the ObjectName. Will not return {@code null} */ static ObjectName createObjectName(final String domain, final PathAddress pathAddress, ObjectNameCreationContext context) { if (pathAddress.size() == 0) { return ModelControllerMBeanHelper.createRootObjectName(domain); } final StringBuilder sb = new StringBuilder(domain); sb.append(":"); boolean first = true; for (PathElement element : pathAddress) { if (first) { first = false; } else { sb.append(","); } escapeKey(ESCAPED_KEY_CHARACTERS, sb, element.getKey(), context); sb.append("="); escapeValue(sb, element.getValue(), context); } try { return ObjectName.getInstance(sb.toString()); } catch (MalformedObjectNameException e) { throw JmxLogger.ROOT_LOGGER.cannotCreateObjectName(e, pathAddress, sb.toString()); } }
Example #10
Source File: UserMBean.java From Tomcat8-Source-Read with MIT License | 6 votes |
/** * @return the MBean Names of all groups this user is a member of. */ public String[] getGroups() { User user = (User) this.resource; ArrayList<String> results = new ArrayList<>(); Iterator<Group> groups = user.getGroups(); while (groups.hasNext()) { Group group = null; try { group = groups.next(); ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group); results.add(oname.toString()); } catch (MalformedObjectNameException e) { IllegalArgumentException iae = new IllegalArgumentException ("Cannot create object name for group " + group); iae.initCause(e); throw iae; } } return results.toArray(new String[results.size()]); }
Example #11
Source File: JmxRegistrationCallbackTest.java From javasimon with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Test public void managerClearTest() throws MalformedObjectNameException { String counterName = "test.1"; ObjectName counterObjectName = new ObjectName(DOMAIN + ":type=" + SimonInfo.COUNTER + ",name=" + counterName); String stopwatchName = "test.2"; ObjectName stopwatchObjectName = new ObjectName(DOMAIN + ":type=" + SimonInfo.STOPWATCH + ",name=" + stopwatchName); Assert.assertFalse(mbs.isRegistered(counterObjectName)); Assert.assertFalse(mbs.isRegistered(stopwatchObjectName)); SimonManager.getCounter(counterName); Assert.assertTrue(mbs.isRegistered(counterObjectName)); SimonManager.getStopwatch(stopwatchName); Assert.assertTrue(mbs.isRegistered(stopwatchObjectName)); SimonManager.clear(); Assert.assertFalse(mbs.isRegistered(counterObjectName)); Assert.assertFalse(mbs.isRegistered(stopwatchObjectName)); }
Example #12
Source File: JMXUtils.java From blazingcache with Apache License 2.0 | 6 votes |
/** * Unregister the mbean providing the status related to the specified {@link CacheClient}. * * @param client the client on which status mbean has to be unregistered */ public static void unregisterClientStatusMXBean(final CacheClient client) { if (platformMBeanServer == null) { return; } final String cacheClientId = safeName(client.getClientId()); try { final ObjectName name = new ObjectName("blazingcache.client.management:type=CacheClientStatus,CacheClient=" + cacheClientId); if (platformMBeanServer.isRegistered(name)) { try { platformMBeanServer.unregisterMBean(name); } catch (InstanceNotFoundException noProblem) { LOGGER.warning("Impossible to unregister non-registered mbean: " + name + ". Cause: " + noProblem); } } } catch (MalformedObjectNameException | MBeanRegistrationException e) { throw new BlazingCacheManagementException(REGISTRATION_FAILURE_MSG, e); } }
Example #13
Source File: RMRest.java From scheduling with GNU Affero General Public License v3.0 | 6 votes |
@Override public Map<String, Map<String, Object>> getNodesMBeanHistory(String sessionId, List<String> nodesJmxUrl, String objectName, List<String> attrs, String range) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, NotConnectedException, MalformedObjectNameException, NullPointerException, MBeanException { // checking that still connected to the RM RMProxyUserInterface rmProxy = checkAccess(sessionId); return nodesJmxUrl.stream().collect(Collectors.toMap(nodeJmxUrl -> nodeJmxUrl, nodeJmxUrl -> { try { return processHistoryResult(rmProxy.getNodeMBeanHistory(nodeJmxUrl, objectName, attrs, range), range); } catch (Exception e) { LOGGER.error(e); return Collections.EMPTY_MAP; } })); }
Example #14
Source File: Util.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
public static ObjectName newObjectName(String name) { try { return ObjectName.getInstance(name); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException(e); } }
Example #15
Source File: AMXClient.java From hottub with GNU General Public License v2.0 | 5 votes |
private static ObjectName makeObjectName( String str ) { try { return new ObjectName(str); } catch (MalformedObjectNameException ex) { return null ; } }
Example #16
Source File: ClusterJspHelper.java From RDFS with Apache License 2.0 | 5 votes |
/** * Connect to namenode to get decommission node information. * @param statusMap data node status map */ private void getDecomNodeInfoForReport( Map<String, Map<String, String>> statusMap) throws IOException, MalformedObjectNameException { getLiveNodeStatus(statusMap, address, mxbeanProxy.getLiveNodes()); getDeadNodeStatus(statusMap, address, mxbeanProxy.getDeadNodes()); getDecommissionNodeStatus(statusMap, address, mxbeanProxy.getDecomNodes()); }
Example #17
Source File: Util.java From JDKSourceCode1.8 with MIT License | 5 votes |
public static ObjectName newObjectName(String string) { try { return new ObjectName(string); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException(e); } }
Example #18
Source File: QpidJmsTestSupport.java From qpid-jms with Apache License 2.0 | 5 votes |
protected TopicViewMBean getProxyToTopic(BrokerService broker, String name) throws MalformedObjectNameException, JMSException { ObjectName topicViewMBeanName = new ObjectName( broker.getBrokerObjectName() + ",destinationType=Topic,destinationName=" + name); TopicViewMBean proxy = (TopicViewMBean) brokerService.getManagementContext() .newProxyInstance(topicViewMBeanName, TopicViewMBean.class, true); return proxy; }
Example #19
Source File: ObjectNameFactory.java From wildfly-camel with Apache License 2.0 | 5 votes |
public static ObjectName create(String domain, Hashtable<String, String> table) { try { return new ObjectName(domain, table); } catch (MalformedObjectNameException e) { throw new IllegalArgumentException("Malformed ObjectName", e); } }
Example #20
Source File: ThreadsMemory.java From visualvm with GNU General Public License v2.0 | 5 votes |
private static ObjectName getThreadName() { try { return new ObjectName(ManagementFactory.THREAD_MXBEAN_NAME); } catch (MalformedObjectNameException ex) { throw new RuntimeException(ex); } }
Example #21
Source File: MetaDataProvider.java From Moss with Apache License 2.0 | 5 votes |
private void initServerPort() { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); Set<ObjectName> objectNames; try { objectNames = mBeanServer.queryNames(new ObjectName("*:type=Connector,*"), Query.match(Query.attr("protocol"), Query.value("HTTP/1.1"))); } catch (MalformedObjectNameException e) { return; } tomcatPort = Integer.valueOf(objectNames.iterator().next().getKeyProperty("port")); }
Example #22
Source File: MBeanExporterTests.java From spring-analysis-note with MIT License | 5 votes |
private void assertListener(MockMBeanExporterListener listener) throws MalformedObjectNameException { ObjectName desired = ObjectNameManager.getInstance(OBJECT_NAME); assertEquals("Incorrect number of registrations", 1, listener.getRegistered().size()); assertEquals("Incorrect number of unregistrations", 1, listener.getUnregistered().size()); assertEquals("Incorrect ObjectName in register", desired, listener.getRegistered().get(0)); assertEquals("Incorrect ObjectName in unregister", desired, listener.getUnregistered().get(0)); }
Example #23
Source File: MetadataNamingStrategy.java From spring-analysis-note with MIT License | 5 votes |
/** * Reads the {@code ObjectName} from the source-level metadata associated * with the managed resource's {@code Class}. */ @Override public ObjectName getObjectName(Object managedBean, @Nullable String beanKey) throws MalformedObjectNameException { Assert.state(this.attributeSource != null, "No JmxAttributeSource set"); Class<?> managedClass = AopUtils.getTargetClass(managedBean); ManagedResource mr = this.attributeSource.getManagedResource(managedClass); // Check that an object name has been specified. if (mr != null && StringUtils.hasText(mr.getObjectName())) { return ObjectNameManager.getInstance(mr.getObjectName()); } else { Assert.state(beanKey != null, "No ManagedResource attribute and no bean key specified"); try { return ObjectNameManager.getInstance(beanKey); } catch (MalformedObjectNameException ex) { String domain = this.defaultDomain; if (domain == null) { domain = ClassUtils.getPackageName(managedClass); } Hashtable<String, String> properties = new Hashtable<>(); properties.put("type", ClassUtils.getShortName(managedClass)); properties.put("name", beanKey); return ObjectNameManager.getInstance(domain, properties); } } }
Example #24
Source File: ObjectNameManager.java From spring-analysis-note with MIT License | 5 votes |
/** * Retrieve the {@code ObjectName} instance corresponding to the supplied name. * @param objectName the {@code ObjectName} in {@code ObjectName} or * {@code String} format * @return the {@code ObjectName} instance * @throws MalformedObjectNameException in case of an invalid object name specification * @see ObjectName#ObjectName(String) * @see ObjectName#getInstance(String) */ public static ObjectName getInstance(Object objectName) throws MalformedObjectNameException { if (objectName instanceof ObjectName) { return (ObjectName) objectName; } if (!(objectName instanceof String)) { throw new MalformedObjectNameException("Invalid ObjectName value type [" + objectName.getClass().getName() + "]: only ObjectName and String supported."); } return getInstance((String) objectName); }
Example #25
Source File: AgentImpl.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * Constructs a new Agent using the specified configuration. * * @param agentConfig instance of configuration for Agent * @throws com.gemstone.gemfire.admin.AdminException TODO-javadocs * @throws IllegalArgumentException if agentConfig is null */ public AgentImpl(AgentConfig agentConfig) throws AdminException, IllegalArgumentException { addShutdownHook(); if (agentConfig == null) { throw new IllegalArgumentException(LocalizedStrings.AgentImpl_AGENTCONFIG_MUST_NOT_BE_NULL.toLocalizedString()); } this.agentConfig = (AgentConfigImpl)agentConfig; this.mbeanName = MBEAN_NAME_PREFIX + MBeanUtil.makeCompliantMBeanNameProperty("Agent"); try { this.objectName = new ObjectName(this.mbeanName); } catch (MalformedObjectNameException ex) { String s = LocalizedStrings.AgentImpl_WHILE_CREATING_OBJECTNAME_0.toLocalizedString(new Object[] { this.mbeanName }); throw new AdminException(s, ex); } this.propertyFile = this.agentConfig.getPropertyFile().getAbsolutePath(); // bind address only affects how the Agent VM connects to the system... // It should be set only once in the agent lifecycle this.agentConfig.setBindAddress(getBindAddress()); // init the logger initLogWriter(); mBeanServer = MBeanUtil.start(); MBeanUtil.createMBean(this); initializeHelperMbean(); }
Example #26
Source File: JMXUtils.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
public static List<ManagedCacheMBean> getTotalManagedCache(List<Pair<String,JMXConnector>> mbscArray) throws MalformedObjectNameException, IOException { List<ManagedCacheMBean> managedCache = new ArrayList<>(); List<ManagedCache> mc = new ArrayList<>(); for (Pair<String,JMXConnector> mbsc: mbscArray) { managedCache.add(getNewMBeanProxy(mbsc.getSecond(),TOTAL_MANAGED_CACHE, ManagedCacheMBean.class)); } return managedCache; }
Example #27
Source File: MBeanRegistrar.java From helix with Apache License 2.0 | 5 votes |
public static ObjectName buildObjectName(String domain, String... keyValuePairs) throws MalformedObjectNameException { if (keyValuePairs.length < 2 || keyValuePairs.length % 2 != 0) { throw new IllegalArgumentException("key-value pairs for ObjectName must contain even " + "number of String and at least 2 String"); } StringBuilder objectNameStr = new StringBuilder(); for (int i = 0; i < keyValuePairs.length; i += 2) { objectNameStr.append( String.format(i == 0 ? "%s=%s" : ",%s=%s", keyValuePairs[i], keyValuePairs[i + 1])); } return new ObjectName(String.format("%s:%s", domain, objectNameStr.toString())); }
Example #28
Source File: IdentityNamingStrategy.java From spring-analysis-note with MIT License | 5 votes |
/** * Returns an instance of {@code ObjectName} based on the identity * of the managed resource. */ @Override public ObjectName getObjectName(Object managedBean, @Nullable String beanKey) throws MalformedObjectNameException { String domain = ClassUtils.getPackageName(managedBean.getClass()); Hashtable<String, String> keys = new Hashtable<>(); keys.put(TYPE_KEY, ClassUtils.getShortName(managedBean.getClass())); keys.put(HASH_CODE_KEY, ObjectUtils.getIdentityHexString(managedBean)); return ObjectNameManager.getInstance(domain, keys); }
Example #29
Source File: JmxDatabaseAdminstrator.java From spliceengine with GNU Affero General Public License v3.0 | 5 votes |
@Override public void setWritePoolMaxThreadCount(final int maxThreadCount) throws SQLException{ operate(new JMXServerOperation(){ @Override public void operate(List<Pair<String, JMXConnector>> connections) throws MalformedObjectNameException, IOException, SQLException{ List<ThreadPoolStatus> threadPools=JMXUtils.getMonitoredThreadPools(connections); for(ThreadPoolStatus threadPool : threadPools){ threadPool.setMaxThreadCount(maxThreadCount); } } }); }
Example #30
Source File: NodeProbe.java From stratio-cassandra with Apache License 2.0 | 5 votes |
/** * Retrieve Proxy metrics * @param metricName Exceptions, Load, TotalHints or TotalHintsInProgress. */ public long getStorageMetric(String metricName) { try { return JMX.newMBeanProxy(mbeanServerConn, new ObjectName("org.apache.cassandra.metrics:type=Storage,name=" + metricName), JmxReporter.CounterMBean.class).getCount(); } catch (MalformedObjectNameException e) { throw new RuntimeException(e); } }