List of usage examples for javax.management MBeanInfo getNotifications
public MBeanNotificationInfo[] getNotifications()
From source file:org.jolokia.handler.list.NotificationDataUpdater.java
/** {@inheritDoc} */ @Override// w ww . j a v a 2s. c om protected JSONObject extractData(MBeanInfo pMBeanInfo, String pNotification) { JSONObject notMap = new JSONObject(); for (MBeanNotificationInfo notInfo : pMBeanInfo.getNotifications()) { if (pNotification == null || notInfo.getName().equals(pNotification)) { JSONObject map = new JSONObject(); map.put(NAME.getKey(), notInfo.getName()); map.put(DESCRIPTION.getKey(), notInfo.getDescription()); String[] types = notInfo.getNotifTypes(); JSONArray tList = new JSONArray(); for (String type : types) { tList.add(type); } map.put(TYPES.getKey(), tList); } } return notMap; }
From source file:flens.query.JMXQuery.java
private Map<String, Object> getNotifications(MBeanInfo info) { Map<String, Object> outc = new HashMap<>(); MBeanNotificationInfo[] atts = info.getNotifications(); for (MBeanNotificationInfo att : atts) { Map<String, Object> out = new HashMap<>(); outc.put(att.getName(), out);// w w w. j ava2 s .co m out.put("description", att.getDescription()); out.put("type", att.getNotifTypes()); } return outc; }
From source file:Utilities.java
/** * Prints info about a bean to a {@link VarOutputSink}. * //from w ww . j a v a 2 s . co m * @param sink The {@link VarOutputSink} to which info will be sent * @param mbs The {@link MBeanServer} with respect to which the * {@code objectName} is accessed * @param objectName The {@link ObjectName} that identifies this bean */ public static void printMBeanInfo(VarOutputSink sink, MBeanServer mbs, ObjectName objectName) { MBeanInfo info = getMBeanInfoSafely(sink, mbs, objectName); if (info == null) { return; } sink.echo("\nCLASSNAME: \t" + info.getClassName()); sink.echo("\nDESCRIPTION: \t" + info.getDescription()); sink.echo("\nATTRIBUTES"); MBeanAttributeInfo[] attrInfo = info.getAttributes(); sink.printVariable("attrcount", Integer.toString(attrInfo.length)); if (attrInfo.length > 0) { for (int i = 0; i < attrInfo.length; i++) { sink.echo(" ** NAME: \t" + attrInfo[i].getName()); sink.echo(" DESCR: \t" + attrInfo[i].getDescription()); sink.echo(" TYPE: \t" + attrInfo[i].getType() + "\tREAD: " + attrInfo[i].isReadable() + "\tWRITE: " + attrInfo[i].isWritable()); } } else sink.echo(" ** No attributes **"); sink.echo("\nCONSTRUCTORS"); MBeanConstructorInfo[] constrInfo = info.getConstructors(); for (int i = 0; i < constrInfo.length; i++) { sink.echo(" ** NAME: \t" + constrInfo[i].getName()); sink.echo(" DESCR: \t" + constrInfo[i].getDescription()); sink.echo(" PARAM: \t" + constrInfo[i].getSignature().length + " parameter(s)"); } sink.echo("\nOPERATIONS"); MBeanOperationInfo[] opInfo = info.getOperations(); if (opInfo.length > 0) { for (int i = 0; i < opInfo.length; i++) { sink.echo(" ** NAME: \t" + opInfo[i].getName()); sink.echo(" DESCR: \t" + opInfo[i].getDescription()); sink.echo(" PARAM: \t" + opInfo[i].getSignature().length + " parameter(s)"); } } else sink.echo(" ** No operations ** "); sink.echo("\nNOTIFICATIONS"); MBeanNotificationInfo[] notifInfo = info.getNotifications(); if (notifInfo.length > 0) { for (int i = 0; i < notifInfo.length; i++) { sink.echo(" ** NAME: \t" + notifInfo[i].getName()); sink.echo(" DESCR: \t" + notifInfo[i].getDescription()); String notifTypes[] = notifInfo[i].getNotifTypes(); for (int j = 0; j < notifTypes.length; j++) { sink.echo(" TYPE: \t" + notifTypes[j]); } } } else sink.echo(" ** No notifications **"); }
From source file:org.apache.hadoop.hbase.metrics.MetricsMBeanBase.java
protected void init() { List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(); MBeanInfo parentInfo = super.getMBeanInfo(); List<String> parentAttributes = new ArrayList<String>(); for (MBeanAttributeInfo attr : parentInfo.getAttributes()) { attributes.add(attr);/*ww w . ja v a 2s . c o m*/ parentAttributes.add(attr.getName()); } this.registryLength = this.registry.getMetricsList().size(); for (MetricsBase metric : this.registry.getMetricsList()) { if (metric.getName() == null || parentAttributes.contains(metric.getName())) continue; // add on custom HBase metric types if (metric instanceof MetricsRate) { attributes.add(new MBeanAttributeInfo(metric.getName(), "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metric.getName(), metric); } else if (metric instanceof MetricsString) { attributes.add(new MBeanAttributeInfo(metric.getName(), "java.lang.String", metric.getDescription(), true, false, false)); extendedAttributes.put(metric.getName(), metric); LOG.info("MetricsString added: " + metric.getName()); } else if (metric instanceof MetricsHistogram) { String metricName = metric.getName() + MetricsHistogram.NUM_OPS_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MIN_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MAX_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Long", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MEAN_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.STD_DEV_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.MEDIAN_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.SEVENTY_FIFTH_PERCENTILE_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.NINETY_FIFTH_PERCENTILE_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); metricName = metric.getName() + MetricsHistogram.NINETY_NINETH_PERCENTILE_METRIC_NAME; attributes.add(new MBeanAttributeInfo(metricName, "java.lang.Float", metric.getDescription(), true, false, false)); extendedAttributes.put(metricName, metric); } // else, its probably a hadoop metric already registered. Skip it. } LOG.info("new MBeanInfo"); this.extendedInfo = new MBeanInfo(this.getClass().getName(), this.description, attributes.toArray(new MBeanAttributeInfo[0]), parentInfo.getConstructors(), parentInfo.getOperations(), parentInfo.getNotifications()); }