Search in sources :

Example 36 with ManagementService

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

the class ReadOpFileAccessControllerJUnitTest method testReadOnlyOperations.

@Test
public void testReadOnlyOperations() throws IOException, InstanceNotFoundException, ReflectionException, MBeanException {
    ManagementService service = ManagementService.getExistingManagementService(GemFireCacheImpl.getInstance());
    String accessFileName = createAccessFile();
    String passwordFileName = createPasswordFile();
    createConnector(accessFileName, passwordFileName);
    MBeanServerConnection server = connectToRmiConnector();
    DistributedMember member = cache.getMyId();
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listRegions", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listGemFireProperties", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listConnectedGatewayReceivers", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listConnectedGatewaySenders", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "showJVMMetrics", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "showOSMetrics", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "fetchJvmThreads", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "viewLicense", null, null));
    // TODO QueryData : Start Manager fails due to #50280 : Can not start manager inside a loner
    try {
        server.invoke(service.getMemberMBeanName(member), "compactAllDiskStores", null, null);
        fail("Admin operation accessible to readonly user");
    } catch (SecurityException e) {
    // ok
    }
}
Also used : ManagementService(org.apache.geode.management.ManagementService) DistributedMember(org.apache.geode.distributed.DistributedMember) Test(org.junit.Test) IntegrationTest(org.apache.geode.test.junit.categories.IntegrationTest)

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