Search in sources :

Example 6 with GridMapQueryExecutor

use of org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor 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();
}
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 7 with GridMapQueryExecutor

use of org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor in project ignite by apache.

the class RetryCauseMessageSelfTest method testReplicatedCacheReserveFailureMessage.

/**
 * Failed to reserve partitions for query (partition of REPLICATED cache is not in OWNING state)
 */
@Ignore("https://issues.apache.org/jira/browse/IGNITE-7039")
@Test
public void testReplicatedCacheReserveFailureMessage() {
    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, Organization> qry = new SqlQuery<>(Organization.class, ORG_SQL);
    qry.setDistributedJoins(true);
    try {
        orgCache.query(qry).getAll();
    } catch (CacheException e) {
        assertTrue(e.getMessage().contains("Failed to reserve partitions for query (partition of REPLICATED cache is not in OWNING state) ["));
        return;
    } finally {
        GridTestUtils.setFieldValue(h2Idx, "mapQryExec", mapQryExec);
    }
    fail();
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) Organization(org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization) SqlQuery(org.apache.ignite.cache.query.SqlQuery) 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) Ignore(org.junit.Ignore) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) Test(org.junit.Test)

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