Search in sources :

Example 1 with MemberMXBean

use of org.apache.geode.management.MemberMXBean in project geode by apache.

the class DistributedSystemBridge method showDiskMetrics.

public DiskMetrics showDiskMetrics(String member) throws Exception {
    MemberMXBean bean = validateMember(member);
    DiskMetrics dm = new DiskMetrics();
    dm.setDiskReadsRate(bean.getDiskReadsRate());
    dm.setDiskWritesRate(bean.getDiskWritesRate());
    dm.setTotalBackupInProgress(bean.getTotalBackupInProgress());
    dm.setTotalBackupCompleted(bean.getTotalBackupCompleted());
    dm.setDiskFlushAvgLatency(bean.getDiskFlushAvgLatency());
    dm.setTotalBytesOnDisk(bean.getTotalDiskUsage());
    return dm;
}
Also used : DiskMetrics(org.apache.geode.management.DiskMetrics) MemberMXBean(org.apache.geode.management.MemberMXBean)

Example 2 with MemberMXBean

use of org.apache.geode.management.MemberMXBean in project geode by apache.

the class DistributedSystemBridge method getGroups.

/**
   * @return list of groups visible to the Manager node
   */
public String[] getGroups() {
    String[] groups = new String[0];
    Collection<MemberMXBean> values = mapOfMembers.values();
    if (values != null) {
        Set<String> groupSet = new TreeSet<>();
        for (MemberMXBean memberMXBean : values) {
            String[] memberGroups = memberMXBean.getGroups();
            if (memberGroups != null && memberGroups.length != 0) {
                groupSet.addAll(Arrays.asList(memberGroups));
            }
        }
        if (!groupSet.isEmpty()) {
            groups = new String[groupSet.size()];
            groups = groupSet.toArray(groups);
        }
    }
    return groups;
}
Also used : TreeSet(java.util.TreeSet) MemberMXBean(org.apache.geode.management.MemberMXBean)

Example 3 with MemberMXBean

use of org.apache.geode.management.MemberMXBean in project geode by apache.

the class DistributedSystemBridge method getMemberDiskstoreMap.

/**
   * @return Lists all the members disk stores
   */
public Map<String, String[]> getMemberDiskstoreMap() {
    Iterator<MemberMXBean> memberIterator = mapOfMembers.values().iterator();
    if (memberIterator != null) {
        Map<String, String[]> mapOfDisks = new HashMap<>();
        while (memberIterator.hasNext()) {
            MemberMXBean bean = memberIterator.next();
            mapOfDisks.put(bean.getMember(), bean.getDiskStores());
        }
        return mapOfDisks;
    }
    return Collections.emptyMap();
}
Also used : ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) MemberMXBean(org.apache.geode.management.MemberMXBean)

Example 4 with MemberMXBean

use of org.apache.geode.management.MemberMXBean in project geode by apache.

the class DistributedSystemBridge method validateMember.

private MemberMXBean validateMember(String member) throws Exception {
    ObjectName objectName = MBeanJMXAdapter.getMemberMBeanName(member);
    MemberMXBean bean = mapOfMembers.get(objectName);
    if (bean != null) {
        return bean;
    } else {
        throw new Exception(ManagementStrings.INVALID_MEMBER_NAME_OR_ID.toLocalizedString(member));
    }
}
Also used : ManagementException(org.apache.geode.management.ManagementException) ListenerNotFoundException(javax.management.ListenerNotFoundException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectName(javax.management.ObjectName) MemberMXBean(org.apache.geode.management.MemberMXBean)

Example 5 with MemberMXBean

use of org.apache.geode.management.MemberMXBean in project geode by apache.

the class ManagementAdapter method handleManagerStart.

/**
   * Handles all the distributed mbean creation part when a Manager is started
   */
public void handleManagerStart() throws ManagementException {
    if (!isServiceInitialised("handleManagerStart")) {
        return;
    }
    MBeanJMXAdapter jmxAdapter = service.getJMXAdapter();
    Map<ObjectName, Object> registeredMBeans = jmxAdapter.getLocalGemFireMBean();
    DistributedSystemBridge dsBridge = new DistributedSystemBridge(service);
    this.aggregator = new MBeanAggregator(dsBridge);
    // register the aggregator for Federation framework to use
    service.addProxyListener(aggregator);
    /*
     * get the local member mbean as it need to be provided to aggregator first
     */
    MemberMXBean localMember = service.getMemberMXBean();
    ObjectName memberObjectName = MBeanJMXAdapter.getMemberMBeanName(InternalDistributedSystem.getConnectedInstance().getDistributedMember());
    FederationComponent addedComp = service.getLocalManager().getFedComponents().get(memberObjectName);
    service.afterCreateProxy(memberObjectName, MemberMXBean.class, localMember, addedComp);
    for (ObjectName objectName : registeredMBeans.keySet()) {
        if (objectName.equals(memberObjectName)) {
            continue;
        }
        Object object = registeredMBeans.get(objectName);
        ObjectInstance instance;
        try {
            instance = mbeanServer.getObjectInstance(objectName);
            String className = instance.getClassName();
            Class cls = ClassLoadUtil.classFromName(className);
            Type[] intfTyps = cls.getGenericInterfaces();
            FederationComponent newObj = service.getLocalManager().getFedComponents().get(objectName);
            for (Type intfTyp1 : intfTyps) {
                Class intfTyp = (Class) intfTyp1;
                service.afterCreateProxy(objectName, intfTyp, object, newObj);
            }
        } catch (InstanceNotFoundException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Failed in Registering distributed mbean ");
            }
            throw new ManagementException(e);
        } catch (ClassNotFoundException e) {
            if (logger.isDebugEnabled()) {
                logger.debug("Failed in Registering distributed mbean");
            }
            throw new ManagementException(e);
        }
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectInstance(javax.management.ObjectInstance) ObjectName(javax.management.ObjectName) MemberMXBean(org.apache.geode.management.MemberMXBean) Type(java.lang.reflect.Type) JMXNotificationType(org.apache.geode.management.JMXNotificationType) ManagementException(org.apache.geode.management.ManagementException) MBeanJMXAdapter(org.apache.geode.management.internal.MBeanJMXAdapter) FederationComponent(org.apache.geode.management.internal.FederationComponent)

Aggregations

MemberMXBean (org.apache.geode.management.MemberMXBean)25 ObjectName (javax.management.ObjectName)9 Test (org.junit.Test)6 CliMetaData (org.apache.geode.management.cli.CliMetaData)5 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)5 CliCommand (org.springframework.shell.core.annotation.CliCommand)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)4 CacheFactory (org.apache.geode.cache.CacheFactory)4 ManagementException (org.apache.geode.management.ManagementException)4 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)4 MXBeanProvider.getMemberMXBean (org.apache.geode.management.internal.cli.shell.MXBeanProvider.getMemberMXBean)4 ArrayList (java.util.ArrayList)3 Properties (java.util.Properties)3 ManagementService (org.apache.geode.management.ManagementService)3 Type (java.lang.reflect.Type)2 ListenerNotFoundException (javax.management.ListenerNotFoundException)2 MalformedObjectNameException (javax.management.MalformedObjectNameException)2 ObjectInstance (javax.management.ObjectInstance)2 DistributedMember (org.apache.geode.distributed.DistributedMember)2 LocatorLauncher (org.apache.geode.distributed.LocatorLauncher)2