List of usage examples for javax.management RuntimeMBeanException getCause
public Throwable getCause()
From source file:com.streamsets.datacollector.http.JMXJsonServlet.java
private void writeAttribute(JsonGenerator jg, ObjectName oname, MBeanAttributeInfo attr) throws IOException { if (!attr.isReadable()) { return;//w ww. ja va 2s .c om } String attName = attr.getName(); if ("modelerType".equals(attName)) { return; } if (attName.indexOf("=") >= 0 || attName.indexOf(":") >= 0 || attName.indexOf(" ") >= 0) { return; } Object value = null; try { value = mBeanServer.getAttribute(oname, attName); } catch (RuntimeMBeanException e) { // UnsupportedOperationExceptions happen in the normal course of business, // so no need to if (e.getCause() instanceof UnsupportedOperationException) { } else { } return; } catch (RuntimeErrorException e) { // RuntimeErrorException happens when an unexpected failure occurs in getAttribute // for example https://issues.apache.org/jira/browse/DAEMON-120 return; } catch (AttributeNotFoundException e) { //Ignored the attribute was not found, which should never happen because the bean //just told us that it has this attribute, but if this happens just don't output //the attribute. return; } catch (MBeanException e) { //The code inside the attribute getter threw an exception so // skip outputting the attribute return; } catch (RuntimeException e) { //For some reason even with an MBeanException available to them Runtime exceptions //can still find their way through, so treat them the same as MBeanException return; } catch (ReflectionException e) { //This happens when the code inside the JMX bean (setter?? from the java docs) //threw an exception, so return; } catch (InstanceNotFoundException e) { //Ignored the mbean itself was not found, which should never happen because we //just accessed it (perhaps something unregistered in-between) but if this //happens just don't output the attribute. return; } writeAttribute(jg, attName, value); }
From source file:org.apache.hadoop.hbase.util.JSONBean.java
/** * @param mBeanServer//from w ww . j a v a 2s . c o m * @param qry * @param attribute * @param description * @return Return non-zero if failed to find bean. 0 * @throws IOException */ private static int write(final JsonGenerator jg, final MBeanServer mBeanServer, ObjectName qry, String attribute, final boolean description) throws IOException { LOG.trace("Listing beans for " + qry); Set<ObjectName> names = null; names = mBeanServer.queryNames(qry, null); jg.writeArrayFieldStart("beans"); Iterator<ObjectName> it = names.iterator(); while (it.hasNext()) { ObjectName oname = it.next(); MBeanInfo minfo; String code = ""; String descriptionStr = null; Object attributeinfo = null; try { minfo = mBeanServer.getMBeanInfo(oname); code = minfo.getClassName(); if (description) descriptionStr = minfo.getDescription(); String prs = ""; try { if ("org.apache.commons.modeler.BaseModelMBean".equals(code)) { prs = "modelerType"; code = (String) mBeanServer.getAttribute(oname, prs); } if (attribute != null) { prs = attribute; attributeinfo = mBeanServer.getAttribute(oname, prs); } } catch (RuntimeMBeanException e) { // UnsupportedOperationExceptions happen in the normal course of business, // so no need to log them as errors all the time. if (e.getCause() instanceof UnsupportedOperationException) { if (LOG.isTraceEnabled()) { LOG.trace("Getting attribute " + prs + " of " + oname + " threw " + e); } } else { LOG.error("Getting attribute " + prs + " of " + oname + " threw an exception", e); } return 0; } catch (AttributeNotFoundException e) { // If the modelerType attribute was not found, the class name is used // instead. LOG.error("getting attribute " + prs + " of " + oname + " threw an exception", e); } catch (MBeanException e) { // The code inside the attribute getter threw an exception so log it, // and fall back on the class name LOG.error("getting attribute " + prs + " of " + oname + " threw an exception", e); } catch (RuntimeException e) { // For some reason even with an MBeanException available to them // Runtime exceptionscan still find their way through, so treat them // the same as MBeanException LOG.error("getting attribute " + prs + " of " + oname + " threw an exception", e); } catch (ReflectionException e) { // This happens when the code inside the JMX bean (setter?? from the // java docs) threw an exception, so log it and fall back on the // class name LOG.error("getting attribute " + prs + " of " + oname + " threw an exception", e); } } catch (InstanceNotFoundException e) { //Ignored for some reason the bean was not found so don't output it continue; } catch (IntrospectionException e) { // This is an internal error, something odd happened with reflection so // log it and don't output the bean. LOG.error("Problem while trying to process JMX query: " + qry + " with MBean " + oname, e); continue; } catch (ReflectionException e) { // This happens when the code inside the JMX bean threw an exception, so // log it and don't output the bean. LOG.error("Problem while trying to process JMX query: " + qry + " with MBean " + oname, e); continue; } jg.writeStartObject(); jg.writeStringField("name", oname.toString()); if (description && descriptionStr != null && descriptionStr.length() > 0) { jg.writeStringField("description", descriptionStr); } jg.writeStringField("modelerType", code); if (attribute != null && attributeinfo == null) { jg.writeStringField("result", "ERROR"); jg.writeStringField("message", "No attribute with name " + attribute + " was found."); jg.writeEndObject(); jg.writeEndArray(); jg.close(); return -1; } if (attribute != null) { writeAttribute(jg, attribute, descriptionStr, attributeinfo); } else { MBeanAttributeInfo[] attrs = minfo.getAttributes(); for (int i = 0; i < attrs.length; i++) { writeAttribute(jg, mBeanServer, oname, description, attrs[i]); } } jg.writeEndObject(); } jg.writeEndArray(); return 0; }
From source file:org.apache.hadoop.hbase.util.JSONBean.java
private static void writeAttribute(final JsonGenerator jg, final MBeanServer mBeanServer, ObjectName oname, final boolean description, final MBeanAttributeInfo attr) throws IOException { if (!attr.isReadable()) { return;//from w w w .java 2s . co m } String attName = attr.getName(); if ("modelerType".equals(attName)) { return; } if (attName.indexOf("=") >= 0 || attName.indexOf(":") >= 0 || attName.indexOf(" ") >= 0) { return; } String descriptionStr = description ? attr.getDescription() : null; Object value = null; try { value = mBeanServer.getAttribute(oname, attName); } catch (RuntimeMBeanException e) { // UnsupportedOperationExceptions happen in the normal course of business, // so no need to log them as errors all the time. if (e.getCause() instanceof UnsupportedOperationException) { if (LOG.isTraceEnabled()) { LOG.trace("Getting attribute " + attName + " of " + oname + " threw " + e); } } else { LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); } return; } catch (RuntimeErrorException e) { // RuntimeErrorException happens when an unexpected failure occurs in getAttribute // for example https://issues.apache.org/jira/browse/DAEMON-120 LOG.debug("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (AttributeNotFoundException e) { //Ignored the attribute was not found, which should never happen because the bean //just told us that it has this attribute, but if this happens just don't output //the attribute. return; } catch (MBeanException e) { //The code inside the attribute getter threw an exception so log it, and // skip outputting the attribute LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (RuntimeException e) { //For some reason even with an MBeanException available to them Runtime exceptions //can still find their way through, so treat them the same as MBeanException LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (ReflectionException e) { //This happens when the code inside the JMX bean (setter?? from the java docs) //threw an exception, so log it and skip outputting the attribute LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (InstanceNotFoundException e) { //Ignored the mbean itself was not found, which should never happen because we //just accessed it (perhaps something unregistered in-between) but if this //happens just don't output the attribute. return; } writeAttribute(jg, attName, descriptionStr, value); }
From source file:org.apache.hadoop.jmx.JMXJsonServlet.java
private void writeAttribute(JsonGenerator jg, ObjectName oname, MBeanAttributeInfo attr) throws IOException { if (!attr.isReadable()) { return;/*from w w w . jav a2 s . co m*/ } String attName = attr.getName(); if ("modelerType".equals(attName)) { return; } if (attName.indexOf("=") >= 0 || attName.indexOf(":") >= 0 || attName.indexOf(" ") >= 0) { return; } Object value = null; try { value = mBeanServer.getAttribute(oname, attName); } catch (RuntimeMBeanException e) { // UnsupportedOperationExceptions happen in the normal course of business, // so no need to log them as errors all the time. if (e.getCause() instanceof UnsupportedOperationException) { LOG.debug("getting attribute " + attName + " of " + oname + " threw an exception", e); } else { LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); } return; } catch (AttributeNotFoundException e) { //Ignored the attribute was not found, which should never happen because the bean //just told us that it has this attribute, but if this happens just don't output //the attribute. return; } catch (MBeanException e) { //The code inside the attribute getter threw an exception so log it, and // skip outputting the attribute LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (RuntimeException e) { //For some reason even with an MBeanException available to them Runtime exceptions //can still find their way through, so treat them the same as MBeanException LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (ReflectionException e) { //This happens when the code inside the JMX bean (setter?? from the java docs) //threw an exception, so log it and skip outputting the attribute LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (InstanceNotFoundException e) { //Ignored the mbean itself was not found, which should never happen because we //just accessed it (perhaps something unregistered in-between) but if this //happens just don't output the attribute. return; } writeAttribute(jg, attName, value); }
From source file:org.apache.hive.http.JMXJsonServlet.java
private void writeAttribute(JsonGenerator jg, ObjectName oname, MBeanAttributeInfo attr) throws IOException { if (!attr.isReadable()) { return;//from www . j a v a2s . co m } String attName = attr.getName(); if ("modelerType".equals(attName)) { return; } if (attName.indexOf("=") >= 0 || attName.indexOf(":") >= 0 || attName.indexOf(" ") >= 0) { return; } Object value = null; try { value = mBeanServer.getAttribute(oname, attName); } catch (RuntimeMBeanException e) { // UnsupportedOperationExceptions happen in the normal course of business, // so no need to log them as errors all the time. if (e.getCause() instanceof UnsupportedOperationException) { LOG.debug("getting attribute " + attName + " of " + oname + " threw an exception", e); } else { LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); } return; } catch (RuntimeErrorException e) { // RuntimeErrorException happens when an unexpected failure occurs in getAttribute // for example https://issues.apache.org/jira/browse/DAEMON-120 LOG.debug("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (AttributeNotFoundException e) { //Ignored the attribute was not found, which should never happen because the bean //just told us that it has this attribute, but if this happens just don't output //the attribute. return; } catch (MBeanException e) { //The code inside the attribute getter threw an exception so log it, and // skip outputting the attribute LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (RuntimeException e) { //For some reason even with an MBeanException available to them Runtime exceptions //can still find their way through, so treat them the same as MBeanException LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (ReflectionException e) { //This happens when the code inside the JMX bean (setter?? from the java docs) //threw an exception, so log it and skip outputting the attribute LOG.error("getting attribute " + attName + " of " + oname + " threw an exception", e); return; } catch (InstanceNotFoundException e) { //Ignored the mbean itself was not found, which should never happen because we //just accessed it (perhaps something unregistered in-between) but if this //happens just don't output the attribute. return; } writeAttribute(jg, attName, value); }