use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlSelfTest method testCancel.
/**
* @throws Exception if failed.
*/
@Test
public void testCancel() throws Exception {
latch = new CountDownLatch(NODE_COUNT + 1);
fillCaches();
final IgniteCache<Integer, Organization> cache = grid(NODE_CLIENT).cache(CACHE_ORG);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() {
return cache.query(new SqlFieldsQueryEx("UPDATE Organization SET name = WAIT(name)", false).setSkipReducerOnUpdate(true));
}
});
GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
Collection<GridRunningQueryInfo> qCol = grid(NODE_CLIENT).context().query().runningQueries(0);
if (qCol.isEmpty())
return false;
for (GridRunningQueryInfo queryInfo : qCol) queryInfo.cancel();
return true;
}
}, 5000);
latch.await(5000, MILLISECONDS);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws IgniteCheckedException {
return fut.get();
}
}, IgniteCheckedException.class, "Future was cancelled");
}
use of org.apache.ignite.internal.processors.cache.query.SqlFieldsQueryEx in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlSelfTest method testNodeStopDuringUpdate.
/**
* @throws Exception if failed.
*/
@Test
public void testNodeStopDuringUpdate() throws Exception {
startGrid(NODE_COUNT + 1);
awaitPartitionMapExchange();
fillCaches();
latch = new CountDownLatch(NODE_COUNT + 1 + 1);
final IgniteCache<Integer, Organization> cache = grid(NODE_CLIENT).cache(CACHE_ORG);
final IgniteInternalFuture<Object> fut = GridTestUtils.runAsync(new Callable<Object>() {
@Override
public Object call() {
return cache.query(new SqlFieldsQueryEx("UPDATE Organization SET name = WAIT(name)", false).setSkipReducerOnUpdate(true));
}
});
final CountDownLatch finalLatch = latch;
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
return finalLatch.getCount() == 1;
}
}, 5000));
latch.countDown();
stopGrid(NODE_COUNT + 1);
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override
public Object call() throws IgniteCheckedException {
return fut.get();
}
}, IgniteCheckedException.class, "Update failed because map node left topology");
}
Aggregations