use of org.apache.geode.cache.CacheException in project geode by apache.
the class PutAllCSDUnitTest method testRAVersionsOnClientsWithNotificationsOnly.
/**
* basically same test as testVersionsOnClientsWithNotificationsOnly but also do a removeAll
*/
// GEODE-1419
@Category(FlakyTest.class)
@Test
public void testRAVersionsOnClientsWithNotificationsOnly() {
final String title = "testRAVersionsInClients";
disconnectAllFromDS();
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
VM client1 = host.getVM(2);
VM client2 = host.getVM(3);
final String regionName = getUniqueName();
final String serverHost = NetworkUtils.getServerHostName(server1.getHost());
// set notifyBySubscription=true to test register interest
final int serverPort1 = createBridgeServer(server1, regionName, 0, true, 0, null);
final int serverPort2 = createBridgeServer(server2, regionName, 0, true, 0, null);
// set queueRedundency=1
createBridgeClient(client1, regionName, serverHost, new int[] { serverPort1 }, 0, 59000, true);
createBridgeClient(client2, regionName, serverHost, new int[] { serverPort2 }, 0, 59000, true);
server1.invoke(addExceptionTag1(expectedExceptions));
server2.invoke(addExceptionTag1(expectedExceptions));
client1.invoke(addExceptionTag1(expectedExceptions));
client2.invoke(addExceptionTag1(expectedExceptions));
client1.invoke(new CacheSerializableRunnable(title + "client1 putAll+removeAll") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
doPutAll(regionName, "key-", numberOfEntries * 2);
assertEquals(numberOfEntries * 2, region.size());
doRemoveAll(regionName, "key-", numberOfEntries);
assertEquals(numberOfEntries, region.size());
}
});
client2.invoke(new CacheSerializableRunnable(title + "client2 versions collection") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
region.registerInterest("ALL_KEYS");
assertEquals(numberOfEntries, region.size());
LogWriterUtils.getLogWriter().info("client2 registerInterest ALL_KEYS at " + region.getFullPath());
}
});
client1RAVersions = (List<VersionTag>) client1.invoke(new SerializableCallable(title + "client1 versions collection") {
@Override
public Object call() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
assertEquals(numberOfEntries, region.size());
List<VersionTag> versions = new ArrayList<VersionTag>(numberOfEntries * 2);
RegionMap entries = ((LocalRegion) region).entries;
assertEquals(numberOfEntries * 2, entries.size());
for (Object key : entries.keySet()) {
RegionEntry internalRegionEntry = entries.getEntry(key);
VersionTag tag = internalRegionEntry.getVersionStamp().asVersionTag();
LogWriterUtils.getLogWriter().info("Entry version tag on client for " + key + ": " + tag);
versions.add(tag);
}
return versions;
}
});
client2RAVersions = (List<VersionTag>) client2.invoke(new SerializableCallable(title + "client2 versions collection") {
@Override
public Object call() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
assertEquals(numberOfEntries, region.size());
List<VersionTag> versions = new ArrayList<VersionTag>(numberOfEntries * 2);
RegionMap entries = ((LocalRegion) region).entries;
assertEquals(numberOfEntries * 2, entries.size());
for (Object key : entries.keySet()) {
RegionEntry internalRegionEntry = entries.getEntry(key);
VersionTag tag = internalRegionEntry.getVersionStamp().asVersionTag();
LogWriterUtils.getLogWriter().info("Entry version tag on client for " + key + ": " + tag);
versions.add(tag);
}
return versions;
}
});
assertEquals(numberOfEntries * 2, client1RAVersions.size());
LogWriterUtils.getLogWriter().info(Arrays.toString(client1RAVersions.toArray()));
LogWriterUtils.getLogWriter().info(Arrays.toString(client2RAVersions.toArray()));
for (VersionTag tag : client1RAVersions) {
if (!client2RAVersions.contains(tag)) {
fail("client 2 does not have the tag contained in client 1" + tag);
}
}
}
use of org.apache.geode.cache.CacheException in project geode by apache.
the class QueryMonitorDUnitTest method testQueryExecutionLocallyAndCacheOp.
/**
* Tests query execution on local vm.
*/
@Test
public void testQueryExecutionLocallyAndCacheOp() throws Exception {
setup(2);
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
final int numberOfEntries = 1000;
// Start server
// All
server1.invoke("Create BridgeServer", () -> configServer(20, "testQueryExecutionLocally"));
// the
// queries
// taking
// more
// than
// 20ms
// should
// be
// canceled
// by
// Query
// monitor.
server1.invoke("createRegion", () -> createRegion());
// All
server2.invoke("Create BridgeServer", () -> configServer(20, "testQueryExecutionLocally"));
// the
// queries
// taking
// more
// than
// 20ms
// should
// be
// canceled
// by
// Query
// monitor.
server2.invoke("createRegion", () -> createRegion());
// Initialize server regions.
server1.invoke("populatePortfolioRegions", () -> populatePortfolioRegions(numberOfEntries));
// Initialize server regions.
server2.invoke("populatePortfolioRegions", () -> populatePortfolioRegions(numberOfEntries));
// Execute server queries
SerializableRunnable executeQuery = new CacheSerializableRunnable("Execute queries") {
public void run2() throws CacheException {
try {
QueryService queryService = GemFireCacheImpl.getInstance().getQueryService();
String qStr = "SELECT DISTINCT * FROM /root/exampleRegion p, (SELECT DISTINCT pos FROM /root/exampleRegion x, x.positions.values pos" + " WHERE x.ID = p.ID) as itrX";
executeQuery(queryService, qStr);
// Create index and Perform cache op. Bug#44307
queryService.createIndex("idIndex", IndexType.FUNCTIONAL, "ID", "/root/exampleRegion");
queryService.createIndex("statusIndex", IndexType.FUNCTIONAL, "status", "/root/exampleRegion");
Region exampleRegion = getRootRegion().getSubregion(exampleRegionName);
for (int i = (1 + 100); i <= (numberOfEntries + 200); i++) {
exampleRegion.put("" + i, new Portfolio(i));
}
} catch (Exception ex) {
Assert.fail("Exception creating the query service", ex);
}
}
};
server1.invoke(executeQuery);
server2.invoke(executeQuery);
stopServer(server1);
stopServer(server2);
}
use of org.apache.geode.cache.CacheException in project geode by apache.
the class QueryMonitorDUnitTest method testQueryMonitorRegionWithEviction.
/**
* Tests query execution from client to server (multiple server) with eviction to disk.
*/
@Ignore("TODO:BUG46770WORKAROUND: test is disabled")
@Test
public void testQueryMonitorRegionWithEviction() throws CacheException {
final Host host = Host.getHost(0);
VM server1 = host.getVM(0);
VM server2 = host.getVM(1);
VM client1 = host.getVM(2);
VM client2 = host.getVM(3);
final int numberOfEntries = 100;
String serverHostName = NetworkUtils.getServerHostName(host);
// Start server
int serverPort1 = server1.invoke("Create BridgeServer", // All the queries taking more
() -> configServer(20, "testQueryMonitorRegionWithEviction"));
// than 20ms should be
// canceled by Query monitor.
server1.invoke("createRegion", () -> createRegion(true, "server1_testQueryMonitorRegionWithEviction"));
int serverPort2 = server2.invoke("Create BridgeServer", // All the queries taking more
() -> configServer(20, "testQueryMonitorRegionWithEviction"));
// than 20ms should be
// canceled by Query monitor.
server2.invoke("createRegion", () -> createRegion(true, "server2_testQueryMonitorRegionWithEviction"));
// Initialize server regions.
server1.invoke(new CacheSerializableRunnable("Create Bridge Server") {
public void run2() throws CacheException {
bulkInsertPorfolio(101, numberOfEntries);
}
});
// Initialize server regions.
server2.invoke(new CacheSerializableRunnable("Create Bridge Server") {
public void run2() throws CacheException {
bulkInsertPorfolio((numberOfEntries + 100), (numberOfEntries + numberOfEntries + 100));
}
});
// Initialize Client1 and create client regions.
client1.invoke("Init client", () -> configClient(serverHostName, serverPort1));
client1.invoke("createRegion", () -> createRegion());
// Initialize Client2 and create client regions.
client2.invoke("Init client", () -> configClient(serverHostName, serverPort2));
client2.invoke("createRegion", () -> createRegion());
// Execute client queries
client1.invoke("Execute Queries", () -> executeQueriesFromClient(20));
client2.invoke("Execute Queries", () -> executeQueriesFromClient(20));
stopServer(server1);
stopServer(server2);
}
use of org.apache.geode.cache.CacheException in project geode by apache.
the class QueryIndexUpdateRIDUnitTest method getSRRegisterInterestList.
private SerializableRunnable getSRRegisterInterestList(final String regionName, final int keySize, final int policy, final int start) {
SerializableRunnable sr = new CacheSerializableRunnable("Register InterestList") {
public void run2() throws CacheException {
// Get Query Service.
Region region = null;
try {
if ("root".equals(regionName)) {
region = getRootRegion();
} else {
region = getRootRegion().getSubregion(regionName);
}
region.getAttributesMutator().setCacheListener(new CertifiableTestCacheListener(LogWriterUtils.getLogWriter()));
} catch (Exception cqe) {
AssertionError err = new AssertionError("Failed to get Region.");
err.initCause(cqe);
throw err;
}
try {
switch(policy) {
case REGEX:
region.registerInterestRegex(REGULAR_EXPRESSION);
break;
case KEYS:
List list = new ArrayList();
for (int i = start != 0 ? start : 1; i <= keySize; i++) {
list.add(KEY + i);
}
region.registerInterest(list);
break;
default:
region.registerInterest("ALL_KEYS");
}
} catch (Exception ex) {
AssertionError err = new AssertionError("Failed to Register InterestList");
err.initCause(ex);
throw err;
}
}
};
return sr;
}
use of org.apache.geode.cache.CacheException in project geode by apache.
the class QueryIndexUpdateRIDUnitTest method createClient.
/* Create Client */
public void createClient(VM client, final int[] serverPorts, final String serverHost, final String redundancyLevel, final String poolName) {
SerializableRunnable createQService = new CacheSerializableRunnable("Create Client") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Create Client. ###");
// Initialize CQ Service.
try {
getCache().getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
AttributesFactory regionFactory = new AttributesFactory();
regionFactory.setScope(Scope.LOCAL);
if (poolName != null) {
regionFactory.setPoolName(poolName);
} else {
if (redundancyLevel != null) {
ClientServerTestCase.configureConnectionPool(regionFactory, serverHost, serverPorts, true, Integer.parseInt(redundancyLevel), -1, null);
} else {
ClientServerTestCase.configureConnectionPool(regionFactory, serverHost, serverPorts, true, -1, -1, null);
}
}
createRootRegion(regionFactory.createRegionAttributes());
LogWriterUtils.getLogWriter().info("### Successfully Created Root Region on Client");
}
};
client.invoke(createQService);
}
Aggregations