use of org.apache.ignite.internal.util.lang.GridInClosure3 in project ignite by apache.
the class GridNearTxLocal method checkMissed.
/**
* @param cacheCtx Cache context.
* @param topVer Topology version.
* @param map Return map.
* @param missedMap Missed keys.
* @param deserializeBinary Deserialize binary flag.
* @param skipVals Skip values flag.
* @param keepCacheObjects Keep cache objects flag.
* @param skipStore Skip store flag.
* @param expiryPlc Expiry policy.
* @return Loaded key-value pairs.
*/
private <K, V> IgniteInternalFuture<Map<K, V>> checkMissed(final GridCacheContext cacheCtx, final AffinityTopologyVersion topVer, final Map<K, V> map, final Map<KeyCacheObject, GridCacheVersion> missedMap, final boolean deserializeBinary, final boolean skipVals, final boolean keepCacheObjects, final boolean skipStore, final boolean recovery, final boolean needVer, final ExpiryPolicy expiryPlc) {
if (log.isDebugEnabled())
log.debug("Loading missed values for missed map: " + missedMap);
final boolean needReadVer = (serializable() && optimistic()) || needVer;
return new GridEmbeddedFuture<>(new C2<Void, Exception, Map<K, V>>() {
@Override
public Map<K, V> apply(Void v, Exception e) {
if (e != null) {
setRollbackOnly();
throw new GridClosureException(e);
}
return map;
}
}, loadMissing(cacheCtx, topVer, !skipStore, false, missedMap.keySet(), skipVals, needReadVer, !deserializeBinary, recovery, expiryPlc, new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
@Override
public void apply(KeyCacheObject key, Object val, GridCacheVersion loadVer) {
if (isRollbackOnly()) {
if (log.isDebugEnabled())
log.debug("Ignoring loaded value for read because transaction was rolled back: " + GridNearTxLocal.this);
return;
}
CacheObject cacheVal = cacheCtx.toCacheObject(val);
CacheObject visibleVal = cacheVal;
IgniteTxKey txKey = cacheCtx.txKey(key);
IgniteTxEntry txEntry = entry(txKey);
if (txEntry != null) {
if (!readCommitted())
txEntry.readValue(cacheVal);
if (!F.isEmpty(txEntry.entryProcessors()))
visibleVal = txEntry.applyEntryProcessors(visibleVal);
}
assert txEntry != null || readCommitted() || skipVals;
GridCacheEntryEx e = txEntry == null ? entryEx(cacheCtx, txKey, topVer) : txEntry.cached();
if (readCommitted() || skipVals) {
cacheCtx.evicts().touch(e, topologyVersion());
if (visibleVal != null) {
cacheCtx.addResult(map, key, visibleVal, skipVals, keepCacheObjects, deserializeBinary, false, needVer ? loadVer : null, 0, 0);
}
} else {
assert txEntry != null;
txEntry.setAndMarkValid(cacheVal);
if (needReadVer) {
assert loadVer != null;
txEntry.entryReadVersion(loadVer);
}
if (visibleVal != null) {
cacheCtx.addResult(map, key, visibleVal, skipVals, keepCacheObjects, deserializeBinary, false, needVer ? loadVer : null, 0, 0);
}
}
}
}));
}
use of org.apache.ignite.internal.util.lang.GridInClosure3 in project ignite by apache.
the class GridNearTxLocal method loadMissing.
/**
* @param cacheCtx Cache context.
* @param keys Keys to load.
* @param filter Filter.
* @param ret Return value.
* @param needReadVer Read version flag.
* @param singleRmv {@code True} for single remove operation.
* @param hasFilters {@code True} if filters not empty.
* @param readThrough Read through flag.
* @param retval Return value flag.
* @param expiryPlc Expiry policy.
* @return Load future.
*/
private IgniteInternalFuture<Void> loadMissing(final GridCacheContext cacheCtx, final AffinityTopologyVersion topVer, final Set<KeyCacheObject> keys, final CacheEntryPredicate[] filter, final GridCacheReturn ret, final boolean needReadVer, final boolean singleRmv, final boolean hasFilters, final boolean readThrough, final boolean retval, final boolean keepBinary, final boolean recovery, final ExpiryPolicy expiryPlc) {
GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c = new GridInClosure3<KeyCacheObject, Object, GridCacheVersion>() {
@Override
public void apply(KeyCacheObject key, @Nullable Object val, @Nullable GridCacheVersion loadVer) {
if (log.isDebugEnabled())
log.debug("Loaded value from remote node [key=" + key + ", val=" + val + ']');
IgniteTxEntry e = entry(new IgniteTxKey(key, cacheCtx.cacheId()));
assert e != null;
if (needReadVer) {
assert loadVer != null;
e.entryReadVersion(singleRmv && val != null ? SER_READ_NOT_EMPTY_VER : loadVer);
}
if (singleRmv) {
assert !hasFilters && !retval;
assert val == null || Boolean.TRUE.equals(val) : val;
ret.set(cacheCtx, null, val != null, keepBinary, U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId));
} else {
CacheObject cacheVal = cacheCtx.toCacheObject(val);
if (e.op() == TRANSFORM) {
GridCacheVersion ver;
e.readValue(cacheVal);
try {
ver = e.cached().version();
} catch (GridCacheEntryRemovedException ex) {
assert optimistic() : e;
if (log.isDebugEnabled())
log.debug("Failed to get entry version: [msg=" + ex.getMessage() + ']');
ver = null;
}
addInvokeResult(e, cacheVal, ret, ver);
} else {
boolean success;
if (hasFilters) {
success = isAll(e.context(), key, cacheVal, filter);
if (!success) {
e.value(cacheVal, false, false);
e.op(READ);
}
} else
success = true;
ret.set(cacheCtx, cacheVal, success, keepBinary, U.deploymentClassLoader(cctx.kernalContext(), deploymentLdrId));
}
}
}
};
return loadMissing(cacheCtx, topVer, readThrough, /*async*/
true, keys, /*skipVals*/
singleRmv, needReadVer, keepBinary, recovery, null, expiryPlc, c);
}
use of org.apache.ignite.internal.util.lang.GridInClosure3 in project ignite by apache.
the class GridNearTxLocal method loadMissing.
/**
* @param cacheCtx Cache context.
* @param readThrough Read through flag.
* @param async if {@code True}, then loading will happen in a separate thread.
* @param keys Keys.
* @param skipVals Skip values flag.
* @param needVer If {@code true} version is required for loaded values.
* @param c Closure to be applied for loaded values.
* @param readRepairStrategy Read Repair strategy.
* @param expiryPlc Expiry policy.
* @return Future with {@code True} value if loading took place.
*/
private IgniteInternalFuture<Void> loadMissing(final GridCacheContext cacheCtx, AffinityTopologyVersion topVer, boolean readThrough, boolean async, final Collection<KeyCacheObject> keys, final boolean skipVals, final boolean needVer, boolean keepBinary, boolean recovery, ReadRepairStrategy readRepairStrategy, final ExpiryPolicy expiryPlc, final GridInClosure3<KeyCacheObject, Object, GridCacheVersion> c) {
IgniteCacheExpiryPolicy expiryPlc0 = optimistic() ? accessPolicy(cacheCtx, keys) : cacheCtx.cache().expiryPolicy(expiryPlc);
if (cacheCtx.isNear()) {
return cacheCtx.nearTx().txLoadAsync(this, topVer, keys, readThrough, needVer || !cacheCtx.config().isReadFromBackup() || (optimistic() && serializable() && readThrough), /*deserializeBinary*/
false, recovery, expiryPlc0, skipVals, needVer).chain(new C1<IgniteInternalFuture<Map<Object, Object>>, Void>() {
@Override
public Void apply(IgniteInternalFuture<Map<Object, Object>> f) {
try {
Map<Object, Object> map = f.get();
processLoaded(map, keys, needVer, c);
return null;
} catch (Exception e) {
setRollbackOnly();
throw new GridClosureException(e);
}
}
});
} else if (cacheCtx.isColocated()) {
if (readRepairStrategy != null) {
return new GridNearReadRepairCheckOnlyFuture(cacheCtx, keys, readRepairStrategy, readThrough, taskName, false, recovery, expiryPlc0, skipVals, needVer, true, this).multi().chain((fut) -> {
try {
Map<Object, Object> map = fut.get();
processLoaded(map, keys, needVer, c);
return null;
} catch (IgniteConsistencyViolationException e) {
for (KeyCacheObject key : keys) // Will be recreated after repair.
txState().removeEntry(cacheCtx.txKey(key));
throw new GridClosureException(e);
} catch (Exception e) {
setRollbackOnly();
throw new GridClosureException(e);
}
});
}
if (keys.size() == 1) {
final KeyCacheObject key = F.first(keys);
return cacheCtx.colocated().loadAsync(key, readThrough, needVer || !cacheCtx.config().isReadFromBackup() || (optimistic() && serializable() && readThrough), topVer, resolveTaskName(), /*deserializeBinary*/
false, expiryPlc0, skipVals, needVer, /*keepCacheObject*/
true, recovery, null, label()).chain(new C1<IgniteInternalFuture<Object>, Void>() {
@Override
public Void apply(IgniteInternalFuture<Object> f) {
try {
Object val = f.get();
processLoaded(key, val, needVer, skipVals, c);
return null;
} catch (Exception e) {
setRollbackOnly();
throw new GridClosureException(e);
}
}
});
} else {
return cacheCtx.colocated().loadAsync(keys, readThrough, needVer || !cacheCtx.config().isReadFromBackup() || (optimistic() && serializable() && readThrough), topVer, resolveTaskName(), /*deserializeBinary*/
false, recovery, expiryPlc0, skipVals, needVer, /*keepCacheObject*/
true, label(), null).chain(new C1<IgniteInternalFuture<Map<Object, Object>>, Void>() {
@Override
public Void apply(IgniteInternalFuture<Map<Object, Object>> f) {
try {
Map<Object, Object> map = f.get();
processLoaded(map, keys, needVer, c);
return null;
} catch (Exception e) {
setRollbackOnly();
throw new GridClosureException(e);
}
}
});
}
} else {
assert cacheCtx.isLocal();
return localCacheLoadMissing(cacheCtx, topVer, readThrough, async, keys, skipVals, needVer, keepBinary, recovery, expiryPlc, c);
}
}
use of org.apache.ignite.internal.util.lang.GridInClosure3 in project ignite by apache.
the class CacheMvccAbstractTest method accountsTxReadAll.
/**
* @param srvs Number of server nodes.
* @param clients Number of client nodes.
* @param cacheBackups Number of cache backups.
* @param cacheParts Number of cache partitions.
* @param cfgC Optional closure applied to cache configuration.
* @param withRmvs If {@code true} then in addition to puts tests also executes removes.
* @param readMode Read mode.
* @param writeMode Write mode.
* @param testTime Test time.
* @throws Exception If failed.
*/
final void accountsTxReadAll(final int srvs, final int clients, int cacheBackups, int cacheParts, @Nullable IgniteInClosure<CacheConfiguration> cfgC, final boolean withRmvs, final ReadMode readMode, final WriteMode writeMode, long testTime, RestartMode restartMode) throws Exception {
final int ACCOUNTS = 20;
final int ACCOUNT_START_VAL = 1000;
final int writers = 4;
final int readers = 4;
final IgniteInClosure<IgniteCache<Object, Object>> init = new IgniteInClosure<IgniteCache<Object, Object>>() {
@Override
public void apply(IgniteCache<Object, Object> cache) {
final IgniteTransactions txs = cache.unwrap(Ignite.class).transactions();
if (writeMode == WriteMode.PUT) {
Map<Integer, MvccTestAccount> accounts = new HashMap<>();
for (int i = 0; i < ACCOUNTS; i++) accounts.put(i, new MvccTestAccount(ACCOUNT_START_VAL, 1));
try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
cache.putAll(accounts);
tx.commit();
}
} else if (writeMode == WriteMode.DML) {
try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
SqlFieldsQuery qry = new SqlFieldsQuery("insert into MvccTestAccount(_key, val, updateCnt) values " + "(?," + ACCOUNT_START_VAL + ",1)");
for (int i = 0; i < ACCOUNTS; i++) {
try (FieldsQueryCursor<List<?>> cur = cache.query(qry.setArgs(i))) {
assertEquals(1L, cur.iterator().next().get(0));
}
tx.commit();
}
}
} else
assert false : "Unknown write mode";
}
};
final RemovedAccountsTracker rmvdTracker = new RemovedAccountsTracker(ACCOUNTS);
GridInClosure3<Integer, List<TestCache>, AtomicBoolean> writer = new GridInClosure3<Integer, List<TestCache>, AtomicBoolean>() {
@Override
public void apply(Integer idx, List<TestCache> caches, AtomicBoolean stop) {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
int cnt = 0;
while (!stop.get()) {
TestCache<Integer, MvccTestAccount> cache = randomCache(caches, rnd);
try {
IgniteTransactions txs = cache.cache.unwrap(Ignite.class).transactions();
cnt++;
int i1 = rnd.nextInt(ACCOUNTS), i2 = rnd.nextInt(ACCOUNTS);
while (i2 == i1) i2 = rnd.nextInt(ACCOUNTS);
Integer id1 = Math.min(i1, i2);
Integer id2 = Math.max(i1, i2);
Set<Integer> keys = new HashSet<>();
keys.add(id1);
keys.add(id2);
Integer cntr1 = null;
Integer cntr2 = null;
Integer rmvd = null;
Integer inserted = null;
MvccTestAccount a1;
MvccTestAccount a2;
try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
tx.timeout(TX_TIMEOUT);
Map<Integer, MvccTestAccount> accounts = null;
if (writeMode == WriteMode.PUT)
accounts = cache.cache.getAll(keys);
else if (writeMode == WriteMode.DML)
accounts = getAllSql(cache);
else
assert false : "Unknown write mode";
a1 = accounts.get(id1);
a2 = accounts.get(id2);
if (!withRmvs) {
assertNotNull(a1);
assertNotNull(a2);
cntr1 = a1.updateCnt + 1;
cntr2 = a2.updateCnt + 1;
if (writeMode == WriteMode.PUT) {
cache.cache.put(id1, new MvccTestAccount(a1.val + 1, cntr1));
cache.cache.put(id2, new MvccTestAccount(a2.val - 1, cntr2));
} else if (writeMode == WriteMode.DML) {
updateSql(cache, id1, a1.val + 1, cntr1);
updateSql(cache, id2, a2.val - 1, cntr2);
} else
assert false : "Unknown write mode";
} else {
if (a1 != null || a2 != null) {
if (a1 != null && a2 != null) {
if (rnd.nextInt(10) == 0) {
if (rmvdTracker.size() < ACCOUNTS / 2) {
rmvd = rnd.nextBoolean() ? id1 : id2;
assertTrue(rmvdTracker.markRemoved(rmvd));
}
}
if (rmvd != null) {
if (writeMode == WriteMode.PUT) {
if (rmvd.equals(id1)) {
cache.cache.remove(id1);
cache.cache.put(id2, new MvccTestAccount(a1.val + a2.val, 1));
} else {
cache.cache.put(id1, new MvccTestAccount(a1.val + a2.val, 1));
cache.cache.remove(id2);
}
} else if (writeMode == WriteMode.DML) {
if (rmvd.equals(id1)) {
removeSql(cache, id1);
updateSql(cache, id2, a1.val + a2.val, 1);
} else {
updateSql(cache, id1, a1.val + a2.val, 1);
removeSql(cache, id2);
}
} else
assert false : "Unknown write mode";
} else {
if (writeMode == WriteMode.PUT) {
cache.cache.put(id1, new MvccTestAccount(a1.val + 1, 1));
cache.cache.put(id2, new MvccTestAccount(a2.val - 1, 1));
} else if (writeMode == WriteMode.DML) {
updateSql(cache, id1, a1.val + 1, 1);
updateSql(cache, id2, a2.val - 1, 1);
} else
assert false : "Unknown write mode";
}
} else {
if (a1 == null) {
inserted = id1;
if (writeMode == WriteMode.PUT) {
cache.cache.put(id1, new MvccTestAccount(100, 1));
cache.cache.put(id2, new MvccTestAccount(a2.val - 100, 1));
} else if (writeMode == WriteMode.DML) {
insertSql(cache, id1, 100, 1);
updateSql(cache, id2, a2.val - 100, 1);
} else
assert false : "Unknown write mode";
} else {
inserted = id2;
if (writeMode == WriteMode.PUT) {
cache.cache.put(id1, new MvccTestAccount(a1.val - 100, 1));
cache.cache.put(id2, new MvccTestAccount(100, 1));
} else if (writeMode == WriteMode.DML) {
updateSql(cache, id1, a1.val - 100, 1);
insertSql(cache, id2, 100, 1);
} else
assert false : "Unknown write mode";
}
}
}
}
tx.commit();
// In case of tx success mark inserted.
if (inserted != null) {
assert withRmvs;
assertTrue(rmvdTracker.unmarkRemoved(inserted));
}
} catch (Throwable e) {
if (rmvd != null) {
assert withRmvs;
// If tx fails, unmark removed.
assertTrue(rmvdTracker.unmarkRemoved(rmvd));
}
throw e;
}
if (!withRmvs) {
Map<Integer, MvccTestAccount> accounts = null;
if (writeMode == WriteMode.PUT)
accounts = cache.cache.getAll(keys);
else if (writeMode == WriteMode.DML)
accounts = getAllSql(cache);
else
assert false : "Unknown write mode";
a1 = accounts.get(id1);
a2 = accounts.get(id2);
assertNotNull(a1);
assertNotNull(a2);
assertTrue(a1.updateCnt >= cntr1);
assertTrue(a2.updateCnt >= cntr2);
}
} catch (Exception e) {
handleTxException(e);
} finally {
cache.readUnlock();
}
}
info("Writer finished, updates: " + cnt);
}
};
GridInClosure3<Integer, List<TestCache>, AtomicBoolean> reader = new GridInClosure3<Integer, List<TestCache>, AtomicBoolean>() {
@Override
public void apply(Integer idx, List<TestCache> caches, AtomicBoolean stop) {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
Set<Integer> keys = new LinkedHashSet<>();
Map<Integer, Integer> lastUpdateCntrs = new HashMap<>();
SqlFieldsQuery sumQry = new SqlFieldsQuery("select sum(val) from MvccTestAccount");
while (!stop.get()) {
while (keys.size() < ACCOUNTS) keys.add(rnd.nextInt(ACCOUNTS));
TestCache<Integer, MvccTestAccount> cache = randomCache(caches, rnd);
Map<Integer, MvccTestAccount> accounts = null;
try {
switch(readMode) {
case GET:
{
accounts = cache.cache.getAll(keys);
break;
}
case SCAN:
{
accounts = new HashMap<>();
Iterator<Cache.Entry<Integer, MvccTestAccount>> it = cache.cache.iterator();
try {
for (; it.hasNext(); ) {
IgniteCache.Entry<Integer, MvccTestAccount> e = it.next();
MvccTestAccount old = accounts.put(e.getKey(), e.getValue());
assertNull("new=" + e + ", old=" + old, old);
}
} finally {
U.closeQuiet((AutoCloseable) it);
}
break;
}
case SQL:
{
accounts = new HashMap<>();
if (rnd.nextBoolean()) {
SqlQuery<Integer, MvccTestAccount> qry = new SqlQuery<>(MvccTestAccount.class, "_key >= 0");
for (IgniteCache.Entry<Integer, MvccTestAccount> e : cache.cache.query(qry).getAll()) {
MvccTestAccount old = accounts.put(e.getKey(), e.getValue());
assertNull(old);
}
} else {
SqlFieldsQuery qry = new SqlFieldsQuery("select _key, val from MvccTestAccount");
for (List<?> row : cache.cache.query(qry).getAll()) {
Integer id = (Integer) row.get(0);
Integer val = (Integer) row.get(1);
MvccTestAccount old = accounts.put(id, new MvccTestAccount(val, 1));
assertNull(old);
}
}
break;
}
case SQL_SUM:
{
Long sum;
if (rnd.nextBoolean()) {
List<List<?>> res = cache.cache.query(sumQry).getAll();
assertEquals(1, res.size());
sum = (Long) res.get(0).get(0);
} else {
Map res = readAllByMode(cache.cache, keys, readMode, ACCOUNT_CODEC);
sum = (Long) ((Map.Entry) res.entrySet().iterator().next()).getValue();
}
assertEquals(ACCOUNT_START_VAL * ACCOUNTS, sum.intValue());
break;
}
default:
{
fail();
return;
}
}
} finally {
cache.readUnlock();
}
if (accounts != null) {
if (!withRmvs)
assertEquals(ACCOUNTS, accounts.size());
int sum = 0;
for (int i = 0; i < ACCOUNTS; i++) {
MvccTestAccount account = accounts.get(i);
if (account != null) {
sum += account.val;
Integer cntr = lastUpdateCntrs.get(i);
if (cntr != null)
assertTrue(cntr <= account.updateCnt);
lastUpdateCntrs.put(i, cntr);
} else
assertTrue(withRmvs);
}
assertEquals(ACCOUNTS * ACCOUNT_START_VAL, sum);
}
}
if (idx == 0) {
TestCache<Integer, MvccTestAccount> cache = randomCache(caches, rnd);
Map<Integer, MvccTestAccount> accounts;
ReadMode readMode0 = readMode == SQL_SUM ? SQL : readMode;
try {
accounts = readAllByMode(cache.cache, keys, readMode0, ACCOUNT_CODEC);
;
} finally {
cache.readUnlock();
}
int sum = 0;
for (int i = 0; i < ACCOUNTS; i++) {
MvccTestAccount account = accounts.get(i);
assertTrue(account != null || withRmvs);
info("Account [id=" + i + ", val=" + (account != null ? account.val : null) + ']');
if (account != null)
sum += account.val;
}
info("Sum: " + sum);
}
}
};
readWriteTest(restartMode, srvs, clients, cacheBackups, cacheParts, writers, readers, testTime, cfgC, init, writer, reader);
}
use of org.apache.ignite.internal.util.lang.GridInClosure3 in project ignite by apache.
the class CacheMvccSqlQueriesAbstractTest method joinTransactional.
/**
* @param singleNode {@code True} for test with single node.
* @param distributedJoin {@code True} to test distributed joins.
* @throws Exception If failed.
*/
private void joinTransactional(boolean singleNode, final boolean distributedJoin) throws Exception {
final int KEYS = 100;
final int writers = 4;
final int readers = 4;
GridInClosure3<Integer, List<TestCache>, AtomicBoolean> writer = new GridInClosure3<Integer, List<TestCache>, AtomicBoolean>() {
@Override
public void apply(Integer idx, List<TestCache> caches, AtomicBoolean stop) {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
int cnt = 0;
while (!stop.get()) {
TestCache<Object, Object> cache = randomCache(caches, rnd);
IgniteTransactions txs = cache.cache.unwrap(Ignite.class).transactions();
try {
while (true) {
try (Transaction tx = txs.txStart(PESSIMISTIC, REPEATABLE_READ)) {
Integer key = rnd.nextInt(KEYS);
JoinTestChildKey childKey = new JoinTestChildKey(key);
JoinTestChild child = (JoinTestChild) cache.cache.get(childKey);
if (child == null) {
int parentKey = distributedJoin ? key + 100 : key;
child = new JoinTestChild(parentKey);
cache.cache.put(childKey, child);
JoinTestParent parent = new JoinTestParent(parentKey);
cache.cache.put(new JoinTestParentKey(parentKey), parent);
} else {
cache.cache.remove(childKey);
cache.cache.remove(new JoinTestParentKey(child.parentId));
}
tx.commit();
break;
} catch (CacheException e) {
MvccFeatureChecker.assertMvccWriteConflict(e);
}
}
cnt++;
} finally {
cache.readUnlock();
}
}
info("Writer finished, updates: " + cnt);
}
};
GridInClosure3<Integer, List<TestCache>, AtomicBoolean> reader = new GridInClosure3<Integer, List<TestCache>, AtomicBoolean>() {
@Override
public void apply(Integer idx, List<TestCache> caches, AtomicBoolean stop) {
ThreadLocalRandom rnd = ThreadLocalRandom.current();
List<SqlFieldsQuery> qrys = new ArrayList<>();
qrys.add(new SqlFieldsQuery("select c.parentId, p.id from " + "JoinTestChild c left outer join JoinTestParent p on (c.parentId = p.id)").setDistributedJoins(distributedJoin));
qrys.add(new SqlFieldsQuery("select c.parentId, p.id from " + "JoinTestChild c left outer join JoinTestParent p on (c.parentId = p.id) where p.id = 10").setDistributedJoins(distributedJoin));
qrys.add(new SqlFieldsQuery("select c.parentId, p.id from " + "JoinTestChild c left outer join JoinTestParent p on (c.parentId = p.id) where p.id != 10").setDistributedJoins(distributedJoin));
while (!stop.get()) {
TestCache<Object, Object> cache = randomCache(caches, rnd);
try {
for (SqlFieldsQuery qry : qrys) {
List<List<?>> res = cache.cache.query(qry).getAll();
if (!res.isEmpty()) {
for (List<?> resRow : res) {
Integer parentId = (Integer) resRow.get(1);
assertNotNull(parentId);
}
}
}
} finally {
cache.readUnlock();
}
}
if (idx == 0) {
TestCache<Object, Object> cache = randomCache(caches, rnd);
try {
List<List<?>> res = cache.cache.query(qrys.get(0)).getAll();
info("Reader finished, result: " + res);
} finally {
cache.readUnlock();
}
}
}
};
int srvs;
int clients;
if (singleNode) {
srvs = 1;
clients = 0;
} else {
srvs = 4;
clients = 2;
}
readWriteTest(null, srvs, clients, 0, DFLT_PARTITION_COUNT, writers, readers, DFLT_TEST_TIME, new InitIndexing(JoinTestParentKey.class, JoinTestParent.class, JoinTestChildKey.class, JoinTestChild.class), null, writer, reader);
}
Aggregations