Example usage for javax.management MBeanAttributeInfo MBeanAttributeInfo

List of usage examples for javax.management MBeanAttributeInfo MBeanAttributeInfo

Introduction

In this page you can find the example usage for javax.management MBeanAttributeInfo MBeanAttributeInfo.

Prototype

public MBeanAttributeInfo(String name, String type, String description, boolean isReadable, boolean isWritable,
        boolean isIs) 

Source Link

Document

Constructs an MBeanAttributeInfo object.

Usage

From source file:org.cleverbus.core.throttling.JmxThrottlingConfiguration.java

@Override
public MBeanInfo getMBeanInfo() {
    Map<ThrottleScope, ThrottleProps> props = configuration.getProperties();

    List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(props.size());

    // add all throttling properties
    for (Map.Entry<ThrottleScope, ThrottleProps> propsEntry : props.entrySet()) {
        String key = propsEntry.getKey().toHumanString();

        attributes.add(new MBeanAttributeInfo(key, "java.lang.String", key, true, true, false));
    }// w w  w.  j a  v a2s . c  om

    MBeanInfo mBeanInfo = new MBeanInfo(this.getClass().getName(), "Throttling Configuration",
            attributes.toArray(new MBeanAttributeInfo[] {}), null, null, null);

    return mBeanInfo;
}

From source file:org.cleverbus.core.alerts.AlertsJmxConfiguration.java

@Override
public MBeanInfo getMBeanInfo() {
    List<AlertInfo> alerts = configuration.getAlerts(false);

    List<MBeanAttributeInfo> attributes = new ArrayList<MBeanAttributeInfo>(alerts.size());

    // add all alert properties
    for (AlertInfo alert : alerts) {
        String keyLimit = alert.getId() + LIMIT_SUFFIX;
        String keyEnable = alert.getId() + ENABLE_SUFFIX;

        attributes.add(new MBeanAttributeInfo(keyEnable, "java.lang.String", "Enable/disable alert", true, true,
                false));/*w  w  w.  j a  va  2 s  .co  m*/
        attributes.add(
                new MBeanAttributeInfo(keyLimit, "java.lang.String", "Set alert limit", true, true, false));
    }

    MBeanInfo mBeanInfo = new MBeanInfo(this.getClass().getName(), "Alerts Configuration",
            attributes.toArray(new MBeanAttributeInfo[] {}), null, null, null);

    return mBeanInfo;
}

From source file:com.wakacommerce.common.cache.StatisticsServiceImpl.java

@Override
public MBeanInfo getMBeanInfo() {
    SortedSet<String> names = new TreeSet<String>();
    for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) {
        names.add(stats.getKey());/*from ww  w  . ja  va2  s. c o m*/
    }
    MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[names.size()];
    Iterator<String> it = names.iterator();
    for (int i = 0; i < attrs.length; i++) {
        String name = it.next();
        attrs[i] = new MBeanAttributeInfo(name, "java.lang.Double", name, true, // isReadable
                false, // isWritable
                false); // isIs
    }
    attrs = ArrayUtils.add(attrs,
            new MBeanAttributeInfo("LOG_RESOLUTION", "java.lang.Double", "LOG_RESOLUTION", true, // isReadable
                    true, // isWritable
                    false) // isIs
    );
    MBeanOperationInfo[] opers = { new MBeanOperationInfo("activate", "Activate statistic logging", null, // no parameters
            "void", MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("disable", "Disable statistic logging", null, // no parameters
                    "void", MBeanOperationInfo.ACTION) };
    return new MBeanInfo("com.wakacommerce:name=StatisticsService." + appName, "Runtime Statistics", attrs,
            null, // constructors
            opers, null); // 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);/*from w  ww  .  j a  va 2s  .co  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());
}

From source file:org.broadleafcommerce.common.cache.StatisticsServiceImpl.java

@Override
public MBeanInfo getMBeanInfo() {
    SortedSet<String> names = new TreeSet<String>();
    for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) {
        names.add(stats.getKey());/*  w  w w  .ja va  2s .com*/
    }
    MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[names.size()];
    Iterator<String> it = names.iterator();
    for (int i = 0; i < attrs.length; i++) {
        String name = it.next();
        attrs[i] = new MBeanAttributeInfo(name, "java.lang.Double", name, true, // isReadable
                false, // isWritable
                false); // isIs
    }
    attrs = ArrayUtils.add(attrs,
            new MBeanAttributeInfo("LOG_RESOLUTION", "java.lang.Double", "LOG_RESOLUTION", true, // isReadable
                    true, // isWritable
                    false) // isIs
    );
    MBeanOperationInfo[] opers = { new MBeanOperationInfo("activate", "Activate statistic logging", null, // no parameters
            "void", MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("disable", "Disable statistic logging", null, // no parameters
                    "void", MBeanOperationInfo.ACTION) };
    return new MBeanInfo("org.broadleafcommerce:name=StatisticsService." + appName, "Runtime Statistics", attrs,
            null, // constructors
            opers, null); // notifications
}

From source file:org.echocat.jemoni.jmx.support.CacheDynamicMBean.java

@Nonnull
protected MBeanAttributeInfo[] getAttributes() {
    final List<MBeanAttributeInfo> result = new ArrayList<>();
    result.add(new MBeanAttributeInfo("type", String.class.getName(), null, true, false, false));
    result.add(new MBeanAttributeInfo("keyType", String.class.getName(), null, true, false, false));
    result.add(new MBeanAttributeInfo("valueType", String.class.getName(), null, true, false, false));
    if (_cache instanceof StatisticsEnabledCache) {
        result.add(new MBeanAttributeInfo("size", Long.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("hitRatio", Double.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("dropRatio", Double.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("numberOfRequests", Long.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("numberOfHits", Long.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("numberOfDrops", Long.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("numberOfMisses", Long.class.getName(), null, true, false, false));
        result.add(new MBeanAttributeInfo("created", Date.class.getName(), null, true, false, false));
    }/*from   w  ww.j a  v a  2 s  .  c  o m*/
    if (_cache instanceof LimitedCache) {
        result.add(new MBeanAttributeInfo("maximumLifetime", String.class.getName(), null, true, true, false));
        result.add(new MBeanAttributeInfo("capacity", Long.class.getName(), null, true, true, false));
    }
    if (_cache instanceof ListenerEnabledCache) {
        result.add(new MBeanAttributeInfo("listeners", String.class.getName(), null, true, false, false));
    }
    if (_cache instanceof ProducingTypeEnabledCache) {
        result.add(new MBeanAttributeInfo("producingType", String.class.getName(), null, true, true, false));
    }
    return result.toArray(new MBeanAttributeInfo[result.size()]);
}