Search in sources :

Example 6 with ManagementService

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

the class GemfireDataCommandsDUnitTest method doTestSelectProjectionProcessCommand.

public void doTestSelectProjectionProcessCommand() {
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            Random random = new Random(System.nanoTime());
            int randomInteger = random.nextInt(COUNT);
            String query = "query --query=\"select ID , status , createTime , pk, floatMinValue from " + DATA_PAR_REGION_NAME_PATH + " where ID <= " + randomInteger + "\" --interactive=false";
            ManagementService service = ManagementService.getExistingManagementService(getCache());
            MemberMXBean member = service.getMemberMXBean();
            String cmdResult = member.processCommand(query);
            assertNotNull(cmdResult);
            getLogWriter().info("Text Command Output : " + cmdResult);
        }
    });
}
Also used : ManagementService(org.apache.geode.management.ManagementService) Random(java.util.Random) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) MemberMXBean(org.apache.geode.management.MemberMXBean)

Example 7 with ManagementService

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

the class GemfireDataCommandsDUnitTest method waitForListClientMbean.

public void waitForListClientMbean(final String regionName) {
    final VM manager = Host.getHost(0).getVM(0);
    manager.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            Cache cache = getCache();
            final ManagementService service = ManagementService.getManagementService(cache);
            final WaitCriterion waitForMaangerMBean = new WaitCriterion() {

                @Override
                public boolean done() {
                    ManagerMXBean bean1 = service.getManagerMXBean();
                    DistributedRegionMXBean bean2 = service.getDistributedRegionMXBean(regionName);
                    if (bean1 == null) {
                        getLogWriter().info("waitForListClientMbean Still probing for ManagerMBean");
                        return false;
                    } else {
                        getLogWriter().info("waitForListClientMbean Still probing for DistributedRegionMXBean=" + bean2);
                        if (bean2 == null) {
                            bean2 = service.getDistributedRegionMXBean(Region.SEPARATOR + regionName);
                        }
                        if (bean2 == null) {
                            getLogWriter().info("waitForListClientMbean Still probing for DistributedRegionMXBean with separator = " + bean2);
                            return false;
                        } else {
                            getLogWriter().info("waitForListClientMbean Still probing for DistributedRegionMXBean with separator Not null  " + bean2.getMembers().length);
                            return bean2.getMembers().length > 1;
                        }
                    }
                }

                @Override
                public String description() {
                    return "waitForListClientMbean Probing for ManagerMBean";
                }
            };
            waitForCriterion(waitForMaangerMBean, 30000, 2000, true);
            DistributedRegionMXBean bean = service.getDistributedRegionMXBean(regionName);
            if (bean == null) {
                bean = service.getDistributedRegionMXBean(Region.SEPARATOR + regionName);
            }
            assertNotNull(bean);
        }
    });
}
Also used : ManagementService(org.apache.geode.management.ManagementService) WaitCriterion(org.apache.geode.test.dunit.WaitCriterion) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) ManagerMXBean(org.apache.geode.management.ManagerMXBean) DistributedRegionMXBean(org.apache.geode.management.DistributedRegionMXBean) Cache(org.apache.geode.cache.Cache) InternalCache(org.apache.geode.internal.cache.InternalCache)

Example 8 with ManagementService

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

the class SecurityManagerCallbacksDistributedTest method verifyCallbacksRegardlessOfManager.

private void verifyCallbacksRegardlessOfManager(final boolean isManager) {
    ManagementService ms = getExistingManagementService(getCache());
    assertThat(ms).isNotNull();
    assertThat(ms.isManager()).isEqualTo(isManager);
    verifyInitAndCloseInvoked();
}
Also used : ManagementService(org.apache.geode.management.ManagementService) ManagementService.getExistingManagementService(org.apache.geode.management.ManagementService.getExistingManagementService)

Example 9 with ManagementService

use of org.apache.geode.management.ManagementService 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 10 with ManagementService

use of org.apache.geode.management.ManagementService 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

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