use of org.apache.geode.cache30.CacheSerializableRunnable 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.cache30.CacheSerializableRunnable in project geode by apache.
the class QueryMonitorDUnitTest method validateQueryMonitorThreadCnt.
private void validateQueryMonitorThreadCnt(VM vm, final int threadCount, final int waitTime) {
SerializableRunnable validateThreadCnt = new CacheSerializableRunnable("validateQueryMonitorThreadCnt") {
public void run2() throws CacheException {
Cache cache = getCache();
QueryMonitor qm = ((GemFireCacheImpl) cache).getQueryMonitor();
if (qm == null) {
fail("Didn't found query monitor.");
}
int waited = 0;
while (true) {
if (qm.getQueryMonitorThreadCount() != threadCount) {
if (waited <= waitTime) {
Wait.pause(10);
waited += 10;
continue;
} else {
fail("Didn't found expected monitoring thread. Expected: " + threadCount + " found :" + qm.getQueryMonitorThreadCount());
}
}
break;
}
// ((GemFireCache)cache).testMaxQueryExecutionTime = queryMonitorTime;
}
};
vm.invoke(validateThreadCnt);
}
use of org.apache.geode.cache30.CacheSerializableRunnable in project geode by apache.
the class QueryIndexUpdateRIDUnitTest method getSRClearRegion.
private SerializableRunnable getSRClearRegion(final String regionName) {
SerializableRunnable sr = new CacheSerializableRunnable("Destroy entries") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Clearing Region. ###");
Region region1;
if (!"root".equals(regionName)) {
region1 = getRootRegion().getSubregion(regionName);
} else {
region1 = getRootRegion();
}
region1.clear();
LogWriterUtils.getLogWriter().info("### Number of Entries in Region :" + region1.keySet().size());
}
};
return sr;
}
use of org.apache.geode.cache30.CacheSerializableRunnable 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.cache30.CacheSerializableRunnable 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