use of org.apache.geode.cache.query.internal.CqStateImpl in project geode by apache.
the class CqQueryDUnitTest method waitForCqState.
/**
* Waits till the CQ state is same as the expected. Waits for max time, if the CQ state is not
* same as expected throws exception.
*/
public void waitForCqState(VM vm, final String cqName, final int state) {
vm.invoke(new CacheSerializableRunnable("Wait For cq State") {
public void run2() throws CacheException {
// 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);
}
// Get CQ State.
final CqStateImpl cqState = (CqStateImpl) cQuery.getState();
// Wait max time, till the CQ state is as expected.
WaitCriterion ev = new WaitCriterion() {
public boolean done() {
return cqState.getState() == state;
}
public String description() {
return "cqState never became " + state;
}
};
Wait.waitForCriterion(ev, MAX_TIME, 200, true);
}
});
}
use of org.apache.geode.cache.query.internal.CqStateImpl in project geode by apache.
the class FilterProfile method processRegisterCq.
/**
* adds a new CQ to this profile during a delta operation or deserialization
*
* @param serverCqName the query objects' name
* @param ServerCQ the new query object
* @param addToCqMap whether to add the query to this.cqs
*/
void processRegisterCq(String serverCqName, ServerCQ ServerCQ, boolean addToCqMap) {
ServerCQ cq = (ServerCQ) ServerCQ;
try {
CqService cqService = GemFireCacheImpl.getInstance().getCqService();
cqService.start();
cq.setCqService(cqService);
CqStateImpl cqState = (CqStateImpl) cq.getState();
cq.setName(generateCqName(serverCqName));
cq.registerCq(null, null, cqState.getState());
} catch (Exception ex) {
// Change it to Info level.
if (logger.isDebugEnabled()) {
logger.debug("Error while initializing the CQs with FilterProfile for CQ {}, Error : {}", serverCqName, ex.getMessage(), ex);
}
}
if (logger.isDebugEnabled()) {
logger.debug("Adding CQ to remote members FilterProfile using name: {}", serverCqName);
}
if (addToCqMap) {
this.cqs.put(serverCqName, cq);
}
// region is not set on the FilterProfile created for the peer nodes.
if (cq.getCqBaseRegion() != null) {
FilterProfile pf = cq.getCqBaseRegion().getFilterProfile();
if (pf != null) {
pf.incCqCount();
}
}
}
use of org.apache.geode.cache.query.internal.CqStateImpl in project geode by apache.
the class FilterProfile method processSetCqState.
public void processSetCqState(String serverCqName, ServerCQ ServerCQ) {
ServerCQ cq = (ServerCQ) this.cqs.get(serverCqName);
if (cq != null) {
CqStateImpl cqState = (CqStateImpl) ServerCQ.getState();
cq.setCqState(cqState.getState());
}
}
Aggregations