Search in sources :

Example 11 with AttributeList

use of javax.management.AttributeList in project cloudstack by apache.

the class PropertyMapDynamicBean method setAttributes.

@Override
public synchronized AttributeList setAttributes(AttributeList list) {
    Attribute[] attrs = list.toArray(new Attribute[0]);
    AttributeList retList = new AttributeList();
    for (Attribute attr : attrs) {
        String name = attr.getName();
        Object value = attr.getValue();
        _propMap.put(name, value);
        retList.add(new Attribute(name, value));
    }
    return retList;
}
Also used : Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList)

Example 12 with AttributeList

use of javax.management.AttributeList in project deltaspike by apache.

the class DynamicMBeanWrapper method setAttributes.

@Override
public AttributeList setAttributes(final AttributeList attributes) {
    final AttributeList list = new AttributeList();
    for (Object o : attributes) {
        final Attribute attr = (Attribute) o;
        try {
            setAttribute(attr);
            list.add(attr);
        } catch (Exception ignore) {
        // no-op
        }
    }
    return list;
}
Also used : Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) ReflectionException(javax.management.ReflectionException) InvocationTargetException(java.lang.reflect.InvocationTargetException) OpenDataException(javax.management.openmbean.OpenDataException) AttributeNotFoundException(javax.management.AttributeNotFoundException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException)

Example 13 with AttributeList

use of javax.management.AttributeList in project geode by apache.

the class MBeanServerWrapper method getAttributes.

