Search in sources :

Example 1 with GridMapQueryExecutor

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());
        }
    }
}
Also used : IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) Map(java.util.Map) GridReduceQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor) GridMapQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor)

Example 2 with GridMapQueryExecutor

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();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) CacheException(javax.cache.CacheException) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridH2QueryRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest) AtomicLong(java.util.concurrent.atomic.AtomicLong) GridDhtLocalPartition(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition) Person(org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) Test(org.junit.Test)

Example 3 with GridMapQueryExecutor

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();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) CacheException(javax.cache.CacheException) GridH2QueryRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest) GridReservable(org.apache.ignite.internal.processors.cache.distributed.dht.GridReservable) Person(org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) Test(org.junit.Test)

Example 4 with GridMapQueryExecutor

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;
}
Also used : IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) UUID(java.util.UUID)

Example 5 with GridMapQueryExecutor

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);
}
Also used : H2PartitionResolver(org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver) GridMapQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor) RunningQueryManager(org.apache.ignite.internal.processors.query.RunningQueryManager) IgniteStatisticsManagerImpl(org.apache.ignite.internal.processors.query.stat.IgniteStatisticsManagerImpl) PartitionReservationManager(org.apache.ignite.internal.processors.query.h2.twostep.PartitionReservationManager) PartitionExtractor(org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor) GridReduceQueryExecutor(org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)

Aggregations

CacheException (javax.cache.CacheException)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)4 AbstractIndexingCommonTest (org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest)4 GridH2QueryRequest (org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest)4 Test (org.junit.Test)4 Person (org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 GridKernalContext (org.apache.ignite.internal.GridKernalContext)2 GridReservable (org.apache.ignite.internal.processors.cache.distributed.dht.GridReservable)2 GridDhtLocalPartition (org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtLocalPartition)2 IgniteH2Indexing (org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing)2 GridMapQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor)2 GridReduceQueryExecutor (org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor)2 Map (java.util.Map)1 UUID (java.util.UUID)1 SqlQuery (org.apache.ignite.cache.query.SqlQuery)1 RunningQueryManager (org.apache.ignite.internal.processors.query.RunningQueryManager)1 H2PartitionResolver (org.apache.ignite.internal.processors.query.h2.affinity.H2PartitionResolver)1 PartitionExtractor (org.apache.ignite.internal.processors.query.h2.affinity.PartitionExtractor)1 Organization (org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization)1