Search in sources :

Example 31 with Cache

use of org.apache.geode.cache.Cache in project geode by apache.

the class RebalanceDUnitTest method putEntryInEachBucket.

// Duplicated for now, try to abstract this out...
protected void putEntryInEachBucket() {
    accessor.invoke(() -> {
        final Cache cache = getCache();
        Region<Object, Object> region = cache.getRegion(REGION_NAME);
        IntStream.range(0, NUM_BUCKETS).forEach(i -> region.put(i, new TestObject("hello world")));
    });
}
Also used : Cache(org.apache.geode.cache.Cache)

Example 32 with Cache

use of org.apache.geode.cache.Cache 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 33 with Cache

use of org.apache.geode.cache.Cache 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 34 with Cache

use of org.apache.geode.cache.Cache 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 35 with Cache

use of org.apache.geode.cache.Cache 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)

Aggregations

Cache (org.apache.geode.cache.Cache)1044 Region (org.apache.geode.cache.Region)478 Test (org.junit.Test)476 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)292 SerializableRunnable (org.apache.geode.test.dunit.SerializableRunnable)277 VM (org.apache.geode.test.dunit.VM)264 Host (org.apache.geode.test.dunit.Host)230 AttributesFactory (org.apache.geode.cache.AttributesFactory)229 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)177 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)176 CacheSerializableRunnable (org.apache.geode.cache30.CacheSerializableRunnable)164 LocalRegion (org.apache.geode.internal.cache.LocalRegion)153 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)123 ClientCache (org.apache.geode.cache.client.ClientCache)117 SerializableCallable (org.apache.geode.test.dunit.SerializableCallable)112 Properties (java.util.Properties)101 CacheException (org.apache.geode.cache.CacheException)101 RegionAttributes (org.apache.geode.cache.RegionAttributes)99 QueryService (org.apache.geode.cache.query.QueryService)95 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)93