use of org.apache.geode.cache.query.CqQuery in project geode by apache.
the class CqQueryDUnitTest method waitForCqsConnected.
protected void waitForCqsConnected(VM vm, final String cqName, final int count) {
vm.invoke(new CacheSerializableRunnable("validate cq connected count") {
public void run2() throws CacheException {
QueryService cqService = null;
try {
cqService = getCache().getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
CqQuery cQuery = cqService.getCq(cqName);
if (cQuery == null) {
fail("Failed to get CqQuery for CQ : " + cqName);
}
CqAttributes cqAttr = cQuery.getCqAttributes();
CqListener[] cqListener = cqAttr.getCqListeners();
CqQueryTestListener listener = (CqQueryTestListener) cqListener[0];
listener.waitForCqsConnectedEvents(count);
}
});
}
use of org.apache.geode.cache.query.CqQuery in project geode by apache.
the class CqQueryDUnitTest method stopCQ.
/* Stop/pause CQ */
public void stopCQ(VM vm, final String cqName) throws Exception {
vm.invoke(new CacheSerializableRunnable("Stop CQ :" + cqName) {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Stop CQ. ###" + cqName);
// Get CQ Service.
QueryService cqService = null;
try {
cqService = getCache().getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
// Stop CQ.
CqQuery cq1 = null;
try {
cq1 = cqService.getCq(cqName);
cq1.stop();
} catch (Exception ex) {
ex.printStackTrace();
fail("Failed to stop CQ " + cqName + " . " + ex.getMessage());
}
assertTrue("Stop CQ state mismatch", cq1.getState().isStopped());
}
});
}
use of org.apache.geode.cache.query.CqQuery in project geode by apache.
the class CqQueryDUnitTest method validateCQError.
private void validateCQError(VM vm, final String cqName, final int numError) {
vm.invoke(new CacheSerializableRunnable("Validate CQs") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Validating CQ. ### " + cqName);
// Get CQ Service.
QueryService cqService = null;
try {
cqService = getCache().getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
CqQuery cQuery = cqService.getCq(cqName);
if (cQuery == null) {
fail("Failed to get CqQuery for CQ : " + cqName);
}
CqAttributes cqAttr = cQuery.getCqAttributes();
CqListener cqListener = cqAttr.getCqListener();
CqQueryTestListener listener = (CqQueryTestListener) cqListener;
listener.printInfo(false);
// Check for totalEvents count.
if (numError != noTest) {
// Result size validation.
listener.printInfo(true);
assertEquals("Total Event Count mismatch", numError, listener.getErrorEventCount());
}
}
});
}
use of org.apache.geode.cache.query.CqQuery in project geode by apache.
the class CqQueryDUnitTest method failIfCQExists.
/**
* Throws AssertionError if the CQ can be found or if any other error occurs
*/
private void failIfCQExists(VM vm, final String cqName) {
vm.invoke(new CacheSerializableRunnable("Fail if CQ exists") {
public void run2() throws CacheException {
LogWriterUtils.getLogWriter().info("### Fail if CQ Exists. ### " + cqName);
// Get CQ Service.
QueryService cqService = null;
try {
cqService = getCache().getQueryService();
} catch (Exception cqe) {
cqe.printStackTrace();
fail("Failed to getCQService.");
}
CqQuery cQuery = cqService.getCq(cqName);
if (cQuery != null) {
fail("Unexpectedly found CqQuery for CQ : " + cqName);
}
}
});
}
use of org.apache.geode.cache.query.CqQuery in project geode by apache.
the class CqQueryDUnitTest method ensureCQExists.
private void ensureCQExists(VM server, final String regionName, final String cqName) {
SerializableRunnable task = new CacheSerializableRunnable("check CQs") {
public void run2() throws CacheException {
CqQuery[] queries = getCache().getQueryService().getCqs();
assertTrue("expected to find a CQ but found none", queries.length > 0);
System.out.println("found query " + queries[0]);
assertTrue("Couldn't find query " + cqName, queries[0].getName().startsWith(cqName));
assertTrue("expected the CQ to be open: " + queries[0], !queries[0].isClosed());
}
};
server.invoke(task);
}
Aggregations