Search in sources :

Example 41 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class WANManagementDUnitTest method checkSenderNavigationAPIS.

@SuppressWarnings("serial")
protected void checkSenderNavigationAPIS(final VM vm, final DistributedMember senderMember) {
    SerializableRunnable checkNavigationAPIS = new SerializableRunnable("Check Sender Navigation APIs") {

        public void run() {
            Cache cache = GemFireCacheImpl.getInstance();
            ManagementService service = ManagementService.getManagementService(cache);
            DistributedSystemMXBean bean = service.getDistributedSystemMXBean();
            ObjectName expectedName = service.getGatewaySenderMBeanName(senderMember, "pn");
            try {
                ObjectName actualName = bean.fetchGatewaySenderObjectName(senderMember.getId(), "pn");
                assertEquals(expectedName, actualName);
            } catch (Exception e) {
                fail("Sender Navigation Failed " + e);
            }
            assertEquals(2, bean.listGatewaySenderObjectNames().length);
            try {
                assertEquals(1, bean.listGatewaySenderObjectNames(senderMember.getId()).length);
            } catch (Exception e) {
                fail("Sender Navigation Failed " + e);
            }
        }
    };
    vm.invoke(checkNavigationAPIS);
}
Also used : SystemManagementService(org.apache.geode.management.internal.SystemManagementService) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache) ObjectName(javax.management.ObjectName)

Example 42 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable 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)

Example 43 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class TestRemoteClusterDUnitTest method stopGatewaySender.

/**
   * stops a gateway sender
   * 
   * @param vm reference to VM
   */
@SuppressWarnings("serial")
protected void stopGatewaySender(final VM vm) {
    SerializableRunnable stopGatewaySender = new SerializableRunnable("Stop Gateway Sender") {

        public void run() {
            Cache cache = GemFireCacheImpl.getInstance();
            ManagementService service = ManagementService.getManagementService(cache);
            GatewaySenderMXBean bean = service.getLocalGatewaySenderMXBean("pn");
            assertNotNull(bean);
            bean.stop();
            assertFalse(bean.isRunning());
        }
    };
    vm.invoke(stopGatewaySender);
}
Also used : ManagementService(org.apache.geode.management.ManagementService) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) GatewaySenderMXBean(org.apache.geode.management.GatewaySenderMXBean) Cache(org.apache.geode.cache.Cache)

Example 44 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CliUtilDUnitTest method setupMembersWithIdsAndGroups.

@SuppressWarnings("serial")
void setupMembersWithIdsAndGroups() {
    final VM vm1 = Host.getHost(0).getVM(0);
    final VM vm2 = Host.getHost(0).getVM(1);
    final VM vm3 = Host.getHost(0).getVM(2);
    final VM vm4 = Host.getHost(0).getVM(3);
    vm1.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            createCacheWithMemberIdAndGroup(MEMBER_1_GROUP1, GROUP1);
            createRegion(REGION_MEMBER1_GROUP1);
            createRegion(COMMON_REGION_GROUP1);
            createRegion(COMMON_REGION);
        }
    });
    vm2.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            createCacheWithMemberIdAndGroup(MEMBER_2_GROUP1, GROUP1);
            createRegion(REGION_MEMBER2_GROUP1);
            createRegion(COMMON_REGION_GROUP1);
            createRegion(COMMON_REGION);
        }
    });
    vm3.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            createCacheWithMemberIdAndGroup(MEMBER_1_GROUP2, GROUP2);
            createRegion(REGION_MEMBER1_GROUP2);
            createRegion(COMMON_REGION_GROUP2);
            createRegion(COMMON_REGION);
        }
    });
    vm4.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            createCacheWithMemberIdAndGroup(MEMBER_2_GROUP2, GROUP2);
            createRegion(REGION_MEMBER2_GROUP2);
            createRegion(COMMON_REGION_GROUP2);
            createRegion(COMMON_REGION);
        }
    });
    vm1.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            startManager();
        }
    });
}
Also used : VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable)

Example 45 with SerializableRunnable

use of org.apache.geode.test.dunit.SerializableRunnable in project geode by apache.

the class CliUtilDUnitTest method testCliUtilMethods.

@SuppressWarnings("serial")
@Test
public void testCliUtilMethods() {
    setupMembersWithIdsAndGroups();
    final VM vm1 = Host.getHost(0).getVM(0);
    LogWriterUtils.getLogWriter().info("testFor - findMembersOrThrow");
    vm1.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            verifyFindAllMatchingMembers();
        }
    });
    final String id = (String) vm1.invoke(new SerializableCallable() {

        @Override
        public Object call() throws Exception {
            InternalCache cache = getCache();
            return cache.getDistributedSystem().getDistributedMember().getId();
        }
    });
    LogWriterUtils.getLogWriter().info("testFor - getDistributedMemberByNameOrId");
    vm1.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            getDistributedMemberByNameOrId(MEMBER_1_GROUP1, id);
        }
    });
    LogWriterUtils.getLogWriter().info("testFor - executeFunction");
    vm1.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            verifyExecuteFunction();
        }
    });
    LogWriterUtils.getLogWriter().info("testFor - getRegionAssociatedMembers");
    vm1.invoke(new SerializableRunnable() {

        @Override
        public void run() {
            getRegionAssociatedMembers();
        }
    });
}
Also used : VM(org.apache.geode.test.dunit.VM) SerializableCallable(org.apache.geode.test.dunit.SerializableCallable) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) InternalCache(org.apache.geode.internal.cache.InternalCache) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Aggregations

SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)741 VM (org.apache.geode.test.dunit.VM)405 Test (org.junit.Test)403 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)353 Region (org.apache.geode.cache.Region)347 Host (org.apache.geode.test.dunit.Host)344 Cache (org.apache.geode.cache.Cache)274 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)259 CacheException (org.apache.geode.cache.CacheException)207 AttributesFactory (org.apache.geode.cache.AttributesFactory)204 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)198 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)166 LocalRegion (org.apache.geode.internal.cache.LocalRegion)160 IOException (java.io.IOException)145 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)120 Properties (java.util.Properties)66 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)66 AsyncInvocation (org.apache.geode.test.dunit.AsyncInvocation)65 IgnoredException (org.apache.geode.test.dunit.IgnoredException)61 WaitCriterion (org.apache.geode.test.dunit.WaitCriterion)53