Search in sources :

Example 36 with SerializableRunnable

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

the class WANManagementDUnitTest method checkProxySender.

/**
   * Checks Proxy GatewaySender
   * 
   * @param vm reference to VM
   */
@SuppressWarnings("serial")
protected void checkProxySender(final VM vm, final DistributedMember senderMember) {
    SerializableRunnable checkProxySender = new SerializableRunnable("Check Proxy Sender") {

        public void run() {
            Cache cache = GemFireCacheImpl.getInstance();
            ManagementService service = ManagementService.getManagementService(cache);
            GatewaySenderMXBean bean = null;
            try {
                bean = MBeanUtil.getGatewaySenderMbeanProxy(senderMember, "pn");
            } catch (Exception e) {
                fail("Could not obtain Sender Proxy in desired time " + e);
            }
            assertNotNull(bean);
            final ObjectName senderMBeanName = service.getGatewaySenderMBeanName(senderMember, "pn");
            try {
                MBeanUtil.printBeanDetails(senderMBeanName);
            } catch (Exception e) {
                fail("Error while Printing Bean Details " + e);
            }
            if (service.isManager()) {
                DistributedSystemMXBean dsBean = service.getDistributedSystemMXBean();
                Awaitility.await().atMost(1, TimeUnit.MINUTES).until(() -> {
                    Map<String, Boolean> dsMap = dsBean.viewRemoteClusterStatus();
                    dsMap.entrySet().stream().forEach(entry -> assertTrue("Should be true " + entry.getKey(), entry.getValue()));
                });
            }
        }
    };
    vm.invoke(checkProxySender);
}
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 37 with SerializableRunnable

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

the class WANManagementDUnitTest method checkProxyReceiver.

/**
   * Checks Proxy GatewayReceiver
   * 
   * @param vm reference to VM
   */
@SuppressWarnings("serial")
protected void checkProxyReceiver(final VM vm, final DistributedMember senderMember) {
    SerializableRunnable checkProxySender = new SerializableRunnable("Check Proxy Receiver") {

        public void run() {
            Cache cache = GemFireCacheImpl.getInstance();
            ManagementService service = ManagementService.getManagementService(cache);
            GatewayReceiverMXBean bean = null;
            try {
                bean = MBeanUtil.getGatewayReceiverMbeanProxy(senderMember);
            } catch (Exception e) {
                fail("Could not obtain Sender Proxy in desired time " + e);
            }
            assertNotNull(bean);
            final ObjectName receiverMBeanName = service.getGatewayReceiverMBeanName(senderMember);
            try {
                MBeanUtil.printBeanDetails(receiverMBeanName);
            } catch (Exception e) {
                fail("Error while Printing Bean Details " + e);
            }
        }
    };
    vm.invoke(checkProxySender);
}
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 38 with SerializableRunnable

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

the class WANManagementDUnitTest 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 : SystemManagementService(org.apache.geode.management.internal.SystemManagementService) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache)

Example 39 with SerializableRunnable

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

the class WANManagementDUnitTest method checkAsyncQueueMBean.

/**
   * Checks whether a Async Queue MBean is created or not
   * 
   * @param vm reference to VM
   */
@SuppressWarnings("serial")
protected void checkAsyncQueueMBean(final VM vm, final boolean shouldExist) {
    SerializableRunnable checkAsyncQueueMBean = new SerializableRunnable("Check Async Queue MBean") {

        public void run() {
            Cache cache = GemFireCacheImpl.getInstance();
            ManagementService service = ManagementService.getManagementService(cache);
            AsyncEventQueueMXBean bean = service.getLocalAsyncEventQueueMXBean("pn");
            if (shouldExist) {
                assertNotNull(bean);
            } else {
                assertNull(bean);
            }
        }
    };
    vm.invoke(checkAsyncQueueMBean);
}
Also used : SystemManagementService(org.apache.geode.management.internal.SystemManagementService) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Cache(org.apache.geode.cache.Cache)

Example 40 with SerializableRunnable

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

the class DataCommandsOverHttpDistributedTest method setupTestRebalanceForEntireDS.

void setupTestRebalanceForEntireDS() {
    final VM vm1 = Host.getHost(0).getVM(1);
    final VM vm2 = Host.getHost(0).getVM(2);
    setUpJmxManagerOnVm0ThenConnect(null);
    vm1.invoke(new SerializableRunnable() {

        public void run() {
            // no need to close cache as it will be closed as part of teardown2
            Cache cache = getCache();
            RegionFactory<Integer, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
            Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
            for (int i = 0; i < 10; i++) {
                region.put("key" + (i + 200), "value" + (i + 200));
            }
            region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another1");
            for (int i = 0; i < 100; i++) {
                region.put("key" + (i + 200), "value" + (i + 200));
            }
        }
    });
    vm2.invoke(new SerializableRunnable() {

        public void run() {
            // no need to close cache as it will be closed as part of teardown2
            Cache cache = getCache();
            RegionFactory<Integer, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
            Region region = dataRegionFactory.create(REBALANCE_REGION_NAME);
            for (int i = 0; i < 100; i++) {
                region.put("key" + (i + 400), "value" + (i + 400));
            }
            region = dataRegionFactory.create(REBALANCE_REGION_NAME + "Another2");
            for (int i = 0; i < 10; i++) {
                region.put("key" + (i + 200), "value" + (i + 200));
            }
        }
    });
}
Also used : RegionFactory(org.apache.geode.cache.RegionFactory) VM(org.apache.geode.test.dunit.VM) SerializableRunnable(org.apache.geode.test.dunit.SerializableRunnable) Region(org.apache.geode.cache.Region) Cache(org.apache.geode.cache.Cache)

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