Search in sources :

Example 1 with DistributedSystemMXBean

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

the class CreateAlterDestroyRegionCommands method regionExists.

private static boolean regionExists(InternalCache cache, String regionPath) {
    boolean regionFound = false;
    if (regionPath != null && !Region.SEPARATOR.equals(regionPath)) {
        ManagementService managementService = ManagementService.getExistingManagementService(cache);
        DistributedSystemMXBean dsMBean = managementService.getDistributedSystemMXBean();
        String[] allRegionPaths = dsMBean.listAllRegionPaths();
        for (String allRegionPath : allRegionPaths) {
            if (allRegionPath.equals(regionPath)) {
                regionFound = true;
                break;
            }
        }
    }
    return regionFound;
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) ManagementService(org.apache.geode.management.ManagementService)

Example 2 with DistributedSystemMXBean

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

the class DistributedSystemBridge method addMemberToSystem.

/**
   * Add a proxy to the map to be used by bridge.
   *
   * @param objectName object name of the proxy
   * @param proxy actual proxy instance
   */
public void addMemberToSystem(ObjectName objectName, MemberMXBean proxy, FederationComponent newState) {
    if (objectName.equals(thisMemberName)) {
        ObjectName distrObjectName = MBeanJMXAdapter.getDistributedSystemName();
        DistributedSystemMXBean systemMBean = new DistributedSystemMBean(this);
        service.registerInternalMBean(systemMBean, distrObjectName);
        this.systemLevelNotifEmitter = (DistributedSystemMBean) service.getDistributedSystemMXBean();
        this.distListener = new DistributedSystemNotifListener();
    }
    if (mapOfMembers != null) {
        mapOfMembers.put(objectName, proxy);
        memberSetSize = mapOfMembers.values().size();
    }
    updateMember(objectName, newState, null);
    try {
        mbeanServer.addNotificationListener(objectName, distListener, null, null);
    } catch (InstanceNotFoundException e) {
        if (logger.isDebugEnabled()) {
            logger.debug(e.getMessage());
        }
        logger.info(LocalizedMessage.create(ManagementStrings.INSTANCE_NOT_FOUND, objectName));
    }
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) InstanceNotFoundException(javax.management.InstanceNotFoundException) ObjectName(javax.management.ObjectName)

Example 3 with DistributedSystemMXBean

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

the class DistributedSystemStatsJUnitTest method testIssue51048.

@Test
public void testIssue51048() throws InterruptedException {
    SystemManagementService service = (SystemManagementService) ManagementService.getExistingManagementService(cache);
    DistributedSystemMXBean dsmbean = service.getDistributedSystemMXBean();
    CachePerfStats cachePerfStats = ((GemFireCacheImpl) cache).getCachePerfStats();
    for (int i = 1; i <= 10; i++) {
        cachePerfStats.incCreates();
    }
    sample();
    service.getLocalManager().runManagementTaskAdhoc();
    assertTrue(dsmbean.getAverageWrites() == 10);
    sample();
    service.getLocalManager().runManagementTaskAdhoc();
    assertTrue(dsmbean.getAverageWrites() == 0);
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) CachePerfStats(org.apache.geode.internal.cache.CachePerfStats) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl) SystemManagementService(org.apache.geode.management.internal.SystemManagementService) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 4 with DistributedSystemMXBean

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

the class TestCQDUnitTest method getNumOfCQ.

public static long getNumOfCQ() {
    final WaitCriterion waitCriteria = new WaitCriterion() {

        @Override
        public boolean done() {
            final ManagementService service = getManagementService();
            final DistributedSystemMXBean bean = service.getDistributedSystemMXBean();
            if (bean != null) {
                if (bean.getActiveCQCount() > 0) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public String description() {
            return "wait for getNumOfCQ to complete and get results";
        }
    };
    Wait.waitForCriterion(waitCriteria, 2 * 60 * 1000, 3000, true);
    final DistributedSystemMXBean bean = getManagementService().getDistributedSystemMXBean();
    assertNotNull(bean);
    return bean.getActiveCQCount();
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) ManagementService(org.apache.geode.management.ManagementService)

Example 5 with DistributedSystemMXBean

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

the class TestClientsDUnitTest method getNumOfClients.

public static Integer getNumOfClients() {
    final WaitCriterion waitCriteria = new WaitCriterion() {

        @Override
        public boolean done() {
            final ManagementService service = getManagementService();
            final DistributedSystemMXBean bean = service.getDistributedSystemMXBean();
            if (bean != null) {
                if (bean.getNumClients() > 0) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public String description() {
            return "wait for getNumOfClients bean to complete and get results";
        }
    };
    Wait.waitForCriterion(waitCriteria, 2 * 60 * 1000, 3000, true);
    final DistributedSystemMXBean bean = getManagementService().getDistributedSystemMXBean();
    assertNotNull(bean);
    return Integer.valueOf(bean.getNumClients());
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) ManagementService(org.apache.geode.management.ManagementService)

Aggregations

DistributedSystemMXBean (org.apache.geode.management.DistributedSystemMXBean)22 ManagementService (org.apache.geode.management.ManagementService)15 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)8 SystemManagementService (org.apache.geode.management.internal.SystemManagementService)5 ObjectName (javax.management.ObjectName)4 DistributedMember (org.apache.geode.distributed.DistributedMember)4 InternalCache (org.apache.geode.internal.cache.InternalCache)3 CommandResultException (org.apache.geode.management.internal.cli.result.CommandResultException)3 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Entry (java.util.Map.Entry)2 MBeanServer (javax.management.MBeanServer)2 GemFireCacheImpl (org.apache.geode.internal.cache.GemFireCacheImpl)2 DistributedRegionMXBean (org.apache.geode.management.DistributedRegionMXBean)2 ConverterHint (org.apache.geode.management.cli.ConverterHint)2 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)2 FileNotFoundException (java.io.FileNotFoundException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1