Search in sources :

Example 11 with ManagementService

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

the class TestServerDUnitTest method getNumOfServersFromMBean.

public static int getNumOfServersFromMBean() {
    final WaitCriterion waitCriteria = new WaitCriterion() {

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

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

Example 12 with ManagementService

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

the class MBeanSecurityJUnitTest method testServerSideCalls.

@Test
@ConnectionConfiguration(user = "stranger", password = "1234567")
public void testServerSideCalls() {
    // calls through ManagementService is not going through authorization checks
    ManagementService service = ManagementService.getManagementService(server.getCache());
    MemberMXBean bean = service.getMemberMXBean();
    bean.compactAllDiskStores();
}
Also used : ManagementService(org.apache.geode.management.ManagementService) MemberMXBean(org.apache.geode.management.MemberMXBean) ConnectionConfiguration(org.apache.geode.test.dunit.rules.ConnectionConfiguration) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

Example 13 with ManagementService

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

the class TestLocatorsDUnitTest method getNumOfLocatorFromMBean.

public static int getNumOfLocatorFromMBean() {
    final WaitCriterion waitCriteria = new WaitCriterion() {

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

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

Example 14 with ManagementService

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

the class TestSubscriptionsDUnitTest method verifyNumSubscriptions.

private void verifyNumSubscriptions(final VM vm) {
    vm.invoke("TestSubscriptionsDUnitTest Verify Cache Server Remote", () -> {
        final GemFireCacheImpl cache = GemFireCacheImpl.getInstance();
        waitForCriterion(new WaitCriterion() {

            @Override
            public boolean done() {
                ManagementService service = ManagementService.getExistingManagementService(cache);
                DistributedSystemMXBean distributedSystemMXBean = service.getDistributedSystemMXBean();
                return distributedSystemMXBean != null & distributedSystemMXBean.getNumSubscriptions() > 1;
            }

            @Override
            public String description() {
                return "TestSubscriptionsDUnitTest wait for getDistributedSystemMXBean to complete and get results";
            }
        }, 2 * 60 * 1000, 3000, true);
        DistributedSystemMXBean distributedSystemMXBean = ManagementService.getExistingManagementService(cache).getDistributedSystemMXBean();
        assertNotNull(distributedSystemMXBean);
        assertEquals(2, distributedSystemMXBean.getNumSubscriptions());
    });
}
Also used : DistributedSystemMXBean(org.apache.geode.management.DistributedSystemMXBean) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) ManagementService(org.apache.geode.management.ManagementService) GemFireCacheImpl(org.apache.geode.internal.cache.GemFireCacheImpl)

Example 15 with ManagementService

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

the class TestRemoteClusterDUnitTest method checkReceiverMBean.

/**
   * Checks whether a GatewayReceiverMBean is created or not
   * 
   * @param vm reference to VM
   */
@SuppressWarnings("serial")
protected void checkReceiverMBean(final VM vm) {
    SerializableRunnable checkMBean = new SerializableRunnable("Check Receiver MBean") {

        public void run() {
            Cache cache = GemFireCacheImpl.getInstance();
            ManagementService service = ManagementService.getManagementService(cache);
            GatewayReceiverMXBean bean = service.getLocalGatewayReceiverMXBean();
            assertNotNull(bean);
        }
    };
    vm.invoke(checkMBean);
}
Also used : GatewayReceiverMXBean(org.apache.geode.management.GatewayReceiverMXBean) ManagementService(org.apache.geode.management.ManagementService) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache)

Aggregations

ManagementService (org.apache.geode.management.ManagementService)36 DistributedSystemMXBean (org.apache.geode.management.DistributedSystemMXBean)15 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)11 Cache (org.apache.geode.cache.Cache)8 InternalCache (org.apache.geode.internal.cache.InternalCache)8 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)8 DistributedRegionMXBean (org.apache.geode.management.DistributedRegionMXBean)7 DistributedMember (org.apache.geode.distributed.DistributedMember)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 ObjectName (javax.management.ObjectName)4 CompositeResultData (org.apache.geode.management.internal.cli.result.CompositeResultData)4 SectionResultData (org.apache.geode.management.internal.cli.result.CompositeResultData.SectionResultData)4 VM (org.apache.geode.test.dunit.VM)4 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)4 HashSet (java.util.HashSet)3 List (java.util.List)3 Entry (java.util.Map.Entry)3 Properties (java.util.Properties)3 MalformedObjectNameException (javax.management.MalformedObjectNameException)3