use of org.apache.geode.cache.query.CqExistsException in project geode by apache.
the class PutAllCSDUnitTest method testOneServer.
/**
* Tests putAll to one server.
*/
@Test
public void testOneServer() throws CacheException, InterruptedException {
final String title = "testOneServer:";
final Host host = Host.getHost(0);
VM server = host.getVM(0);
VM client1 = host.getVM(2);
VM client2 = host.getVM(3);
final String regionName = getUniqueName();
final String serverHost = NetworkUtils.getServerHostName(server.getHost());
// set <false, true> means <PR=false, notifyBySubscription=true> to enable registerInterest and
// CQ
final int serverPort = createBridgeServer(server, regionName, 0, false, 0, null);
createClient(client1, regionName, serverHost, new int[] { serverPort }, -1, -1, false, true, true);
createClient(client2, regionName, serverHost, new int[] { serverPort }, -1, -1, false, true, true);
server.invoke(new CacheSerializableRunnable(title + "server add listener") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
region.getAttributesMutator().addCacheListener(new MyListener(false));
}
});
client2.invoke(new CacheSerializableRunnable(title + "client2 registerInterest and add listener") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
region.getAttributesMutator().addCacheListener(new MyListener(false));
// registerInterest for ALL_KEYS
region.registerInterest("ALL_KEYS");
LogWriterUtils.getLogWriter().info("client2 registerInterest ALL_KEYS at " + region.getFullPath());
}
});
client1.invoke(new CacheSerializableRunnable(title + "client1 create local region and run putAll") {
@Override
public void run2() throws CacheException {
AttributesFactory factory2 = new AttributesFactory();
factory2.setScope(Scope.LOCAL);
factory2.addCacheListener(new MyListener(false));
createRegion("localsave", factory2.create());
Region region = doPutAll(regionName, "key-", numberOfEntries);
assertEquals(numberOfEntries, region.size());
}
});
AsyncInvocation async1 = client1.invokeAsync(new CacheSerializableRunnable(title + "client1 create CQ") {
@Override
public void run2() throws CacheException {
// create a CQ for key 10-20
Region localregion = getRootRegion().getSubregion("localsave");
CqAttributesFactory cqf1 = new CqAttributesFactory();
EOCQEventListener EOCQListener = new EOCQEventListener(localregion);
cqf1.addCqListener(EOCQListener);
CqAttributes cqa1 = cqf1.create();
String cqName1 = "EOInfoTracker";
String queryStr1 = "SELECT ALL * FROM /root/" + regionName + " ii WHERE ii.getTicker() >= '10' and ii.getTicker() < '20'";
LogWriterUtils.getLogWriter().info("Query String: " + queryStr1);
try {
QueryService cqService = getCache().getQueryService();
CqQuery EOTracker = cqService.newCq(cqName1, queryStr1, cqa1);
SelectResults rs1 = EOTracker.executeWithInitialResults();
List list1 = rs1.asList();
for (int i = 0; i < list1.size(); i++) {
Struct s = (Struct) list1.get(i);
TestObject o = (TestObject) s.get("value");
LogWriterUtils.getLogWriter().info("InitialResult:" + i + ":" + o);
localregion.put("key-" + i, o);
}
if (localregion.size() > 0) {
LogWriterUtils.getLogWriter().info("CQ is ready");
synchronized (lockObject) {
lockObject.notify();
}
}
waitTillNotify(lockObject2, 20000, (EOCQListener.num_creates == 5 && EOCQListener.num_updates == 5));
EOTracker.close();
} catch (CqClosedException e) {
Assert.fail("CQ", e);
} catch (RegionNotFoundException e) {
Assert.fail("CQ", e);
} catch (QueryInvalidException e) {
Assert.fail("CQ", e);
} catch (CqExistsException e) {
Assert.fail("CQ", e);
} catch (CqException e) {
Assert.fail("CQ", e);
}
}
});
server.invoke(new CacheSerializableRunnable(title + "verify Bridge Server") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
assertEquals(numberOfEntries, region.size());
for (int i = 0; i < numberOfEntries; i++) {
TestObject obj = (TestObject) region.getEntry("key-" + i).getValue();
assertEquals(i, obj.getPrice());
}
}
});
// verify CQ is ready
client1.invoke(new CacheSerializableRunnable(title + "verify CQ is ready") {
@Override
public void run2() throws CacheException {
Region localregion = getRootRegion().getSubregion("localsave");
waitTillNotify(lockObject, 10000, (localregion.size() > 0));
assertTrue(localregion.size() > 0);
}
});
// verify registerInterest result at client2
client2.invoke(new CacheSerializableRunnable(title + "verify client2") {
@Override
public void run2() throws CacheException {
final Region region = getRootRegion().getSubregion(regionName);
checkRegionSize(region, numberOfEntries);
for (int i = 0; i < numberOfEntries; i++) {
TestObject obj = (TestObject) region.getEntry("key-" + i).getValue();
assertEquals(i, obj.getPrice());
}
// then do update for key 10-20 to trigger CQ at server2
// destroy key 10-14 to simulate create/update mix case
region.removeAll(Arrays.asList("key-10", "key-11", "key-12", "key-13", "key-14"), "removeAllCallback");
assertEquals(null, region.get("key-10"));
assertEquals(null, region.get("key-11"));
assertEquals(null, region.get("key-12"));
assertEquals(null, region.get("key-13"));
assertEquals(null, region.get("key-14"));
}
});
// verify CQ result at client1
client1.invoke(new CacheSerializableRunnable(title + "Verify client1") {
@Override
public void run2() throws CacheException {
Region localregion = getRootRegion().getSubregion("localsave");
for (int i = 10; i < 15; i++) {
TestObject obj = null;
int cnt = 0;
while (cnt < 100) {
obj = (TestObject) localregion.get("key-" + i);
if (obj != null) {
// wait for the key to be destroyed
Wait.pause(100);
if (LogWriterUtils.getLogWriter().fineEnabled()) {
LogWriterUtils.getLogWriter().info("Waiting 100ms(" + cnt + ") for key-" + i + " to be destroyed");
}
cnt++;
} else {
break;
}
}
}
}
});
client2.invoke(new CacheSerializableRunnable(title + "verify client2") {
@Override
public void run2() throws CacheException {
final Region region = getRootRegion().getSubregion(regionName);
LinkedHashMap map = new LinkedHashMap();
for (int i = 10; i < 20; i++) {
map.put("key-" + i, new TestObject(i * 10));
}
region.putAll(map, "putAllCallback");
}
});
// verify CQ result at client1
client1.invoke(new CacheSerializableRunnable(title + "Verify client1") {
@Override
public void run2() throws CacheException {
Region localregion = getRootRegion().getSubregion("localsave");
for (int i = 10; i < 20; i++) {
TestObject obj = null;
int cnt = 0;
while (cnt < 100) {
obj = (TestObject) localregion.get("key-" + i);
if (obj == null || obj.getPrice() != i * 10) {
Wait.pause(100);
LogWriterUtils.getLogWriter().info("Waiting 100ms(" + cnt + ") for obj.getPrice() == i*10 at entry " + i);
cnt++;
} else {
break;
}
}
assertEquals(i * 10, obj.getPrice());
}
synchronized (lockObject2) {
lockObject2.notify();
}
}
});
ThreadUtils.join(async1, 30 * 1000);
// verify stats for client putAll into distributed region
// 1. verify client staus
/*
* server2.invoke(new CacheSerializableRunnable("server2 execute putAll") { public void run2()
* throws CacheException { try { DistributedSystemConfig config =
* AdminDistributedSystemFactory.defineDistributedSystem(system, null); AdminDistributedSystem
* ads = AdminDistributedSystemFactory.getDistributedSystem(config); ads.connect();
* DistributedMember distributedMember = system.getDistributedMember(); SystemMember member =
* ads.lookupSystemMember(distributedMember);
*
* StatisticResource[] resources = member.getStats(); for (int i=0; i<resources.length; i++) {
* System.out.println("GGG:"+resources[i].getType()); if
* (resources[i].getType().equals("CacheServerClientStats")) { Statistic[] stats =
* resources[i].getStatistics(); for (int j=0; i<stats.length; i++) { if
* (stats[j].getName().equals("putAll")) {
* System.out.println("GGG:"+stats[j].getName()+":"+stats[j].getValue()); } else if
* (stats[j].getName().equals("sendPutAllTime")) {
* System.out.println("GGG:"+stats[j].getName()+":"+stats[j].getValue()); } } } } } catch
* (AdminException e) { fail("Failed while creating AdminDS", e); } } });
*/
// Test Exception handling
// verify CQ is ready
client1.invoke(new CacheSerializableRunnable(title + "test exception handling") {
@Override
public void run2() throws CacheException {
Region region = getRootRegion().getSubregion(regionName);
Map m = null;
boolean NPEthrowed = false;
try {
region.putAll(m, "putAllCallback");
fail("Should have thrown NullPointerException");
} catch (NullPointerException ex) {
NPEthrowed = true;
}
assertTrue(NPEthrowed);
region.localDestroyRegion();
boolean RDEthrowed = false;
try {
m = new HashMap();
for (int i = 1; i < 21; i++) {
m.put(new Integer(i), Integer.toString(i));
}
region.putAll(m, "putAllCallback");
fail("Should have thrown RegionDestroyedException");
} catch (RegionDestroyedException ex) {
RDEthrowed = true;
}
assertTrue(RDEthrowed);
try {
region.removeAll(Arrays.asList("key-10", "key-11"), "removeAllCallback");
fail("Should have thrown RegionDestroyedException");
} catch (RegionDestroyedException expected) {
}
}
});
// Stop server
stopBridgeServers(getCache());
}
use of org.apache.geode.cache.query.CqExistsException in project geode by apache.
the class ServerCQImpl method registerCq.
@Override
public void registerCq(ClientProxyMembershipID p_clientProxyId, CacheClientNotifier p_ccn, int p_cqState) throws CqException, RegionNotFoundException {
CacheClientProxy clientProxy = null;
this.clientProxyId = p_clientProxyId;
if (p_ccn != null) {
this.ccn = p_ccn;
clientProxy = p_ccn.getClientProxy(p_clientProxyId, true);
}
validateCq();
final boolean isDebugEnabled = logger.isDebugEnabled();
StringId msg = LocalizedStrings.ONE_ARG;
Throwable t = null;
try {
this.query = constructServerSideQuery();
if (isDebugEnabled) {
logger.debug("Server side query for the cq: {} is: {}", cqName, this.query.getQueryString());
}
} catch (Exception ex) {
t = ex;
if (ex instanceof ClassNotFoundException) {
msg = LocalizedStrings.CqQueryImpl_CLASS_NOT_FOUND_EXCEPTION_THE_ANTLRJAR_OR_THE_SPCIFIED_CLASS_MAY_BE_MISSING_FROM_SERVER_SIDE_CLASSPATH_ERROR_0;
} else {
msg = LocalizedStrings.CqQueryImpl_ERROR_WHILE_PARSING_THE_QUERY_ERROR_0;
}
} finally {
if (t != null) {
String s = msg.toLocalizedString(t);
if (isDebugEnabled) {
logger.debug(s, t);
}
throw new CqException(s);
}
}
// Update Regions Book keeping.
// TODO replace getRegion() with getRegionByPathForProcessing() so this doesn't block
// if the region is still being initialized
this.cqBaseRegion = (LocalRegion) cqService.getCache().getRegion(regionName);
if (this.cqBaseRegion == null) {
throw new RegionNotFoundException(LocalizedStrings.CqQueryImpl_REGION__0_SPECIFIED_WITH_CQ_NOT_FOUND_CQNAME_1.toLocalizedString(new Object[] { regionName, this.cqName }));
}
// Make sure that the region is partitioned or
// replicated with distributed ack or global.
DataPolicy dp = this.cqBaseRegion.getDataPolicy();
this.isPR = dp.withPartitioning();
if (!(this.isPR || dp.withReplication())) {
String errMsg = null;
// replicated regions with eviction set to local destroy get turned into preloaded
if (dp.withPreloaded() && cqBaseRegion.getAttributes().getEvictionAttributes() != null && cqBaseRegion.getAttributes().getEvictionAttributes().getAction().equals(EvictionAction.LOCAL_DESTROY)) {
errMsg = LocalizedStrings.CqQueryImpl_CQ_NOT_SUPPORTED_FOR_REPLICATE_WITH_LOCAL_DESTROY.toString(this.regionName, cqBaseRegion.getAttributes().getEvictionAttributes().getAction());
} else {
errMsg = "The region " + this.regionName + " specified in CQ creation is neither replicated nor partitioned; " + "only replicated or partitioned regions are allowed in CQ creation.";
}
if (isDebugEnabled) {
logger.debug(errMsg);
}
throw new CqException(errMsg);
}
if ((dp.withReplication() && (!(cqBaseRegion.getAttributes().getScope().isDistributedAck() || cqBaseRegion.getAttributes().getScope().isGlobal())))) {
String errMsg = "The replicated region " + this.regionName + " specified in CQ creation does not have scope supported by CQ." + " The CQ supported scopes are DISTRIBUTED_ACK and GLOBAL.";
if (isDebugEnabled) {
logger.debug(errMsg);
}
throw new CqException(errMsg);
}
// Can be null by the time we are here
if (clientProxy != null) {
clientProxy.incCqCount();
if (clientProxy.hasOneCq()) {
cqService.stats().incClientsWithCqs();
}
if (isDebugEnabled) {
logger.debug("Added CQ to the base region: {} With key as: {}", cqBaseRegion.getFullPath(), serverCqName);
}
}
this.updateCqCreateStats();
// Initialize the state of CQ.
if (this.cqState.getState() != p_cqState) {
setCqState(p_cqState);
}
// it to other matching cqs for performance reasons
if (p_cqState == CqStateImpl.RUNNING) {
// Add to the matchedCqMap.
cqService.addToMatchingCqMap(this);
}
// Initialize CQ results (key) cache.
if (CqServiceProvider.MAINTAIN_KEYS) {
this.cqResultKeys = new HashMap<Object, Object>();
// added to the results cache (not from the CQ Results).
if (this.isPR) {
this.setCqResultsCacheInitialized();
} else {
this.destroysWhileCqResultsInProgress = new HashSet<Object>();
}
}
if (p_ccn != null) {
try {
cqService.addToCqMap(this);
} catch (CqExistsException cqe) {
// Should not happen.
throw new CqException(LocalizedStrings.CqQueryImpl_UNABLE_TO_CREATE_CQ_0_ERROR__1.toLocalizedString(new Object[] { cqName, cqe.getMessage() }));
}
this.cqBaseRegion.getFilterProfile().registerCq(this);
}
}
use of org.apache.geode.cache.query.CqExistsException in project geode by apache.
the class CqDataUsingPoolDUnitTest method testGetDurableCqsFromServerCycleClientsAndMoreCqs.
@Test
public void testGetDurableCqsFromServerCycleClientsAndMoreCqs() {
final String regionName = "testGetAllDurableCqsFromServerCycleClients";
final Host host = Host.getHost(0);
VM server = host.getVM(0);
VM client1 = host.getVM(1);
VM client2 = host.getVM(2);
int timeout = 60000;
// Start server 1
final int server1Port = ((Integer) server.invoke(() -> CacheServerTestUtil.createCacheServer(regionName, new Boolean(true)))).intValue();
// Start client 1
client1.invoke(() -> CacheServerTestUtil.createClientCache(getClientPool(NetworkUtils.getServerHostName(client1.getHost()), server1Port), regionName, getDurableClientProperties("client1_dc", timeout)));
// Start client 2
client2.invoke(() -> CacheServerTestUtil.createClientCache(getClientPool(NetworkUtils.getServerHostName(client2.getHost()), server1Port), regionName, getDurableClientProperties("client2_dc", timeout)));
// create the test cqs
createClient1CqsAndDurableCqs(client1, regionName);
createClient2CqsAndDurableCqs(client2, regionName);
cycleDurableClient(client1, "client1_dc", server1Port, regionName, timeout);
cycleDurableClient(client2, "client2_dc", server1Port, regionName, timeout);
client1.invoke(new CacheSerializableRunnable("Register more cq for client 1") {
@Override
public void run2() throws CacheException {
// register the cq's
QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
CqAttributesFactory cqAf = new CqAttributesFactory();
CqAttributes attributes = cqAf.create();
try {
queryService.newCq("client1MoreDCQ1", "Select * From /" + regionName + " where id = 1", attributes, true).execute();
queryService.newCq("client1MoreDCQ2", "Select * From /" + regionName + " where id = 10", attributes, true).execute();
queryService.newCq("client1MoreNoDC1", "Select * From /" + regionName, attributes, false).execute();
queryService.newCq("client1MoreNoDC2", "Select * From /" + regionName + " where id = 3", attributes, false).execute();
} catch (RegionNotFoundException e) {
fail("failed", e);
} catch (CqException e) {
fail("failed", e);
} catch (CqExistsException e) {
fail("failed", e);
}
}
});
client2.invoke(new CacheSerializableRunnable("Register more cq for client 2") {
@Override
public void run2() throws CacheException {
// register the cq's
QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
CqAttributesFactory cqAf = new CqAttributesFactory();
CqAttributes attributes = cqAf.create();
try {
queryService.newCq("client2MoreDCQ1", "Select * From /" + regionName + " where id = 1", attributes, true).execute();
queryService.newCq("client2MoreDCQ2", "Select * From /" + regionName + " where id = 10", attributes, true).execute();
queryService.newCq("client2MoreDCQ3", "Select * From /" + regionName, attributes, true).execute();
queryService.newCq("client2MoreDCQ4", "Select * From /" + regionName + " where id = 3", attributes, true).execute();
} catch (RegionNotFoundException e) {
fail("failed", e);
} catch (CqException e) {
fail("failed", e);
} catch (CqExistsException e) {
fail("failed", e);
}
}
});
// Cycle clients a second time
cycleDurableClient(client1, "client1_dc", server1Port, regionName, timeout);
cycleDurableClient(client2, "client2_dc", server1Port, regionName, timeout);
client2.invoke(new CacheSerializableRunnable("check durable cqs for client 2") {
@Override
public void run2() throws CacheException {
QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
List<String> list = null;
try {
list = queryService.getAllDurableCqsFromServer();
} catch (CqException e) {
fail("failed", e);
}
assertEquals(8, list.size());
assertTrue(list.contains("client2DCQ1"));
assertTrue(list.contains("client2DCQ2"));
assertTrue(list.contains("client2DCQ3"));
assertTrue(list.contains("client2DCQ4"));
assertTrue(list.contains("client2MoreDCQ1"));
assertTrue(list.contains("client2MoreDCQ2"));
assertTrue(list.contains("client2MoreDCQ3"));
assertTrue(list.contains("client2MoreDCQ4"));
}
});
client1.invoke(new CacheSerializableRunnable("check durable cqs for client 1") {
@Override
public void run2() throws CacheException {
QueryService queryService = CacheServerTestUtil.getCache().getQueryService();
List<String> list = null;
try {
list = queryService.getAllDurableCqsFromServer();
} catch (CqException e) {
fail("failed", e);
}
assertEquals(4, list.size());
assertTrue(list.contains("client1DCQ1"));
assertTrue(list.contains("client1DCQ2"));
assertTrue(list.contains("client1MoreDCQ1"));
assertTrue(list.contains("client1MoreDCQ2"));
}
});
client1.invoke(() -> CacheServerTestUtil.closeCache());
client2.invoke(() -> CacheServerTestUtil.closeCache());
server.invoke(() -> CacheServerTestUtil.closeCache());
}
use of org.apache.geode.cache.query.CqExistsException in project geode by apache.
the class CqServiceImpl method newCq.
@Override
public synchronized ClientCQ newCq(String cqName, String queryString, CqAttributes cqAttributes, InternalPool pool, boolean isDurable) throws QueryInvalidException, CqExistsException, CqException {
if (queryString == null) {
throw new IllegalArgumentException(LocalizedStrings.CqService_NULL_ARGUMENT_0.toLocalizedString("queryString"));
} else if (cqAttributes == null) {
throw new IllegalArgumentException(LocalizedStrings.CqService_NULL_ARGUMENT_0.toLocalizedString("cqAttribute"));
}
if (isServer()) {
throw new IllegalStateException(LocalizedStrings.CqService_CLIENT_SIDE_NEWCQ_METHOD_INVOCATION_ON_SERVER.toLocalizedString());
}
// Check if the given cq already exists.
if (cqName != null && isCqExists(cqName)) {
throw new CqExistsException(LocalizedStrings.CqService_CQ_WITH_THE_GIVEN_NAME_ALREADY_EXISTS_CQNAME_0.toLocalizedString(cqName));
}
ServerCQProxyImpl serverProxy = pool == null ? null : new ServerCQProxyImpl(pool);
ClientCQImpl cQuery = new ClientCQImpl(this, cqName, queryString, cqAttributes, serverProxy, isDurable);
cQuery.updateCqCreateStats();
// cQuery.initCq();
// Check if query is valid.
cQuery.validateCq();
// Check if Name needs to be generated.
if (cqName == null) {
// to be taken care internally.
while (true) {
cQuery.setName(generateCqName());
try {
addToCqMap(cQuery);
} catch (CqExistsException ex) {
if (logger.isDebugEnabled()) {
logger.debug("Got CqExistsException while intializing cq : {} Error : {}", cQuery.getName(), ex.getMessage());
}
continue;
}
break;
}
} else {
addToCqMap(cQuery);
}
this.addToBaseRegionToCqNameMap(cQuery.getBaseRegionName(), cQuery.getServerCqName());
return cQuery;
}
use of org.apache.geode.cache.query.CqExistsException in project geode by apache.
the class CqDataUsingPoolDUnitTest method testGetDurableCQsFromPoolOnly.
@Test
public void testGetDurableCQsFromPoolOnly() throws Exception {
final String regionName = "regionA";
final Host host = Host.getHost(0);
VM server = host.getVM(0);
VM client1 = host.getVM(1);
VM client2 = host.getVM(2);
/* Create Server and Client */
cqDUnitTest.createServer(server);
final int port = server.invoke(() -> CqQueryUsingPoolDUnitTest.getCacheServerPort());
final String host0 = NetworkUtils.getServerHostName(server.getHost());
final String poolName1 = "pool1";
final String poolName2 = "pool2";
cqDUnitTest.createPool(client1, poolName1, host0, port);
cqDUnitTest.createPool(client2, poolName2, host0, port);
client1.invoke(new CacheSerializableRunnable("Register cq for client 1") {
@Override
public void run2() throws CacheException {
QueryService queryService = null;
try {
queryService = (PoolManager.find(poolName1)).getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
try {
CqAttributesFactory cqAf = new CqAttributesFactory();
CqAttributes attributes = cqAf.create();
queryService.newCq("client1DCQ1", "Select * From /root/" + regionName + " where id = 1", attributes, true).execute();
queryService.newCq("client1DCQ2", "Select * From /root/" + regionName + " where id = 10", attributes, true).execute();
queryService.newCq("client1NoDC1", "Select * From /root/" + regionName, attributes, false).execute();
queryService.newCq("client1NoDC2", "Select * From /root/" + regionName + " where id = 3", attributes, false).execute();
} catch (CqException e) {
fail("failed", e);
} catch (CqExistsException e) {
fail("failed", e);
} catch (RegionNotFoundException e) {
fail("failed", e);
}
}
});
client2.invoke(new CacheSerializableRunnable("Register cq for client 2") {
@Override
public void run2() throws CacheException {
QueryService queryService = null;
try {
queryService = (PoolManager.find(poolName2)).getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
try {
CqAttributesFactory cqAf = new CqAttributesFactory();
CqAttributes attributes = cqAf.create();
queryService.newCq("client2DCQ1", "Select * From /root/" + regionName + " where id = 1", attributes, true).execute();
queryService.newCq("client2DCQ2", "Select * From /root/" + regionName + " where id = 10", attributes, true).execute();
queryService.newCq("client2DCQ3", "Select * From /root/" + regionName, attributes, true).execute();
queryService.newCq("client2DCQ4", "Select * From /root/" + regionName + " where id = 3", attributes, true).execute();
} catch (CqException e) {
fail("failed", e);
} catch (CqExistsException e) {
fail("failed", e);
} catch (RegionNotFoundException e) {
fail("failed", e);
}
}
});
client2.invoke(new CacheSerializableRunnable("test getDurableCQsFromServer for client2") {
@Override
public void run2() throws CacheException {
QueryService queryService = null;
try {
queryService = (PoolManager.find(poolName2)).getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
List<String> list = null;
try {
list = queryService.getAllDurableCqsFromServer();
} catch (CqException e) {
fail("failed", e);
}
assertEquals(4, list.size());
assertTrue(list.contains("client2DCQ1"));
assertTrue(list.contains("client2DCQ2"));
assertTrue(list.contains("client2DCQ3"));
assertTrue(list.contains("client2DCQ4"));
}
});
client1.invoke(new CacheSerializableRunnable("test getDurableCQsFromServer for client1") {
@Override
public void run2() throws CacheException {
QueryService queryService = null;
try {
queryService = (PoolManager.find(poolName1)).getQueryService();
} catch (Exception cqe) {
Assert.fail("Failed to getCQService.", cqe);
}
List<String> list = null;
try {
list = queryService.getAllDurableCqsFromServer();
} catch (CqException e) {
fail("failed", e);
}
assertEquals(2, list.size());
assertTrue(list.contains("client1DCQ1"));
assertTrue(list.contains("client1DCQ2"));
}
});
cqDUnitTest.closeClient(client2);
cqDUnitTest.closeClient(client1);
cqDUnitTest.closeServer(server);
}
Aggregations