use of org.apache.geode.cache.Cache in project geode by apache.
the class ClusterConfigurationDUnitTest method testDestroyExtensions.
/**
* Tests for {@link Extension}, {@link Extensible}, {@link XmlParser}, {@link XmlGenerator},
* {@link XmlEntity} as it applies to Extensions. Asserts that Mock Extension is created and
* destroyed on region and cache.
*
* @since GemFire 8.1
*/
// GEODE-1333
@Category(FlakyTest.class)
@Test
public void testDestroyExtensions() throws Exception {
Object[] result = setup();
final int locatorPort = (Integer) result[0];
createRegion(REPLICATE_REGION, RegionShortcut.REPLICATE, null);
createMockRegionExtension(REPLICATE_REGION, "value1");
destroyMockRegionExtension(REPLICATE_REGION);
createMockCacheExtension("value1");
destroyMockCacheExtension();
// Start a new member which receives the shared configuration
// Verify the config creation on this member
final String newMemberWorkingDir = this.temporaryFolder.getRoot().getCanonicalPath() + File.separator + newMember;
VM newMember = getHost(0).getVM(2);
newMember.invoke(() -> {
Properties localProps = new Properties();
File workingDir = new File(newMemberWorkingDir);
workingDir.mkdirs();
localProps.setProperty(MCAST_PORT, "0");
localProps.setProperty(LOCATORS, "localhost[" + locatorPort + "]");
localProps.setProperty(NAME, ClusterConfigurationDUnitTest.newMember);
localProps.setProperty(USE_CLUSTER_CONFIGURATION, "true");
localProps.setProperty(DEPLOY_WORKING_DIR, workingDir.getCanonicalPath());
getSystem(localProps);
InternalCache cache = getCache();
assertNotNull(cache);
Region<?, ?> region1 = cache.getRegion(REPLICATE_REGION);
assertNotNull(region1);
// MockRegionExtension verification
@SuppressWarnings("unchecked") final Extensible<Region<?, ?>> extensibleRegion = (Extensible<Region<?, ?>>) region1;
// Should not be any region extensions
assertTrue(!extensibleRegion.getExtensionPoint().getExtensions().iterator().hasNext());
// MockCacheExtension verification
@SuppressWarnings("unchecked") final Extensible<Cache> extensibleCache = (Extensible<Cache>) cache;
// Should not be any cache extensions
assertTrue(!extensibleCache.getExtensionPoint().getExtensions().iterator().hasNext());
return getAllNormalMembers(cache);
});
}
use of org.apache.geode.cache.Cache 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));
}
}
});
}
use of org.apache.geode.cache.Cache 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);
}
use of org.apache.geode.cache.Cache 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);
}
use of org.apache.geode.cache.Cache 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);
}
Aggregations