@Override
public AttributeList getAttributes(ObjectName name, String[] attributes) throws InstanceNotFoundException, ReflectionException {
    AttributeList results = new AttributeList();
    for (String attribute : attributes) {
        try {
            Object value = getAttribute(name, attribute);
            Attribute att = new Attribute(attribute, value);
            results.add(att);
        } catch (Exception e) {
            throw new GemFireSecurityException("error getting value of " + attribute + " from " + name, e);
        }
    }
    return results;
}
Also used : GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList) AttributeNotFoundException(javax.management.AttributeNotFoundException) IntrospectionException(javax.management.IntrospectionException) OperationsException(javax.management.OperationsException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) MBeanRegistrationException(javax.management.MBeanRegistrationException) GemFireSecurityException(org.apache.geode.security.GemFireSecurityException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ReflectionException(javax.management.ReflectionException) NotCompliantMBeanException(javax.management.NotCompliantMBeanException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) MBeanException(javax.management.MBeanException) ListenerNotFoundException(javax.management.ListenerNotFoundException)

Example 14 with AttributeList

use of javax.management.AttributeList in project geode by apache.

the class JMXDataUpdater method initializeMember.

/**
   * function used to iterate through all member attributes and return the updated member
   */
private Cluster.Member initializeMember(ObjectName mbeanName, Cluster.Member member) throws InstanceNotFoundException, ReflectionException, IOException {
    AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.MEMBER_MBEAN_ATTRIBUTES);
    for (int i = 0; i < attributeList.size(); i++) {
        Attribute attribute = (Attribute) attributeList.get(i);
        String name = attribute.getName();
        switch(name) {
            case PulseConstants.MBEAN_ATTRIBUTE_GEMFIREVERSION:
                if (member.getGemfireVersion() == null) {
                    // Set Member's GemFire Version if not set already
                    String gemfireVersion = obtainGemfireVersion(getStringAttribute(attribute.getValue(), attribute.getName()));
                    member.setGemfireVersion(gemfireVersion);
                }
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_MANAGER:
                member.setManager(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_TOTALREGIONCOUNT:
                member.setTotalRegionCount(getIntegerAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_LOCATOR:
                member.setLocator(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_TOTALDISKUSAGE:
                member.setTotalDiskUsage(getLongAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_SERVER:
                member.setServer(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_TOTALFILEDESCRIPTOROPEN:
                member.setTotalFileDescriptorOpen(getLongAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_LOADAVERAGE:
                member.setLoadAverage(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_DISKWRITESRATE:
                member.setThroughputWrites(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                member.getThroughputWritesTrend().add(member.getThroughputWrites());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_DISKREADSRATE:
                member.setThroughputReads(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                member.getThroughputReadsTrend().add(member.getThroughputReads());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_JVMPAUSES:
                long trendVal = determineCurrentJVMPauses(PulseConstants.JVM_PAUSES_TYPE_MEMBER, member.getName(), getLongAttribute(attribute.getValue(), attribute.getName()));
                member.setGarbageCollectionCount(trendVal);
                member.getGarbageCollectionSamples().add(member.getGarbageCollectionCount());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_USEDMEMORY:
                member.setCurrentHeapSize(getLongAttribute(attribute.getValue(), attribute.getName()));
                member.getHeapUsageSamples().add(member.getCurrentHeapSize());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_MAXMEMORY:
                member.setMaxHeapSize(getLongAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_NUMTHREADS:
                member.setNumThreads(getIntegerAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_MEMBERUPTIME:
                member.setUptime(getLongAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_HOST:
                member.setHost(getStringAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_HOSTNAMEFORCLIENTS:
                member.setHostnameForClients(getStringAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_BINDADDRESS:
                member.setBindAddress(getStringAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_TOTALBYTESONDISK:
                member.setTotalBytesOnDisk(getLongAttribute(attribute.getValue(), attribute.getName()));
                member.getTotalBytesOnDiskSamples().add(member.getTotalBytesOnDisk());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_CPUUSAGE:
                member.setCpuUsage(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                member.getCpuUsageSamples().add(member.getCpuUsage());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_HOSTCPUUSAGE:
                // Float value is expected for host cpu usage.
                // TODO Remove Float.valueOf() when float value is provided in mbean
                member.setHostCpuUsage(Double.valueOf(getIntegerAttribute(attribute.getValue(), attribute.getName())));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_MEMBER:
                member.setName(getStringAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_ID:
                member.setId(getStringAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEREADS:
                member.setGetsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                member.getGetsPerSecond().add(member.getGetsRate());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_AVERAGEWRITES:
                member.setPutsRate(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                member.getPutsPerSecond().add(member.getPutsRate());
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPFREESIZE:
                member.setOffHeapFreeSize(getLongAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_OFFHEAPUSEDSIZE:
                member.setOffHeapUsedSize(getLongAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_SERVERGROUPS:
                String[] sgValues = (String[]) attribute.getValue();
                member.getServerGroups().clear();
                for (int k = 0; k < sgValues.length; k++) {
                    member.getServerGroups().add(sgValues[k]);
                }
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_REDUNDANCYZONES:
                String rzValue = "";
                if (null != attribute.getValue()) {
                    rzValue = getStringAttribute(attribute.getValue(), attribute.getName());
                }
                member.getRedundancyZones().clear();
                if (!rzValue.isEmpty()) {
                    member.getRedundancyZones().add(rzValue);
                }
                break;
        }
    }
    return member;
}
Also used : Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList)

Example 15 with AttributeList

use of javax.management.AttributeList in project geode by apache.

the class JMXDataUpdater method initGatewaySender.

/**
   * function used to get attribute values of Gateway Sender and map them to GatewaySender inner
   * class object
   */
private Cluster.GatewaySender initGatewaySender(ObjectName mbeanName) throws InstanceNotFoundException, IntrospectionException, ReflectionException, IOException, AttributeNotFoundException, MBeanException {
    Cluster.GatewaySender gatewaySender = new Cluster.GatewaySender();
    AttributeList attributeList = this.mbs.getAttributes(mbeanName, PulseConstants.GATEWAYSENDER_MBEAN_ATTRIBUTES);
    for (int i = 0; i < attributeList.size(); i++) {
        Attribute attribute = (Attribute) attributeList.get(i);
        String name = attribute.getName();
        switch(name) {
            case PulseConstants.MBEAN_ATTRIBUTE_EVENTRECEIVEDDATE:
                gatewaySender.setLinkThroughput(getDoubleAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_BATCHSIZE:
                gatewaySender.setBatchSize(getIntegerAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_SENDERID:
                gatewaySender.setId(getStringAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_EVENTQUEUESIZE:
                gatewaySender.setQueueSize(getIntegerAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_RUNNING:
                gatewaySender.setStatus(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_PRIMARY:
                gatewaySender.setPrimary(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_PERSISTENCEENABLED:
                gatewaySender.setPersistenceEnabled(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_PARALLEL:
                gatewaySender.setSenderType(getBooleanAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_REMOTE_DS_ID:
                gatewaySender.setRemoteDSId(getIntegerAttribute(attribute.getValue(), attribute.getName()));
                break;
            case PulseConstants.MBEAN_ATTRIBUTE_EVENTS_EXCEEDING_ALERT_THRESHOLD:
                gatewaySender.setEventsExceedingAlertThreshold(getIntegerAttribute(attribute.getValue(), attribute.getName()));
                break;
        }
    }
    return gatewaySender;
}
Also used : Attribute(javax.management.Attribute) AttributeList(javax.management.AttributeList)

Aggregations

AttributeList (javax.management.AttributeList)56 Attribute (javax.management.Attribute)46 ReflectionException (javax.management.ReflectionException)22 AttributeNotFoundException (javax.management.AttributeNotFoundException)16 InstanceNotFoundException (javax.management.InstanceNotFoundException)16 MBeanException (javax.management.MBeanException)15 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)14 ObjectName (javax.management.ObjectName)14 MBeanAttributeInfo (javax.management.MBeanAttributeInfo)10 MBeanServer (javax.management.MBeanServer)8 IOException (java.io.IOException)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)7 MBeanInfo (javax.management.MBeanInfo)7 RuntimeOperationsException (javax.management.RuntimeOperationsException)7 HashMap (java.util.HashMap)6 MalformedObjectNameException (javax.management.MalformedObjectNameException)6 ListenerNotFoundException (javax.management.ListenerNotFoundException)5 MBeanRegistrationException (javax.management.MBeanRegistrationException)5 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)5 ArrayList (java.util.ArrayList)4