use of org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor in project ignite by apache.
the class IgniteSqlSkipReducerOnUpdateDmlSelfTest method checkNoLeaks.
/**
* Ensure there are no leaks in data structures associated with distributed dml execution.
*/
private void checkNoLeaks() {
GridQueryProcessor qryProc = grid(NODE_CLIENT).context().query();
IgniteH2Indexing h2Idx = GridTestUtils.getFieldValue(qryProc, GridQueryProcessor.class, "idx");
GridReduceQueryExecutor rdcQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "rdcQryExec");
Map updRuns = GridTestUtils.getFieldValue(rdcQryExec, GridReduceQueryExecutor.class, "updRuns");
assertEquals(0, updRuns.size());
for (int idx = 0; idx < NODE_COUNT; idx++) {
qryProc = grid(idx).context().query();
h2Idx = GridTestUtils.getFieldValue(qryProc, GridQueryProcessor.class, "idx");
GridMapQueryExecutor mapQryExec = GridTestUtils.getFieldValue(h2Idx, IgniteH2Indexing.class, "mapQryExec");
Map qryRess = GridTestUtils.getFieldValue(mapQryExec, GridMapQueryExecutor.class, "qryRess");
for (Object obj : qryRess.values()) {
Map updCancels = GridTestUtils.getFieldValue(obj, "updCancels");
assertEquals(0, updCancels.size());
}
}
}
use of org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor 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.GridMapQueryExecutor 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.GridMapQueryExecutor in project ignite by apache.
the class CacheQueryMemoryLeakTest method isMapNodeResultsEmpty.
/**
* @param node Ignite node.
* @return {@code True}, if all MapQueryResults are removed from internal node's structures. {@code False}
* otherwise.
*/
private boolean isMapNodeResultsEmpty(IgniteEx node) {
IgniteH2Indexing idx = (IgniteH2Indexing) node.context().query().getIndexing();
GridMapQueryExecutor mapQryExec = idx.mapQueryExecutor();
Map<UUID, MapNodeResults> qryRess = GridTestUtils.getFieldValue(mapQryExec, GridMapQueryExecutor.class, "qryRess");
for (MapNodeResults nodeRess : qryRess.values()) {
Map<MapRequestKey, MapQueryResults> nodeQryRess = GridTestUtils.getFieldValue(nodeRess, MapNodeResults.class, "res");
if (!nodeQryRess.isEmpty())
return false;
}
return true;
}
use of org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor in project ignite by apache.
the class IgniteH2Indexing method start.
/**
* {@inheritDoc}
*/
@SuppressWarnings({ "deprecation", "AssignmentToStaticFieldFromInstanceMethod" })
@Override
public void start(GridKernalContext ctx, GridSpinBusyLock busyLock) throws IgniteCheckedException {
if (log.isDebugEnabled())
log.debug("Starting cache query index...");
this.busyLock = busyLock;
if (SysProperties.serializeJavaObject) {
U.warn(log, "Serialization of Java objects in H2 was enabled.");
SysProperties.serializeJavaObject = false;
}
this.ctx = ctx;
partReservationMgr = new PartitionReservationManager(ctx);
connMgr = new ConnectionManager(ctx);
longRunningQryMgr = new LongRunningQueryManager(ctx);
parser = new QueryParser(this, connMgr);
schemaMgr = new SchemaManager(ctx, connMgr);
schemaMgr.start(ctx.config().getSqlConfiguration().getSqlSchemas());
statsMgr = new IgniteStatisticsManagerImpl(ctx, schemaMgr);
nodeId = ctx.localNodeId();
marshaller = ctx.config().getMarshaller();
mapQryExec = new GridMapQueryExecutor();
rdcQryExec = new GridReduceQueryExecutor();
mapQryExec.start(ctx, this);
rdcQryExec.start(ctx, this);
discoLsnr = evt -> {
mapQryExec.onNodeLeft((DiscoveryEvent) evt);
rdcQryExec.onNodeLeft((DiscoveryEvent) evt);
};
ctx.event().addLocalEventListener(discoLsnr, EventType.EVT_NODE_FAILED, EventType.EVT_NODE_LEFT);
qryLsnr = (nodeId, msg, plc) -> onMessage(nodeId, msg);
ctx.io().addMessageListener(GridTopic.TOPIC_QUERY, qryLsnr);
runningQryMgr = new RunningQueryManager(ctx);
partExtractor = new PartitionExtractor(new H2PartitionResolver(this), ctx);
cmdProc = new CommandProcessor(ctx, schemaMgr, this);
cmdProc.start();
if (JdbcUtils.serializer != null)
U.warn(log, "Custom H2 serialization is already configured, will override.");
JdbcUtils.serializer = h2Serializer();
distrCfg = new DistributedSqlConfiguration(ctx, log);
funcMgr = new FunctionsManager(distrCfg);
}
Aggregations