Search in sources :

Example 1 with Organization

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();
}
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 2 with Organization

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();
}
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 3 with Organization

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);
}
Also used : GridQueryProcessor(org.apache.ignite.internal.processors.query.GridQueryProcessor) Ignite(org.apache.ignite.Ignite) Person(org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 4 with Organization

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) GridQueryCancelRequest(org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest) Organization(org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) GridH2QueryRequest(org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException)

Example 5 with Organization

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();
}
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)

Aggregations

ClusterNode (org.apache.ignite.cluster.ClusterNode)5 GridH2QueryRequest (org.apache.ignite.internal.processors.query.h2.twostep.msg.GridH2QueryRequest)5 CacheException (javax.cache.CacheException)4 AbstractIndexingCommonTest (org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest)4 Person (org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Person)4 Test (org.junit.Test)4 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 Organization (org.apache.ignite.internal.processors.query.h2.twostep.JoinSqlTestHelper.Organization)2 Ignite (org.apache.ignite.Ignite)1 IgniteException (org.apache.ignite.IgniteException)1 SqlQuery (org.apache.ignite.cache.query.SqlQuery)1 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)1 GridIoMessage (org.apache.ignite.internal.managers.communication.GridIoMessage)1 GridQueryProcessor (org.apache.ignite.internal.processors.query.GridQueryProcessor)1 GridQueryCancelRequest (org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest)1 Message (org.apache.ignite.plugin.extensions.communication.Message)1