Search in sources :

Example 1 with GridNearGetRequest

use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest in project ignite by apache.

the class GridDhtAtomicCache method start.

/**
 * {@inheritDoc}
 */
@SuppressWarnings({ "IfMayBeConditional", "SimplifiableIfStatement" })
@Override
public void start() throws IgniteCheckedException {
    super.start();
    CacheMetricsImpl m = new CacheMetricsImpl(ctx);
    if (ctx.dht().near() != null)
        m.delegate(ctx.dht().near().metrics0());
    metrics = m;
    ctx.io().addCacheHandler(ctx.cacheId(), GridNearGetRequest.class, new CI2<UUID, GridNearGetRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearGetRequest req) {
            processNearGetRequest(nodeId, req);
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridNearSingleGetRequest.class, new CI2<UUID, GridNearSingleGetRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearSingleGetRequest req) {
            processNearSingleGetRequest(nodeId, req);
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridNearAtomicAbstractUpdateRequest.class, new CI2<UUID, GridNearAtomicAbstractUpdateRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearAtomicAbstractUpdateRequest req) {
            processNearAtomicUpdateRequest(nodeId, req);
        }

        @Override
        public String toString() {
            return "GridNearAtomicAbstractUpdateRequest handler " + "[msgIdx=" + GridNearAtomicAbstractUpdateRequest.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridNearAtomicUpdateResponse.class, new CI2<UUID, GridNearAtomicUpdateResponse>() {

        @Override
        public void apply(UUID nodeId, GridNearAtomicUpdateResponse res) {
            processNearAtomicUpdateResponse(nodeId, res);
        }

        @Override
        public String toString() {
            return "GridNearAtomicUpdateResponse handler " + "[msgIdx=" + GridNearAtomicUpdateResponse.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicAbstractUpdateRequest.class, new CI2<UUID, GridDhtAtomicAbstractUpdateRequest>() {

        @Override
        public void apply(UUID nodeId, GridDhtAtomicAbstractUpdateRequest req) {
            processDhtAtomicUpdateRequest(nodeId, req);
        }

        @Override
        public String toString() {
            return "GridDhtAtomicUpdateRequest handler " + "[msgIdx=" + GridDhtAtomicUpdateRequest.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicUpdateResponse.class, new CI2<UUID, GridDhtAtomicUpdateResponse>() {

        @Override
        public void apply(UUID nodeId, GridDhtAtomicUpdateResponse res) {
            processDhtAtomicUpdateResponse(nodeId, res);
        }

        @Override
        public String toString() {
            return "GridDhtAtomicUpdateResponse handler " + "[msgIdx=" + GridDhtAtomicUpdateResponse.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicDeferredUpdateResponse.class, new CI2<UUID, GridDhtAtomicDeferredUpdateResponse>() {

        @Override
        public void apply(UUID nodeId, GridDhtAtomicDeferredUpdateResponse res) {
            processDhtAtomicDeferredUpdateResponse(nodeId, res);
        }

        @Override
        public String toString() {
            return "GridDhtAtomicDeferredUpdateResponse handler " + "[msgIdx=" + GridDhtAtomicDeferredUpdateResponse.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridDhtAtomicNearResponse.class, new CI2<UUID, GridDhtAtomicNearResponse>() {

        @Override
        public void apply(UUID uuid, GridDhtAtomicNearResponse msg) {
            processDhtAtomicNearResponse(uuid, msg);
        }

        @Override
        public String toString() {
            return "GridDhtAtomicNearResponse handler " + "[msgIdx=" + GridDhtAtomicNearResponse.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridNearAtomicCheckUpdateRequest.class, new CI2<UUID, GridNearAtomicCheckUpdateRequest>() {

        @Override
        public void apply(UUID uuid, GridNearAtomicCheckUpdateRequest msg) {
            processCheckUpdateRequest(uuid, msg);
        }

        @Override
        public String toString() {
            return "GridNearAtomicCheckUpdateRequest handler " + "[msgIdx=" + GridNearAtomicCheckUpdateRequest.CACHE_MSG_IDX + ']';
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridDhtForceKeysRequest.class, new MessageHandler<GridDhtForceKeysRequest>() {

        @Override
        public void onMessage(ClusterNode node, GridDhtForceKeysRequest msg) {
            processForceKeysRequest(node, msg);
        }
    });
    ctx.io().addCacheHandler(ctx.cacheId(), GridDhtForceKeysResponse.class, new MessageHandler<GridDhtForceKeysResponse>() {

        @Override
        public void onMessage(ClusterNode node, GridDhtForceKeysResponse msg) {
            processForceKeyResponse(node, msg);
        }
    });
    if (near == null) {
        ctx.io().addCacheHandler(ctx.cacheId(), GridNearGetResponse.class, new CI2<UUID, GridNearGetResponse>() {

            @Override
            public void apply(UUID nodeId, GridNearGetResponse res) {
                processNearGetResponse(nodeId, res);
            }
        });
        ctx.io().addCacheHandler(ctx.cacheId(), GridNearSingleGetResponse.class, new CI2<UUID, GridNearSingleGetResponse>() {

            @Override
            public void apply(UUID nodeId, GridNearSingleGetResponse res) {
                processNearSingleGetResponse(nodeId, res);
            }
        });
    }
}
Also used : GridDhtForceKeysResponse(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysResponse) CacheMetricsImpl(org.apache.ignite.internal.processors.cache.CacheMetricsImpl) GridDhtForceKeysRequest(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtForceKeysRequest) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) UUID(java.util.UUID) GridNearGetResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetResponse) ClusterNode(org.apache.ignite.cluster.ClusterNode) GridNearSingleGetResponse(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetResponse) GridNearSingleGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest)

Example 2 with GridNearGetRequest

use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest in project ignite by apache.

the class KillCommandsCommandShTest method testCancelConsistencyTask.

/**
 */
@Test
public void testCancelConsistencyTask() throws InterruptedException {
    String consistencyCacheName = "consistencyCache";
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<>();
    cfg.setName(consistencyCacheName);
    cfg.setBackups(SERVER_NODE_CNT - 1);
    cfg.setAffinity(new RendezvousAffinityFunction().setPartitions(1));
    IgniteCache<Integer, Integer> cache = client.getOrCreateCache(cfg);
    int entries = 10_000;
    for (int i = 0; i < entries; i++) cache.put(i, i);
    AtomicInteger getCnt = new AtomicInteger();
    CountDownLatch thLatch = new CountDownLatch(1);
    Thread th = new Thread(() -> {
        IgnitePredicate<ComputeJobView> repairJobFilter = job -> job.taskClassName().equals(VisorConsistencyRepairTask.class.getName());
        for (IgniteEx node : srvs) {
            SystemView<ComputeJobView> jobs = node.context().systemView().view(JOBS_VIEW);
            // Found.
            assertTrue(F.iterator0(jobs, true, repairJobFilter).hasNext());
        }
        int res = execute("--consistency", "status");
        assertEquals(EXIT_CODE_OK, res);
        assertContains(log, testOut.toString(), "Status: 1024/" + entries);
        assertNotContains(log, testOut.toString(), VisorConsistencyStatusTask.NOTHING_FOUND);
        testOut.reset();
        res = execute("--kill", "consistency");
        assertEquals(EXIT_CODE_OK, res);
        try {
            assertTrue(GridTestUtils.waitForCondition(() -> {
                for (IgniteEx node : srvs) {
                    SystemView<ComputeJobView> jobs = node.context().systemView().view(JOBS_VIEW);
                    if (// Found.
                    F.iterator0(jobs, true, repairJobFilter).hasNext())
                        return false;
                }
                return true;
            }, // Missed.
            5000L));
        } catch (IgniteInterruptedCheckedException e) {
            fail();
        }
        thLatch.countDown();
    });
    // GridNearGetRequest messages count required to pefrom getAll() with readRepair from all nodes twice.
    // First will be finished (which generates status), second will be frozen.
    int twiceGetMsgCnt = SERVER_NODE_CNT * (SERVER_NODE_CNT - 1) * 2;
    for (IgniteEx server : srvs) {
        TestRecordingCommunicationSpi spi = ((TestRecordingCommunicationSpi) server.configuration().getCommunicationSpi());
        AtomicInteger locLimit = new AtomicInteger(SERVER_NODE_CNT - 1);
        spi.blockMessages((node, message) -> {
            if (message instanceof GridNearGetRequest) {
                // Each node should perform get twice.
                if (getCnt.incrementAndGet() == twiceGetMsgCnt)
                    th.start();
                // Cancellation should stop the process.
                assertTrue(getCnt.get() <= twiceGetMsgCnt);
                // Blocking to freeze '--consistency repair' operation (except first get).
                return locLimit.decrementAndGet() < 0;
            }
            return false;
        });
    }
    injectTestSystemOut();
    assertEquals(EXIT_CODE_UNEXPECTED_ERROR, execute("--consistency", "repair", ConsistencyCommand.STRATEGY, ReadRepairStrategy.LWW.toString(), ConsistencyCommand.PARTITION, "0", ConsistencyCommand.CACHE, consistencyCacheName));
    assertContains(log, testOut.toString(), "Operation execution cancelled.");
    assertContains(log, testOut.toString(), VisorConsistencyRepairTask.NOTHING_FOUND);
    assertNotContains(log, testOut.toString(), VisorConsistencyRepairTask.CONSISTENCY_VIOLATIONS_FOUND);
    thLatch.await();
    for (IgniteEx server : srvs) {
        // Restoring messaging for other tests.
        TestRecordingCommunicationSpi spi = ((TestRecordingCommunicationSpi) server.configuration().getCommunicationSpi());
        spi.stopBlock();
    }
    testOut.reset();
    int res = execute("--consistency", "status");
    assertEquals(EXIT_CODE_OK, res);
    assertContains(log, testOut.toString(), VisorConsistencyStatusTask.NOTHING_FOUND);
    assertNotContains(log, testOut.toString(), "Status");
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) KillCommandsTests.doTestScanQueryCancel(org.apache.ignite.util.KillCommandsTests.doTestScanQueryCancel) KillCommandsTests.doTestCancelService(org.apache.ignite.util.KillCommandsTests.doTestCancelService) IgniteEx(org.apache.ignite.internal.IgniteEx) EXIT_CODE_OK(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_OK) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) ArrayList(java.util.ArrayList) KillCommandsTests.doTestCancelSQLQuery(org.apache.ignite.util.KillCommandsTests.doTestCancelSQLQuery) KillCommandsTests.doTestCancelTx(org.apache.ignite.util.KillCommandsTests.doTestCancelTx) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) VisorConsistencyStatusTask(org.apache.ignite.internal.visor.consistency.VisorConsistencyStatusTask) GridTestUtils.assertNotContains(org.apache.ignite.testframework.GridTestUtils.assertNotContains) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) F(org.apache.ignite.internal.util.typedef.F) KillCommandsTests.doTestCancelComputeTask(org.apache.ignite.util.KillCommandsTests.doTestCancelComputeTask) SystemView(org.apache.ignite.spi.systemview.view.SystemView) JOBS_VIEW(org.apache.ignite.internal.processors.job.GridJobProcessor.JOBS_VIEW) ReadRepairStrategy(org.apache.ignite.cache.ReadRepairStrategy) Test(org.junit.Test) UUID(java.util.UUID) IgniteCache(org.apache.ignite.IgniteCache) ConsistencyCommand(org.apache.ignite.internal.commandline.consistency.ConsistencyCommand) EXIT_CODE_UNEXPECTED_ERROR(org.apache.ignite.internal.commandline.CommandHandler.EXIT_CODE_UNEXPECTED_ERROR) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) GridTestUtils.assertContains(org.apache.ignite.testframework.GridTestUtils.assertContains) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) PAGES_CNT(org.apache.ignite.util.KillCommandsTests.PAGES_CNT) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest) VisorConsistencyRepairTask(org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTask) ComputeJobView(org.apache.ignite.spi.systemview.view.ComputeJobView) KillCommandsTests.doTestCancelContinuousQuery(org.apache.ignite.util.KillCommandsTests.doTestCancelContinuousQuery) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) PAGE_SZ(org.apache.ignite.util.KillCommandsTests.PAGE_SZ) IgniteUuid(org.apache.ignite.lang.IgniteUuid) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ComputeJobView(org.apache.ignite.spi.systemview.view.ComputeJobView) SystemView(org.apache.ignite.spi.systemview.view.SystemView) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) VisorConsistencyRepairTask(org.apache.ignite.internal.visor.consistency.VisorConsistencyRepairTask) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Test(org.junit.Test) AbstractSnapshotSelfTest.doSnapshotCancellationTest(org.apache.ignite.internal.processors.cache.persistence.snapshot.AbstractSnapshotSelfTest.doSnapshotCancellationTest)

Example 3 with GridNearGetRequest

use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest in project ignite by apache.

the class GridDhtTransactionalCacheAdapter method start.

/** {@inheritDoc} */
@Override
public void start() throws IgniteCheckedException {
    super.start();
    preldr = new GridDhtPreloader(ctx);
    preldr.start();
    ctx.io().addHandler(ctx.cacheId(), GridNearGetRequest.class, new CI2<UUID, GridNearGetRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearGetRequest req) {
            processNearGetRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridNearSingleGetRequest.class, new CI2<UUID, GridNearSingleGetRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearSingleGetRequest req) {
            processNearSingleGetRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridNearLockRequest.class, new CI2<UUID, GridNearLockRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearLockRequest req) {
            processNearLockRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridDhtLockRequest.class, new CI2<UUID, GridDhtLockRequest>() {

        @Override
        public void apply(UUID nodeId, GridDhtLockRequest req) {
            processDhtLockRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridDhtLockResponse.class, new CI2<UUID, GridDhtLockResponse>() {

        @Override
        public void apply(UUID nodeId, GridDhtLockResponse req) {
            processDhtLockResponse(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridNearUnlockRequest.class, new CI2<UUID, GridNearUnlockRequest>() {

        @Override
        public void apply(UUID nodeId, GridNearUnlockRequest req) {
            processNearUnlockRequest(nodeId, req);
        }
    });
    ctx.io().addHandler(ctx.cacheId(), GridDhtUnlockRequest.class, new CI2<UUID, GridDhtUnlockRequest>() {

        @Override
        public void apply(UUID nodeId, GridDhtUnlockRequest req) {
            processDhtUnlockRequest(nodeId, req);
        }
    });
}
Also used : GridNearLockRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearLockRequest) GridNearUnlockRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearUnlockRequest) GridDhtPreloader(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPreloader) GridNearSingleGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) UUID(java.util.UUID)

Example 4 with GridNearGetRequest

use of org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest in project ignite by apache.

the class CacheMvccAbstractBasicCoordinatorFailoverTest method readInProgressCoordinatorFails.

/**
 * @param readDelay {@code True} if delays get requests.
 * @param readInTx {@code True} to read inside transaction.
 * @throws Exception If failed.
 */
@SuppressWarnings("unchecked")
protected void readInProgressCoordinatorFails(boolean readDelay, final boolean readInTx, final TransactionConcurrency concurrency, final TransactionIsolation isolation, ReadMode readMode, WriteMode writeMode, @Nullable IgniteInClosure<CacheConfiguration> cfgC) throws Exception {
    final int COORD_NODES = 5;
    final int SRV_NODES = 4;
    if (readDelay)
        testSpi = true;
    startGrids(COORD_NODES);
    startGridsMultiThreaded(COORD_NODES, SRV_NODES);
    client = true;
    Ignite client = startGrid(COORD_NODES + SRV_NODES);
    final List<String> cacheNames = new ArrayList<>();
    final int KEYS = 100;
    final Map<Integer, Integer> vals = new LinkedHashMap<>();
    for (int i = 0; i < KEYS; i++) vals.put(i, 0);
    String[] exclude = new String[COORD_NODES];
    for (int i = 0; i < COORD_NODES; i++) exclude[i] = testNodeName(i);
    for (CacheConfiguration ccfg : cacheConfigurations()) {
        ccfg.setName("cache-" + cacheNames.size());
        if (cfgC != null)
            cfgC.apply(ccfg);
        // First server nodes are 'dedicated' coordinators.
        ccfg.setNodeFilter(new TestCacheNodeExcludingFilter(exclude));
        cacheNames.add(ccfg.getName());
        IgniteCache cache = client.createCache(ccfg);
        boolean updated = false;
        while (!updated) {
            try (Transaction tx = client.transactions().txStart(concurrency, isolation)) {
                tx.timeout(TX_TIMEOUT);
                writeAllByMode(cache, vals, writeMode, INTEGER_CODEC);
                tx.commit();
                updated = true;
            } catch (Exception e) {
                handleTxException(e);
            }
        }
    }
    if (readDelay) {
        for (int i = COORD_NODES; i < COORD_NODES + SRV_NODES + 1; i++) {
            TestRecordingCommunicationSpi.spi(ignite(i)).closure(new IgniteBiInClosure<ClusterNode, Message>() {

                @Override
                public void apply(ClusterNode node, Message msg) {
                    if (msg instanceof GridNearGetRequest)
                        doSleep(ThreadLocalRandom.current().nextLong(50) + 1);
                }
            });
        }
    }
    final AtomicBoolean done = new AtomicBoolean();
    try {
        final AtomicInteger readNodeIdx = new AtomicInteger(0);
        IgniteInternalFuture getFut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                try {
                    Ignite node = ignite(COORD_NODES + (readNodeIdx.getAndIncrement() % (SRV_NODES + 1)));
                    int cnt = 0;
                    while (!done.get() && !Thread.currentThread().isInterrupted()) {
                        for (String cacheName : cacheNames) {
                            IgniteCache cache = node.cache(cacheName);
                            Map<Integer, Integer> res = null;
                            if (readInTx) {
                                try (Transaction tx = node.transactions().txStart(concurrency, isolation)) {
                                    tx.timeout(TX_TIMEOUT);
                                    res = readAllByMode(cache, vals.keySet(), readMode, INTEGER_CODEC);
                                    tx.commit();
                                } catch (Exception e) {
                                    // TODO Remove catch clause when IGNITE-8841 implemented.
                                    handleTxException(e);
                                }
                            } else
                                res = readAllByMode(cache, vals.keySet(), readMode, INTEGER_CODEC);
                            if (readInTx) {
                                // TODO IGNITE-8841
                                assertTrue("res.size=" + (res == null ? 0 : res.size()) + ", res=" + res, res == null || vals.size() == res.size());
                            } else {
                                assertEquals(vals.size(), res.size());
                                Integer val0 = null;
                                for (Integer val : res.values()) {
                                    if (val0 == null)
                                        val0 = val;
                                    else
                                        assertEquals(val0, val);
                                }
                            }
                        }
                        cnt++;
                    }
                    log.info("Finished [node=" + node.name() + ", readCnt=" + cnt + ']');
                    return null;
                } catch (Throwable e) {
                    error("Unexpected error: " + e, e);
                    throw e;
                }
            }
        }, ((SRV_NODES + 1) + 1) * 2, "get-thread");
        IgniteInternalFuture putFut1 = GridTestUtils.runAsync(new Callable() {

            @Override
            public Void call() throws Exception {
                Ignite node = ignite(COORD_NODES);
                List<IgniteCache> caches = new ArrayList<>();
                for (String cacheName : cacheNames) caches.add(node.cache(cacheName));
                Integer val = 1;
                while (!done.get()) {
                    Map<Integer, Integer> vals = new LinkedHashMap<>();
                    for (int i = 0; i < KEYS; i++) vals.put(i, val);
                    for (IgniteCache cache : caches) {
                        try {
                            try (Transaction tx = node.transactions().txStart(concurrency, isolation)) {
                                tx.timeout(TX_TIMEOUT);
                                writeAllByMode(cache, vals, writeMode, INTEGER_CODEC);
                                tx.commit();
                            }
                        } catch (Exception e) {
                            handleTxException(e);
                        }
                    }
                    val++;
                }
                return null;
            }
        }, "putAll-thread");
        IgniteInternalFuture putFut2 = GridTestUtils.runAsync(new Callable() {

            @Override
            public Void call() throws Exception {
                Ignite node = ignite(COORD_NODES);
                IgniteCache cache = node.cache(cacheNames.get(0));
                Integer val = 0;
                while (!done.get()) {
                    try {
                        try (Transaction tx = node.transactions().txStart(concurrency, isolation)) {
                            tx.timeout(TX_TIMEOUT);
                            writeByMode(cache, Integer.MAX_VALUE, val, writeMode, INTEGER_CODEC);
                            tx.commit();
                        }
                    } catch (Exception e) {
                        handleTxException(e);
                    }
                    val++;
                }
                return null;
            }
        }, "put-thread");
        for (int i = 0; i < COORD_NODES && !getFut.isDone(); i++) {
            U.sleep(3000);
            stopGrid(i);
            awaitPartitionMapExchange();
        }
        done.set(true);
        getFut.get();
        putFut1.get();
        putFut2.get();
        for (Ignite node : G.allGrids()) checkActiveQueriesCleanup(node);
    } finally {
        done.set(true);
    }
}
Also used : Message(org.apache.ignite.plugin.extensions.communication.Message) ArrayList(java.util.ArrayList) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Callable(java.util.concurrent.Callable) LinkedHashMap(java.util.LinkedHashMap) GridNearGetRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest) Ignite(org.apache.ignite.Ignite) ArrayList(java.util.ArrayList) List(java.util.List) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) ClusterNode(org.apache.ignite.cluster.ClusterNode) TestCacheNodeExcludingFilter(org.apache.ignite.internal.processors.cache.distributed.TestCacheNodeExcludingFilter) IgniteCache(org.apache.ignite.IgniteCache) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) CacheException(javax.cache.CacheException) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Transaction(org.apache.ignite.transactions.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

GridNearGetRequest (org.apache.ignite.internal.processors.cache.distributed.near.GridNearGetRequest)4 UUID (java.util.UUID)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 IgniteCache (org.apache.ignite.IgniteCache)2 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 GridNearSingleGetRequest (org.apache.ignite.internal.processors.cache.distributed.near.GridNearSingleGetRequest)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 CacheException (javax.cache.CacheException)1 Ignite (org.apache.ignite.Ignite)1 CacheAtomicityMode (org.apache.ignite.cache.CacheAtomicityMode)1 ReadRepairStrategy (org.apache.ignite.cache.ReadRepairStrategy)1 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)1 ClusterTopologyException (org.apache.ignite.cluster.ClusterTopologyException)1