use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization in project ignite by apache.
the class RetryCauseMessageSelfTest method testPartitionedCacheReserveFailureMessage.
/**
* Failed to reserve partitions for query (partition of PARTITIONED cache cannot be reserved)
*/
@Test
public void testPartitionedCacheReserveFailureMessage() {
GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec");
final GridKernalContext ctx = GridTestUtils.getFieldValue(mapQryExec, GridMapQueryExecutor.class, "ctx");
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", new MockGridMapQueryExecutor() {
@Override
public void onQueryRequest(ClusterNode node, GridH2QueryRequest qryReq) throws IgniteCheckedException {
GridCacheContext<?, ?> cctx = ctx.cache().context().cacheContext(qryReq.caches().get(0));
GridDhtLocalPartition part = cctx.topology().localPartition(0, NONE, false);
AtomicLong aState = GridTestUtils.getFieldValue(part, GridDhtLocalPartition.class, "state");
long stateVal = aState.getAndSet(2);
startedExecutor.onQueryRequest(node, qryReq);
aState.getAndSet(stateVal);
}
}.insertRealExecutor(mapQryExec));
SqlQuery<String, Person> qry = new SqlQuery<String, Person>(Person.class, JOIN_SQL).setArgs("Organization #0");
qry.setDistributedJoins(true);
try {
personCache.query(qry).getAll();
} catch (CacheException e) {
assertTrue(e.getMessage().contains("Failed to reserve partitions for query (partition of PARTITIONED " + "cache is not found or not in OWNING state) "));
return;
} finally {
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", mapQryExec);
}
fail();
}
use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization in project ignite by apache.
the class RetryCauseMessageSelfTest method testNonCollocatedFailureMessage.
/**
* Failed to execute non-collocated query (will retry)
*/
@Test
public void testNonCollocatedFailureMessage() {
final GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec");
final ConcurrentMap<PartitionReservationKey, GridReservable> reservations = reservations(h2Idx);
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", new MockGridMapQueryExecutor() {
@Override
public void onQueryRequest(ClusterNode node, GridH2QueryRequest qryReq) throws IgniteCheckedException {
final PartitionReservationKey grpKey = new PartitionReservationKey(ORG, null);
reservations.put(grpKey, new GridReservable() {
@Override
public boolean reserve() {
throw H2Utils.retryException("test retry exception");
}
@Override
public void release() {
}
});
startedExecutor.onQueryRequest(node, qryReq);
}
}.insertRealExecutor(mapQryExec));
SqlQuery<String, Person> qry = new SqlQuery<String, Person>(Person.class, JOIN_SQL).setArgs("Organization #0");
qry.setDistributedJoins(true);
try {
personCache.query(qry).getAll();
} catch (CacheException e) {
assertTrue(e.getMessage().contains("Failed to execute non-collocated query (will retry) ["));
return;
} finally {
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", mapQryExec);
}
fail();
}
use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization in project ignite by apache.
the class RetryCauseMessageSelfTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
Ignite ignite = startGridsMultiThreaded(NODES_COUNT, false);
GridQueryProcessor qryProc = grid(ignite.name()).context().query();
h2Idx = GridTestUtils.getFieldValue(qryProc, GridQueryProcessor.class, "idx");
personCache = ignite(0).getOrCreateCache(new CacheConfiguration<String, Person>("pers").setQueryEntities(JoinSqlTestHelper.personQueryEntity()));
orgCache = ignite(0).getOrCreateCache(new CacheConfiguration<String, Organization>(ORG).setCacheMode(CacheMode.REPLICATED).setQueryEntities(JoinSqlTestHelper.organizationQueryEntity()));
awaitPartitionMapExchange();
JoinSqlTestHelper.populateDataIntoOrg(orgCache);
JoinSqlTestHelper.populateDataIntoPerson(personCache);
}
use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization in project ignite by apache.
the class DisappearedCacheCauseRetryMessageSelfTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setCommunicationSpi(new TcpCommunicationSpi() {
volatile long reqId = -1;
/**
* {@inheritDoc}
*/
@Override
public void sendMessage(ClusterNode node, Message msg, IgniteInClosure<IgniteException> ackC) {
assert msg != null;
if (GridIoMessage.class.isAssignableFrom(msg.getClass())) {
GridIoMessage gridMsg = (GridIoMessage) msg;
if (GridH2QueryRequest.class.isAssignableFrom(gridMsg.message().getClass())) {
GridH2QueryRequest req = (GridH2QueryRequest) (gridMsg.message());
reqId = req.requestId();
orgCache.destroy();
} else if (GridQueryCancelRequest.class.isAssignableFrom(gridMsg.message().getClass())) {
GridQueryCancelRequest req = (GridQueryCancelRequest) (gridMsg.message());
if (reqId == req.queryRequestId())
orgCache = DisappearedCacheCauseRetryMessageSelfTest.this.ignite(0).getOrCreateCache(new CacheConfiguration<String, Organization>(ORG).setCacheMode(CacheMode.REPLICATED).setQueryEntities(JoinSqlTestHelper.organizationQueryEntity()));
}
}
super.sendMessage(node, msg, ackC);
}
});
return cfg;
}
use of org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization in project ignite by apache.
the class RetryCauseMessageSelfTest method testGrpReservationFailureMessage.
/**
* Failed to reserve partitions for query (group reservation failed)
*/
@Test
public void testGrpReservationFailureMessage() {
final GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec");
final ConcurrentMap<PartitionReservationKey, GridReservable> reservations = reservations(h2Idx);
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", new MockGridMapQueryExecutor() {
@Override
public void onQueryRequest(ClusterNode node, GridH2QueryRequest qryReq) throws IgniteCheckedException {
final PartitionReservationKey grpKey = new PartitionReservationKey(ORG, null);
reservations.put(grpKey, new GridReservable() {
@Override
public boolean reserve() {
return false;
}
@Override
public void release() {
}
});
startedExecutor.onQueryRequest(node, qryReq);
}
}.insertRealExecutor(mapQryExec));
SqlQuery<String, Person> qry = new SqlQuery<String, Person>(Person.class, JOIN_SQL).setArgs("Organization #0");
qry.setDistributedJoins(true);
try {
personCache.query(qry).getAll();
} catch (CacheException e) {
assertTrue(e.getMessage().contains("Failed to reserve partitions for query (group reservation failed) ["));
return;
} finally {
GridTestUtils.setFieldValue(h2Idx, "mapQryExec", mapQryExec);
}
fail();
}
Aggregations