本文整理汇总了Java中javax.management.IntrospectionException类的典型用法代码示例。如果您正苦于以下问题:Java IntrospectionException类的具体用法?Java IntrospectionException怎么用?Java IntrospectionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntrospectionException类属于javax.management包,在下文中一共展示了IntrospectionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMBeanInfo
import javax.management.IntrospectionException; //导入依赖的package包/类
public MBeanInfo getMBeanInfo(ObjectName name)
throws InstanceNotFoundException,
IntrospectionException,
ReflectionException,
IOException {
if (logger.debugOn()) logger.debug("getMBeanInfo", "name=" + name);
final ClassLoader old = pushDefaultClassLoader();
try {
return connection.getMBeanInfo(name, delegationSubject);
} catch (IOException ioe) {
communicatorAdmin.gotIOException(ioe);
return connection.getMBeanInfo(name, delegationSubject);
} finally {
popDefaultClassLoader(old);
}
}
示例2: testInvokeChangeBufferSize
import javax.management.IntrospectionException; //导入依赖的package包/类
/**
* Tests if buffer sizes are changeable via invoke function.
* @throws IOException IOException
* @throws IntrospectionException IntrospectionException
* @throws InstanceNotFoundException InstanceNotFoundException
* @throws ReflectionException ReflectionException
*/
@Test
public void testInvokeChangeBufferSize() throws IOException, IntrospectionException, InstanceNotFoundException, ReflectionException {
//connect to server
final JMXConnector connection = JmxConnectionHelper.buildJmxMPConnector(JMXSERVERIP,serverObj.getConnectorSystemPort());
//get MBeanServerConnection
MBeanServerConnection mbsConnection = JmxServerHelper.getMBeanServer(connection);
//check if mbeans are registered
Assert.assertNotSame(0,mbsConnection.getMBeanCount());
//do actual test
ObjectName networkManagerOn = JmxServerHelper.findObjectName(mbsConnection,"de.b4sh.byter","NetworkManager");
//change writer buffer size
int networkBufferSizeOLD = JmxServerHelper.getNetworkManagerNetworkBufferSize(mbsConnection,networkManagerOn);
int writerBufferSizeOLD = JmxServerHelper.getNetworkManagerWriterBufferSize(mbsConnection,networkManagerOn);
JmxServerHelper.setNetworkManagerNetworkBufferSize(mbsConnection,networkManagerOn,1337);
JmxServerHelper.setNetworkManagerWriterBufferSize(mbsConnection,networkManagerOn,1337);
int networkBufferSize = JmxServerHelper.getNetworkManagerNetworkBufferSize(mbsConnection,networkManagerOn);
int writerBufferSize = JmxServerHelper.getNetworkManagerWriterBufferSize(mbsConnection,networkManagerOn);
Assert.assertNotEquals(networkBufferSize,networkBufferSizeOLD);
Assert.assertNotEquals(writerBufferSize,writerBufferSizeOLD);
Assert.assertEquals(networkBufferSize,1337);
Assert.assertEquals(writerBufferSize,1337);
}
示例3: registerMbeans
import javax.management.IntrospectionException; //导入依赖的package包/类
private static void registerMbeans() {
try {
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
IndexingMbean indexingMbean = IndexingMbean.getInstance();
SearchMbean searchMbean = SearchMbean.getInstance();
GeneralMbean generalMbean = GeneralMbean.getInstance();
JMXBeanWrapper indexingMbeanWrapper = new JMXBeanWrapper(indexingMbean);
JMXBeanWrapper searchMbeanWrapper = new JMXBeanWrapper(searchMbean);
JMXBeanWrapper generalMbeanWrapper = new JMXBeanWrapper(generalMbean);
mbs.registerMBean(indexingMbeanWrapper, new ObjectName("io.logz.benchmarks.elasticsearch:type=Indexing,name=Indexing Metrics"));
mbs.registerMBean(searchMbeanWrapper, new ObjectName("io.logz.benchmarks.elasticsearch:type=Search,name=Search Metrics"));
mbs.registerMBean(generalMbeanWrapper, new ObjectName("io.logz.benchmarks.elasticsearch:type=General,name=General Metrics"));
} catch (IntrospectionException | MalformedObjectNameException | NotCompliantMBeanException |
InstanceAlreadyExistsException | MBeanRegistrationException e) {
throw new RuntimeException("Could not initialize JMX metrics!", e);
}
}
示例4: logPluginConfig
import javax.management.IntrospectionException; //导入依赖的package包/类
protected void logPluginConfig(final String id)
{
try
{
final StringBuilder nameBuff = new StringBuilder(200)
.append("Alfresco:Type=Configuration,Category=Authentication,id1=managed,id2=").append(URLDecoder.decode(id, "UTF-8"));
final ObjectName name = new ObjectName(nameBuff.toString());
if (this.mbeanServer != null && this.mbeanServer.isRegistered(name))
{
final MBeanInfo info = this.mbeanServer.getMBeanInfo(name);
final MBeanAttributeInfo[] attributes = info.getAttributes();
LOGGER.debug("{} attributes:", id);
for (final MBeanAttributeInfo attribute : attributes)
{
final Object value = this.mbeanServer.getAttribute(name, attribute.getName());
LOGGER.debug("{} = {}", attribute.getName(), value);
}
}
}
catch (final MalformedObjectNameException | InstanceNotFoundException | IntrospectionException | AttributeNotFoundException
| ReflectionException | MBeanException | IOException e)
{
LOGGER.warn("Exception during logging", e);
}
}
示例5: testEndpointMBeanExporterWithProperties
import javax.management.IntrospectionException; //导入依赖的package包/类
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertThat(mbeanExporter.getServer().getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context).toString()
+ ",key1=value1,key2=value2"))).isNotNull();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:EndpointMBeanExportAutoConfigurationTests.java
示例6: testMBeanForDatasource
import javax.management.IntrospectionException; //导入依赖的package包/类
private MBeanInfo testMBeanForDatasource() throws Exception {
Map<String, String[]> env = new HashMap<>();
String[] credentials = { "admin", "admin" };
env.put(JMXConnector.CREDENTIALS, credentials);
try {
String url = "service:jmx:rmi://localhost:12311/jndi/rmi://localhost:11199/jmxrmi";
JMXServiceURL jmxUrl = new JMXServiceURL(url);
JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxUrl, env);
MBeanServerConnection mBeanServer = jmxConnector.getMBeanServerConnection();
ObjectName mbeanObject = new ObjectName(dataSourceName + ",-1234:type=DataSource");
MBeanInfo mBeanInfo = mBeanServer.getMBeanInfo(mbeanObject);
return mBeanInfo;
} catch (MalformedURLException | MalformedObjectNameException | IntrospectionException |
ReflectionException e) {
throw new AxisFault("Error while connecting to MBean Server " + e.getMessage(), e);
}
}
示例7: checkAttributeName
import javax.management.IntrospectionException; //导入依赖的package包/类
private String checkAttributeName(ObjectName mBeanName, String attributeName) throws UnsupportedOperationException, InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
MBeanInfo beanInfo = server.getMBeanInfo(mBeanName);
MBeanAttributeInfo monitoredAttribute = null;
MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
for (MBeanAttributeInfo attribute : attributes) {
if (attribute.getName().equals(attributeName)) {
monitoredAttribute = attribute;
break;
}
}
if (monitoredAttribute == null) {
throw new UnsupportedOperationException("MBean [" + mBeanName +
"] has no attribute named [" + attributeName + "]");
}
return monitoredAttribute.getType();
}
示例8: testEndpointMBeanExporterWithProperties
import javax.management.IntrospectionException; //导入依赖的package包/类
@Test
public void testEndpointMBeanExporterWithProperties() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
MockEnvironment environment = new MockEnvironment();
environment.setProperty("endpoints.jmx.domain", "test-domain");
environment.setProperty("endpoints.jmx.unique_names", "true");
environment.setProperty("endpoints.jmx.static_names", "key1=value1, key2=value2");
this.context = new AnnotationConfigApplicationContext();
this.context.setEnvironment(environment);
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.refresh();
this.context.getBean(EndpointMBeanExporter.class);
MBeanExporter mbeanExporter = this.context.getBean(EndpointMBeanExporter.class);
assertNotNull(mbeanExporter.getServer()
.getMBeanInfo(ObjectNameManager.getInstance(
getObjectName("test-domain", "healthEndpoint", this.context)
.toString() + ",key1=value1,key2=value2")));
}
示例9: testEndpointMBeanExporterInParentChild
import javax.management.IntrospectionException; //导入依赖的package包/类
@Test
public void testEndpointMBeanExporterInParentChild() throws IntrospectionException,
InstanceNotFoundException, MalformedObjectNameException, ReflectionException {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
AnnotationConfigApplicationContext parent = new AnnotationConfigApplicationContext();
parent.register(JmxAutoConfiguration.class, EndpointAutoConfiguration.class,
EndpointMBeanExportAutoConfiguration.class);
this.context.setParent(parent);
parent.refresh();
this.context.refresh();
parent.close();
}
示例10: getNodeMBeanInfo
import javax.management.IntrospectionException; //导入依赖的package包/类
/**
* Retrieves attributes of the specified mbean.
*
* @param sessionId current session
* @param nodeJmxUrl mbean server url
* @param objectName name of mbean
* @param attrs set of mbean attributes
*
* @return mbean attributes values
*/
@Override
@GET
@GZIP
@Produces("application/json")
@Path("node/mbean")
public Object getNodeMBeanInfo(@HeaderParam("sessionid") String sessionId,
@QueryParam("nodejmxurl") String nodeJmxUrl, @QueryParam("objectname") String objectName,
@QueryParam("attrs") List<String> attrs)
throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException,
NotConnectedException, MalformedObjectNameException, NullPointerException {
// checking that still connected to the RM
RMProxyUserInterface rmProxy = checkAccess(sessionId);
return rmProxy.getNodeMBeanInfo(nodeJmxUrl, objectName, attrs);
}
示例11: getNodeMBeansInfo
import javax.management.IntrospectionException; //导入依赖的package包/类
/**
* Retrieves attributes of the specified mbeans.
*
* @param sessionId current session
* @param objectNames mbean names (@see ObjectName format)
* @param nodeJmxUrl mbean server url
* @param attrs set of mbean attributes
*
* @return mbean attributes values
*/
@Override
@GET
@GZIP
@Produces("application/json")
@Path("node/mbeans")
public Object getNodeMBeansInfo(@HeaderParam("sessionid") String sessionId,
@QueryParam("nodejmxurl") String nodeJmxUrl, @QueryParam("objectname") String objectNames,
@QueryParam("attrs") List<String> attrs)
throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException,
NotConnectedException, MalformedObjectNameException, NullPointerException {
// checking that still connected to the RM
RMProxyUserInterface rmProxy = checkAccess(sessionId);
return rmProxy.getNodeMBeansInfo(nodeJmxUrl, objectNames, attrs);
}
示例12: getMBeanInfo
import javax.management.IntrospectionException; //导入依赖的package包/类
/**
* Returns the attributes <code>attr</code> of the mbean
* registered as <code>name</code>.
* @param sessionId a valid session
* @param name mbean's object name
* @param attrs attributes to enumerate
* @return returns the attributes of the mbean
* @throws InstanceNotFoundException
* @throws IntrospectionException
* @throws ReflectionException
* @throws IOException
* @throws NotConnectedException
*/
@Override
@GET
@GZIP
@Path("info/{name}")
@Produces("application/json")
public Object getMBeanInfo(@HeaderParam("sessionid") String sessionId, @PathParam("name") ObjectName name,
@QueryParam("attr") List<String> attrs) throws InstanceNotFoundException, IntrospectionException,
ReflectionException, IOException, NotConnectedException {
RMProxyUserInterface rm = checkAccess(sessionId);
if ((attrs == null) || (attrs.size() == 0)) {
// no attribute is requested, we return
// the description of the mbean
return rm.getMBeanInfo(name);
} else {
return rm.getMBeanAttributes(name, attrs.toArray(new String[attrs.size()]));
}
}
示例13: getMBeanInfo
import javax.management.IntrospectionException; //导入依赖的package包/类
/**
* @see javax.management.MBeanServerConnection#getMBeanInfo(javax.management.ObjectName)
*/
public MBeanInfo getMBeanInfo(final ObjectName name)
throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException {
if (this.subject == null) {
return this.mbs.getMBeanInfo(name);
}
try {
return (MBeanInfo) Subject.doAsPrivileged(this.subject, new PrivilegedExceptionAction<MBeanInfo>() {
public final MBeanInfo run() throws Exception {
return mbs.getMBeanInfo(name);
}
}, this.context);
} catch (final PrivilegedActionException pe) {
final Exception e = JMXProviderUtils.extractException(pe);
if (e instanceof InstanceNotFoundException)
throw (InstanceNotFoundException) e;
if (e instanceof IntrospectionException)
throw (IntrospectionException) e;
if (e instanceof ReflectionException)
throw (ReflectionException) e;
if (e instanceof IOException)
throw (IOException) e;
throw JMXProviderUtils.newIOException("Got unexpected server exception: " + e, e);
}
}
示例14: copyAllAttributes
import javax.management.IntrospectionException; //导入依赖的package包/类
public static void copyAllAttributes(ObjectName on, JsonObject targetObject) {
try {
MBeanInfo mbi = mbs.getMBeanInfo(on);
for (MBeanAttributeInfo mbai : mbi.getAttributes()) {
Object attValue = mbs.getAttribute(on, mbai.getName());
if (attValue instanceof Boolean) {
targetObject.addProperty(mbai.getName(), (Boolean) attValue);
} else if (attValue instanceof Character) {
targetObject.addProperty(mbai.getName(), (Character) attValue);
} else if (attValue instanceof Number) {
targetObject.addProperty(mbai.getName(), (Number) attValue);
} else if (attValue instanceof String) {
targetObject.addProperty(mbai.getName(), (String) attValue);
} else {
targetObject.addProperty("OBJECT:" + mbai.getName(), attValue != null ? attValue.toString() : "null");
}
}
} catch (InstanceNotFoundException | IntrospectionException | ReflectionException | AttributeNotFoundException
| MBeanException e) {
log.error("Failed to query mbean", e);
}
}
示例15: setYarnAndNonYarnDaemons
import javax.management.IntrospectionException; //导入依赖的package包/类
private void setYarnAndNonYarnDaemons(String host, YarnSlaveParam slave,
ProfilerJMXDump dump,
WorkerJMXInfo levelJMXInfo) throws IOException,
AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException,
IntrospectionException {
levelJMXInfo.setDataNode(dump.getAllJMXAttribute(JMXDeamons.DATA_NODE, host,
slave.getDataNodeJmxPort()));
if(isYarnEnable){
YarnWorkerJMXInfo ywji = (YarnWorkerJMXInfo) levelJMXInfo;
ywji.setNodeManager(dump.getAllJMXAttribute(JMXDeamons.NODE_MANAGER,
host, slave.getNodeManagerJmxPort()));
}else{
levelJMXInfo.setTaskTracker(dump.getAllJMXAttribute(JMXDeamons.TASK_TRACKER, host,
slave.getTaskTrackerJmxPort()));
}
}