use of org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager in project ignite by apache.
the class IgniteCacheQueryMultiThreadedSelfTest method testMultiThreadedScanQuery.
/**
* JUnit.
*
* @throws Exception If failed.
*/
@SuppressWarnings({ "TooBroadScope" })
public void testMultiThreadedScanQuery() throws Exception {
int threadCnt = 50;
final int keyCnt = 500;
final int logMod = 5000;
final Ignite g = grid(0);
// Put test values into cache.
final IgniteCache<Integer, Integer> c = cache(Integer.class, Integer.class);
for (int i = 0; i < keyCnt; i++) c.put(i, i);
final AtomicInteger cnt = new AtomicInteger();
final AtomicBoolean done = new AtomicBoolean();
IgniteInternalFuture<?> fut = multithreadedAsync(new CAX() {
@Override
public void applyx() throws IgniteCheckedException {
int iter = 0;
while (!done.get() && !Thread.currentThread().isInterrupted()) {
iter++;
// Scan query.
Collection<Cache.Entry<Integer, Integer>> entries = c.query(new ScanQuery<Integer, Integer>()).getAll();
assert entries != null;
assertEquals("Entries count is not as expected on iteration: " + iter, keyCnt, entries.size());
if (cnt.incrementAndGet() % logMod == 0) {
GridCacheQueryManager<Object, Object> qryMgr = ((IgniteKernal) g).internalCache(c.getName()).context().queries();
assert qryMgr != null;
qryMgr.printMemoryStats();
}
}
}
}, threadCnt);
Thread.sleep(DURATION);
done.set(true);
fut.get();
}
use of org.apache.ignite.internal.processors.cache.query.GridCacheQueryManager in project ignite by apache.
the class IgniteCacheQueryMultiThreadedSelfTest method testMultiThreadedSqlFieldsQuery.
/**
* SqlFieldsQuery paging mechanics stress test
*
* @throws Exception If failed.
*/
@SuppressWarnings({ "TooBroadScope" })
public void testMultiThreadedSqlFieldsQuery() throws Throwable {
int threadCnt = 16;
// set resultSet size bigger than page size
final int keyCnt = 1100;
final int logMod = 5000;
final Ignite g = grid(0);
// Put test values into cache.
final IgniteCache<Integer, TestValue> c = cache(Integer.class, TestValue.class);
for (int i = 0; i < keyCnt; i++) c.put(i, new TestValue(i));
final AtomicInteger cnt = new AtomicInteger();
final AtomicBoolean done = new AtomicBoolean();
IgniteInternalFuture<?> fut = multithreadedAsync(new CAX() {
@Override
public void applyx() throws IgniteCheckedException {
int iter = 0;
while (!done.get() && !Thread.currentThread().isInterrupted()) {
iter++;
List<List<?>> entries = c.query(new SqlFieldsQuery("SELECT * from TestValue").setPageSize(100)).getAll();
assert entries != null;
assertEquals("Entries count is not as expected on iteration: " + iter, keyCnt, entries.size());
if (cnt.incrementAndGet() % logMod == 0) {
GridCacheQueryManager<Object, Object> qryMgr = ((IgniteKernal) g).internalCache(DEFAULT_CACHE_NAME).context().queries();
assert qryMgr != null;
qryMgr.printMemoryStats();
}
}
}
}, threadCnt);
Thread.sleep(DURATION);
done.set(true);
fut.get();
}
Aggregations