use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method doTestClients.
public void doTestClients(boolean partitioned, String oldVersion) throws Exception {
final Host host = Host.getHost(0);
VM locator = host.getVM(oldVersion, 0);
VM server2 = host.getVM(oldVersion, 1);
VM server3 = host.getVM(oldVersion, 2);
VM client = host.getVM(oldVersion, 3);
final String objectType = "strings";
final String regionName = "aRegion";
RegionShortcut shortcut = RegionShortcut.REPLICATE;
if (partitioned) {
shortcut = RegionShortcut.PARTITION_REDUNDANT;
}
int[] ports = AvailablePortHelper.getRandomAvailableTCPPorts(3);
int[] locatorPorts = new int[] { ports[0] };
int[] csPorts = new int[] { ports[1], ports[2] };
DistributedTestUtils.deleteLocatorStateFile(locatorPorts);
String hostName = NetworkUtils.getServerHostName(host);
String[] hostNames = new String[] { hostName };
String locatorString = getLocatorString(locatorPorts);
try {
locator.invoke(invokeStartLocator(hostName, locatorPorts[0], getTestMethodName(), getLocatorPropertiesPre91(locatorString)));
invokeRunnableInVMs(invokeCreateCache(getSystemProperties(locatorPorts)), server2, server3);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[0]), server2);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[1]), server3);
invokeRunnableInVMs(invokeCreateClientCache(getClientSystemProperties(), hostNames, locatorPorts), client);
// invokeRunnableInVMs(invokeAssertVersion(oldOrdinal), server2, server3, client);
invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), server2, server3);
invokeRunnableInVMs(invokeCreateClientRegion(regionName, ClientRegionShortcut.PROXY), client);
putAndVerify(objectType, client, regionName, 0, 10, server3, client);
putAndVerify(objectType, server3, regionName, 100, 110, server3, client);
locator = rollLocatorToCurrent(locator, hostName, locatorPorts[0], getTestMethodName(), locatorString);
server3 = rollServerToCurrentAndCreateRegion(server3, shortcut, regionName, locatorPorts);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[1]), server3);
putAndVerify(objectType, client, regionName, 15, 25, server3, client);
putAndVerify(objectType, server3, regionName, 20, 30, server3, client);
server2 = rollServerToCurrentAndCreateRegion(server2, shortcut, regionName, locatorPorts);
invokeRunnableInVMs(invokeStartCacheServer(csPorts[0]), server2);
putAndVerify(objectType, client, regionName, 25, 35, server2, client);
putAndVerify(objectType, server2, regionName, 30, 40, server3, client);
client = rollClientToCurrentAndCreateRegion(client, ClientRegionShortcut.PROXY, regionName, hostNames, locatorPorts);
putAndVerify(objectType, client, regionName, 35, 45, server2, server3);
putAndVerify(objectType, server2, regionName, 40, 50, server3, client);
} finally {
invokeRunnableInVMs(true, invokeStopLocator(), locator);
invokeRunnableInVMs(true, invokeCloseCache(), server2, server3, client);
}
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method doTestRollTwoLocatorsWithTwoServers.
// 2 locator, 2 servers
public void doTestRollTwoLocatorsWithTwoServers(boolean partitioned, String oldVersion) throws Exception {
final Host host = Host.getHost(0);
VM server1 = host.getVM(oldVersion, 0);
VM server2 = host.getVM(oldVersion, 1);
VM server3 = host.getVM(oldVersion, 2);
VM server4 = host.getVM(oldVersion, 3);
final String objectType = "strings";
final String regionName = "aRegion";
RegionShortcut shortcut = RegionShortcut.REPLICATE;
if (partitioned) {
shortcut = RegionShortcut.PARTITION_REDUNDANT;
}
int[] locatorPorts = AvailablePortHelper.getRandomAvailableTCPPorts(2);
DistributedTestUtils.deleteLocatorStateFile(locatorPorts);
String hostName = NetworkUtils.getServerHostName(host);
String locatorString = getLocatorString(locatorPorts);
try {
server1.invoke(invokeStartLocator(hostName, locatorPorts[0], getTestMethodName(), getLocatorPropertiesPre91(locatorString)));
server2.invoke(invokeStartLocator(hostName, locatorPorts[1], getTestMethodName(), getLocatorPropertiesPre91(locatorString)));
invokeRunnableInVMs(invokeCreateCache(getSystemProperties(locatorPorts)), server3, server4);
// invokeRunnableInVMs(invokeAssertVersion(oldOrdinal), server3, server4);
invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), server3, server4);
putAndVerify(objectType, server3, regionName, 0, 10, server3, server4);
server1 = rollLocatorToCurrent(server1, hostName, locatorPorts[0], getTestMethodName(), locatorString);
server2 = rollLocatorToCurrent(server2, hostName, locatorPorts[1], getTestMethodName(), locatorString);
server3 = rollServerToCurrentAndCreateRegion(server3, shortcut, regionName, locatorPorts);
putAndVerify(objectType, server4, regionName, 15, 25, server3, server4);
putAndVerify(objectType, server3, regionName, 20, 30, server3, server4);
server4 = rollServerToCurrentAndCreateRegion(server4, shortcut, regionName, locatorPorts);
putAndVerify(objectType, server4, regionName, 25, 35, server3, server4);
putAndVerify(objectType, server3, regionName, 30, 40, server3, server4);
} finally {
invokeRunnableInVMs(true, invokeStopLocator(), server1, server2);
invokeRunnableInVMs(true, invokeCloseCache(), server3, server4);
}
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method testOplogMagicSeqBackwardCompactibility.
// TODO file a JIRA ticket
// java.lang.AssertionError
// at org.junit.Assert.fail(Assert.java:86)
// at org.junit.Assert.assertTrue(Assert.java:41)
// at org.junit.Assert.assertFalse(Assert.java:64)
// at org.junit.Assert.assertFalse(Assert.java:74)
// at
// org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.verifyOplogHeader(RollingUpgrade2DUnitTest.java:633)
// at
// org.apache.geode.internal.cache.rollingupgrade.RollingUpgrade2DUnitTest.testOplogMagicSeqBackwardCompactibility(RollingUpgrade2DUnitTest.java:568)
@Ignore("GEODE-2355: test fails consistently")
@Test
public void testOplogMagicSeqBackwardCompactibility() throws Exception {
String objectType = "strings";
String regionType = "persistentReplicate";
final Host host = Host.getHost(0);
VM server1 = host.getVM(oldVersion, 0);
VM server2 = host.getVM(oldVersion, 1);
VM server3 = host.getVM(oldVersion, 2);
VM locator = host.getVM(oldVersion, 3);
String regionName = "aRegion";
RegionShortcut shortcut = RegionShortcut.REPLICATE_PERSISTENT;
for (int i = 0; i < testingDirs.length; i++) {
testingDirs[i] = new File(diskDir, "diskStoreVM_" + String.valueOf(host.getVM(i).getPid())).getAbsoluteFile();
if (!testingDirs[i].exists()) {
System.out.println(" Creating diskdir for server: " + i);
testingDirs[i].mkdirs();
}
}
int[] locatorPorts = AvailablePortHelper.getRandomAvailableTCPPorts(1);
String hostName = NetworkUtils.getServerHostName(host);
String locatorsString = getLocatorString(locatorPorts);
DistributedTestUtils.deleteLocatorStateFile(locatorPorts);
try {
locator.invoke(invokeStartLocator(hostName, locatorPorts[0], getTestMethodName(), getLocatorPropertiesPre91(locatorsString)));
invokeRunnableInVMs(invokeCreateCache(getSystemProperties(locatorPorts)), server1, server2, server3);
// create region
for (int i = 0; i < testingDirs.length; i++) {
CacheSerializableRunnable runnable = invokeCreatePersistentReplicateRegion(regionName, testingDirs[i]);
invokeRunnableInVMs(runnable, host.getVM(i));
}
putAndVerify("strings", server1, regionName, 0, 10, server2, server3);
// before upgrade headers will be absent
HashSet<String> oldFormatFiles = verifyOplogHeader(testingDirs[0], null);
locator = rollLocatorToCurrent(locator, hostName, locatorPorts[0], getTestMethodName(), locatorsString);
server1 = rollServerToCurrentAndCreateRegion(server1, regionType, testingDirs[0], shortcut, regionName, locatorPorts);
System.out.println(verifyOplogHeader(testingDirs[0], oldFormatFiles));
verifyValues(objectType, regionName, 0, 10, server1);
putAndVerify(objectType, server1, regionName, 5, 15, server2, server3);
putAndVerify(objectType, server2, regionName, 10, 20, server1, server3);
System.out.println(verifyOplogHeader(testingDirs[0], oldFormatFiles));
System.out.println(verifyOplogHeader(testingDirs[1], null));
} finally {
invokeRunnableInVMs(true, invokeStopLocator(), locator);
invokeRunnableInVMs(true, invokeCloseCache(), server1, server2, server3);
if ((regionType.equals("persistentReplicate"))) {
deleteDiskStores();
}
}
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class RollingUpgrade2DUnitTest method doTestQueryMixedServers.
public void doTestQueryMixedServers(boolean partitioned, String oldVersion) throws Exception {
final Host host = Host.getHost(0);
VM currentServer1 = host.getVM(0);
VM oldServer = host.getVM(oldVersion, 1);
VM currentServer2 = host.getVM(2);
VM oldServerAndLocator = host.getVM(oldVersion, 3);
String regionName = "cqs";
RegionShortcut shortcut = RegionShortcut.REPLICATE;
if (partitioned) {
shortcut = RegionShortcut.PARTITION;
}
String serverHostName = NetworkUtils.getServerHostName(Host.getHost(0));
int port = AvailablePortHelper.getRandomAvailableTCPPort();
try {
Properties props = getSystemProperties();
props.remove(DistributionConfig.LOCATORS_NAME);
invokeRunnableInVMs(invokeStartLocatorAndServer(serverHostName, port, props), oldServerAndLocator);
props.put(DistributionConfig.LOCATORS_NAME, serverHostName + "[" + port + "]");
invokeRunnableInVMs(invokeCreateCache(props), currentServer1, currentServer2, oldServer);
currentServer1.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL));
currentServer2.invoke(invokeAssertVersion(Version.CURRENT_ORDINAL));
// oldServer.invoke(invokeAssertVersion(oldOrdinal));
// oldServerAndLocator.invoke(invokeAssertVersion(oldOrdinal));
// create region
invokeRunnableInVMs(invokeCreateRegion(regionName, shortcut), currentServer1, currentServer2, oldServer, oldServerAndLocator);
putDataSerializableAndVerify(currentServer1, regionName, 0, 100, currentServer2, oldServer, oldServerAndLocator);
query("Select * from /" + regionName + " p where p.timeout > 0L", 99, currentServer1, currentServer2, oldServer, oldServerAndLocator);
} finally {
invokeRunnableInVMs(invokeCloseCache(), currentServer1, currentServer2, oldServer, oldServerAndLocator);
}
}
use of org.apache.geode.cache.RegionShortcut in project geode by apache.
the class OutOfOffHeapMemoryDUnitTest method testOtherMembersSeeOutOfOffHeapMemoryMemberDisconnects.
@Test
public void testOtherMembersSeeOutOfOffHeapMemoryMemberDisconnects() {
final int vmCount = Host.getHost(0).getVMCount();
final String name = getRegionName();
final RegionShortcut shortcut = getRegionShortcut();
final int biggerVM = 0;
final int smallerVM = 1;
Host.getHost(0).getVM(smallerVM).invoke(new SerializableRunnable() {
public void run() {
OutOfOffHeapMemoryDUnitTest.isSmallerVM.set(true);
}
});
// create off-heap region in all members
for (int i = 0; i < vmCount; i++) {
Host.getHost(0).getVM(i).invoke(new SerializableRunnable() {
public void run() {
OutOfOffHeapMemoryDUnitTest.cache.set(getCache());
OutOfOffHeapMemoryDUnitTest.system.set(getSystem());
final Region<Object, Object> region = OutOfOffHeapMemoryDUnitTest.cache.get().createRegionFactory(shortcut).setOffHeap(true).create(name);
assertNotNull(region);
}
});
}
// make sure there are vmCount+1 members total
for (int i = 0; i < vmCount; i++) {
Host.getHost(0).getVM(i).invoke(new SerializableRunnable() {
public void run() {
assertFalse(OutOfOffHeapMemoryDUnitTest.cache.get().isClosed());
assertTrue(OutOfOffHeapMemoryDUnitTest.system.get().isConnected());
// +1 for locator
final int countMembersPlusLocator = vmCount + 1;
// -1 one for self
final int countOtherMembers = vmCount - 1;
assertEquals(countMembersPlusLocator, ((InternalDistributedSystem) OutOfOffHeapMemoryDUnitTest.system.get()).getDistributionManager().getDistributionManagerIds().size());
assertEquals(countOtherMembers, ((DistributedRegion) OutOfOffHeapMemoryDUnitTest.cache.get().getRegion(name)).getDistributionAdvisor().getNumProfiles());
}
});
}
// perform puts in bigger member until smaller member goes OOOHME
Host.getHost(0).getVM(biggerVM).invoke(new SerializableRunnable() {
public void run() {
final long TIME_LIMIT = 30 * 1000;
final StopWatch stopWatch = new StopWatch(true);
// -1 for self
int countOtherMembers = vmCount - 1;
// -1 for self, -1 for smallerVM
final int countOtherMembersMinusSmaller = vmCount - 1 - 1;
final Region<Object, Object> region = OutOfOffHeapMemoryDUnitTest.cache.get().getRegion(name);
for (int i = 0; countOtherMembers > countOtherMembersMinusSmaller; i++) {
region.put("key-" + i, new byte[1024]);
countOtherMembers = ((DistributedRegion) OutOfOffHeapMemoryDUnitTest.cache.get().getRegion(name)).getDistributionAdvisor().getNumProfiles();
assertTrue("puts failed to push member out of off-heap memory within time limit", stopWatch.elapsedTimeMillis() < TIME_LIMIT);
}
assertEquals("Member did not depart from OutOfOffHeapMemory", countOtherMembersMinusSmaller, countOtherMembers);
}
});
// verify that member with OOOHME closed
Host.getHost(0).getVM(smallerVM).invoke(new SerializableRunnable() {
public void run() {
assertTrue(OutOfOffHeapMemoryDUnitTest.cache.get().isClosed());
assertFalse(OutOfOffHeapMemoryDUnitTest.system.get().isConnected());
}
});
// verify that all other members noticed smaller member closed
for (int i = 0; i < vmCount; i++) {
if (i == smallerVM) {
continue;
}
Host.getHost(0).getVM(i).invoke(new SerializableRunnable() {
public void run() {
// +1 for locator, -1 for OOOHME
final int countMembersPlusLocator = vmCount + 1 - 1;
// member
// -1 for self, -1 for OOOHME member
final int countOtherMembers = vmCount - 1 - 1;
with().pollInterval(10, TimeUnit.MILLISECONDS).await().atMost(30, TimeUnit.SECONDS).until(numDistributionManagers(), equalTo(countMembersPlusLocator));
with().pollInterval(10, TimeUnit.MILLISECONDS).await().atMost(30, TimeUnit.SECONDS).until(numProfiles(), equalTo(countOtherMembers));
}
private Callable<Integer> numProfiles() {
return () -> {
DistributedRegion dr = (DistributedRegion) OutOfOffHeapMemoryDUnitTest.cache.get().getRegion(name);
return dr.getDistributionAdvisor().getNumProfiles();
};
}
private Callable<Integer> numDistributionManagers() {
return () -> {
InternalDistributedSystem ids = (InternalDistributedSystem) OutOfOffHeapMemoryDUnitTest.system.get();
return ids.getDistributionManager().getDistributionManagerIds().size();
};
}
});
}
}
Aggregations