Search in sources :

Example 1 with G

use of org.apache.ignite.internal.util.typedef.G in project ignite by apache.

the class ZookeeperDiscoverySplitBrainTest method testSimpleSplitBrain.

/**
 * A simple split-brain test, where cluster spliited on 2 parts of server nodes (2 and 3).
 * There is also client which sees both parts of splitted cluster.
 *
 * Result cluster should be: 3 server nodes + 1 client.
 *
 * @throws Exception If failed.
 */
@Test
public void testSimpleSplitBrain() throws Exception {
    failCommSpi = true;
    startGridsMultiThreaded(5);
    startClientGridsMultiThreaded(5, 3);
    awaitPartitionMapExchange();
    List<ClusterNode> all = G.allGrids().stream().map(g -> g.cluster().localNode()).collect(Collectors.toList());
    List<ClusterNode> part1 = all.subList(0, 3);
    List<ClusterNode> part2 = all.subList(3, all.size());
    ConnectionsFailureMatrix matrix = ConnectionsFailureMatrix.buildFrom(part1, part2);
    ClusterNode lastClient = startGrid(8).cluster().localNode();
    awaitPartitionMapExchange();
    // Make last client connected to other nodes.
    for (ClusterNode node : all) {
        if (node.id().equals(lastClient.id()))
            continue;
        matrix.addConnection(lastClient, node);
        matrix.addConnection(node, lastClient);
    }
    PeerToPeerCommunicationFailureSpi.fail(matrix);
    waitForTopology(4);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) G(org.apache.ignite.internal.util.typedef.G) Set(java.util.Set) HashMap(java.util.HashMap) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) List(java.util.List) ClusterNode(org.apache.ignite.cluster.ClusterNode) Map(java.util.Map) Assert(org.junit.Assert) Collections(java.util.Collections) Test(org.junit.Test)

Example 2 with G

use of org.apache.ignite.internal.util.typedef.G in project ignite by apache.

the class IgniteLogicalRecoveryWithParamsTest method testPartiallyCommitedTx.

/**
 * Tests concurrent tx with node stop and further recovery.
 */
private void testPartiallyCommitedTx() throws Exception {
    final String cacheName = "recovery";
    int itmsCount = 30_000;
    AtomicBoolean failFileIO = new AtomicBoolean();
    List<Integer> keys;
    CacheConfiguration<Integer, Integer> cfg = new CacheConfiguration<Integer, Integer>(cacheName).setCacheMode(CacheMode.PARTITIONED).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC).setBackups(backups).setAffinity(new RendezvousAffinityFunction(false, 32));
    try {
        final IgniteEx srv = (IgniteEx) startGridsMultiThreaded(numSrvNodes);
        G.allGrids().forEach(n -> setWalIOFactory(n, failFileIO));
        IgniteEx clnt = startClientGrid("client");
        TestRecordingCommunicationSpi nearComm = TestRecordingCommunicationSpi.spi(clnt);
        srv.cluster().state(ClusterState.ACTIVE);
        final IgniteCache cache = clnt.getOrCreateCache(cfg);
        final CountDownLatch commitStart = new CountDownLatch(1);
        forceCheckpoint();
        nearComm.blockMessages((node, msg) -> msg instanceof GridNearTxPrepareRequest);
        if (singleNodeTx)
            keys = primaryKeys(srv.cache(cacheName), itmsCount, 0);
        else
            keys = IntStream.range(0, itmsCount).boxed().collect(Collectors.toList());
        Thread t = new Thread(() -> {
            try (Transaction tx = clnt.transactions().txStart(PESSIMISTIC, READ_COMMITTED)) {
                keys.forEach(k -> cache.put(k, k));
                commitStart.countDown();
                tx.commit();
            }
        });
        t.start();
        commitStart.await();
        nearComm.waitForBlocked();
        nearComm.stopBlock();
        assertTrue(waitForWalUpdates(G.allGrids().stream().filter(g -> !g.configuration().isClientMode()).collect(Collectors.toList())));
    } finally {
        failFileIO.set(true);
        stopAllGrids(true);
        assertTrue(G.allGrids().isEmpty());
    }
    final IgniteEx srv = (IgniteEx) startGridsMultiThreaded(numSrvNodes);
    srv.cluster().state(ClusterState.ACTIVE);
    IgniteCache<Integer, Integer> cache = srv.cache(cacheName);
    int cSize = cache.size();
    boolean pr = cache.get(keys.get(0)) == null;
    for (int i : keys) {
        Object res = cache.get(i);
        if (pr != (res == null))
            assertEquals("ethalon=" + pr + ", current=" + res + ", key=" + i, pr, res == null);
    }
    assert (cSize == itmsCount || cSize == 0) : "unexpected cache size: " + cSize;
}
Also used : IntStream(java.util.stream.IntStream) CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) Arrays(java.util.Arrays) Transaction(org.apache.ignite.transactions.Transaction) ClusterState(org.apache.ignite.cluster.ClusterState) RunWith(org.junit.runner.RunWith) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) FileWriteHandle(org.apache.ignite.internal.processors.cache.persistence.wal.filehandle.FileWriteHandle) ByteBuffer(java.nio.ByteBuffer) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) CacheWriteSynchronizationMode(org.apache.ignite.cache.CacheWriteSynchronizationMode) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) GridNearTxPrepareRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest) FileIODecorator(org.apache.ignite.internal.processors.cache.persistence.file.FileIODecorator) IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP) Parameterized(org.junit.runners.Parameterized) G(org.apache.ignite.internal.util.typedef.G) WALMode(org.apache.ignite.configuration.WALMode) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) OpenOption(java.nio.file.OpenOption) Collection(java.util.Collection) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) READ_COMMITTED(org.apache.ignite.transactions.TransactionIsolation.READ_COMMITTED) IOException(java.io.IOException) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) Collectors(java.util.stream.Collectors) File(java.io.File) IgniteCache(org.apache.ignite.IgniteCache) StopNodeFailureHandler(org.apache.ignite.failure.StopNodeFailureHandler) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) PESSIMISTIC(org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC) DFLT_BUSYWAIT_SLEEP_INTERVAL(org.apache.ignite.testframework.GridTestUtils.DFLT_BUSYWAIT_SLEEP_INTERVAL) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) MappedByteBuffer(java.nio.MappedByteBuffer) CacheMode(org.apache.ignite.cache.CacheMode) IgniteCache(org.apache.ignite.IgniteCache) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Transaction(org.apache.ignite.transactions.Transaction) IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) GridNearTxPrepareRequest(org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxPrepareRequest)

Example 3 with G

use of org.apache.ignite.internal.util.typedef.G in project ignite by apache.

the class IgniteSnapshotRemoteRequestTest method testSnapshotRemoteRequestEachOther.

/**
 * @throws Exception If fails.
 */
@Test
public void testSnapshotRemoteRequestEachOther() throws Exception {
    IgniteEx ignite = startGridsWithCache(2, CACHE_KEYS_RANGE, valueBuilder(), dfltCacheCfg);
    ignite.snapshot().createSnapshot(SNAPSHOT_NAME).get(TIMEOUT);
    IgniteSnapshotManager mgr0 = snp(ignite);
    IgniteSnapshotManager mgr1 = snp(grid(1));
    UUID node0 = grid(0).localNode().id();
    UUID node1 = grid(1).localNode().id();
    Map<Integer, Set<Integer>> fromNode1 = owningParts(ignite, CU.cacheId(DEFAULT_CACHE_NAME), node1);
    Map<Integer, Set<Integer>> fromNode0 = owningParts(grid(1), CU.cacheId(DEFAULT_CACHE_NAME), node0);
    G.allGrids().forEach(g -> TestRecordingCommunicationSpi.spi(g).blockMessages((n, msg) -> msg instanceof SnapshotFilesRequestMessage));
    CountDownLatch latch = new CountDownLatch(fromNode1.values().stream().mapToInt(Set::size).sum() + fromNode0.values().stream().mapToInt(Set::size).sum());
    // Snapshot must be taken on node1 and transmitted to node0.
    IgniteInternalFuture<?> futFrom1To0 = mgr0.requestRemoteSnapshotFiles(node1, SNAPSHOT_NAME, fromNode1, () -> false, defaultPartitionConsumer(fromNode1, latch));
    IgniteInternalFuture<?> futFrom0To1 = mgr1.requestRemoteSnapshotFiles(node0, SNAPSHOT_NAME, fromNode0, () -> false, defaultPartitionConsumer(fromNode0, latch));
    G.allGrids().forEach(g -> TestRecordingCommunicationSpi.spi(g).stopBlock());
    latch.await(TIMEOUT, TimeUnit.MILLISECONDS);
    futFrom0To1.get(TIMEOUT);
    futFrom1To0.get(TIMEOUT);
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) BiFunction(java.util.function.BiFunction) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) GridCompoundFuture(org.apache.ignite.internal.util.future.GridCompoundFuture) U(org.apache.ignite.internal.util.typedef.internal.U) HashMap(java.util.HashMap) IgniteEx(org.apache.ignite.internal.IgniteEx) HashSet(java.util.HashSet) Map(java.util.Map) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) BiConsumer(java.util.function.BiConsumer) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) GridDhtPartitionState(org.apache.ignite.internal.processors.cache.distributed.dht.topology.GridDhtPartitionState) GridTestUtils.assertThrowsAnyCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause) G(org.apache.ignite.internal.util.typedef.G) F(org.apache.ignite.internal.util.typedef.F) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId) FilePageStoreManager.cacheGroupName(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.cacheGroupName) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) Set(java.util.Set) ClusterTopologyCheckedException(org.apache.ignite.internal.cluster.ClusterTopologyCheckedException) Test(org.junit.Test) UUID(java.util.UUID) TransmissionCancelledException(org.apache.ignite.internal.managers.communication.TransmissionCancelledException) Collectors(java.util.stream.Collectors) File(java.io.File) FilePageStoreManager.partId(org.apache.ignite.internal.processors.cache.persistence.file.FilePageStoreManager.partId) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) TimeUnit(java.util.concurrent.TimeUnit) CountDownLatch(java.util.concurrent.CountDownLatch) CU(org.apache.ignite.internal.util.typedef.internal.CU) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Collections(java.util.Collections) HashSet(java.util.HashSet) Set(java.util.Set) IgniteEx(org.apache.ignite.internal.IgniteEx) UUID(java.util.UUID) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 4 with G

use of org.apache.ignite.internal.util.typedef.G in project ignite by apache.

the class IgniteClusterSnapshotSelfTest method testSnapshotPrimaryBackupsTheSame.

/**
 * @throws Exception If fails.
 */
@Test
public void testSnapshotPrimaryBackupsTheSame() throws Exception {
    int grids = 3;
    AtomicInteger cacheKey = new AtomicInteger();
    IgniteEx ignite = startGridsWithCache(grids, dfltCacheCfg, CACHE_KEYS_RANGE);
    IgniteInternalFuture<Long> atLoadFut = GridTestUtils.runMultiThreadedAsync(() -> {
        while (!Thread.currentThread().isInterrupted()) {
            ThreadLocalRandom rnd = ThreadLocalRandom.current();
            int gId = rnd.nextInt(grids);
            IgniteCache<Integer, Integer> txCache = grid(gId).getOrCreateCache(dfltCacheCfg.getName());
            try (Transaction tx = grid(gId).transactions().txStart()) {
                txCache.put(cacheKey.incrementAndGet(), 0);
                txCache.put(cacheKey.incrementAndGet(), 1);
                tx.commit();
            }
        }
    }, 5, "tx-cache-put-");
    IgniteInternalFuture<Long> txLoadFut = GridTestUtils.runMultiThreadedAsync(() -> {
        while (!Thread.currentThread().isInterrupted()) {
            ThreadLocalRandom rnd = ThreadLocalRandom.current();
            IgniteCache<Integer, Integer> atomicCache = grid(rnd.nextInt(grids)).getOrCreateCache(atomicCcfg);
            atomicCache.put(cacheKey.incrementAndGet(), 0);
        }
    }, 5, "atomic-cache-put-");
    try {
        IgniteFuture<Void> fut = ignite.snapshot().createSnapshot(SNAPSHOT_NAME);
        fut.get();
    } finally {
        txLoadFut.cancel();
        atLoadFut.cancel();
    }
    stopAllGrids();
    IgniteEx snpIg0 = startGridsFromSnapshot(grids, cfg -> resolveSnapshotWorkDirectory(cfg).getAbsolutePath(), SNAPSHOT_NAME, false);
    // Block whole rebalancing.
    for (Ignite g : G.allGrids()) TestRecordingCommunicationSpi.spi(g).blockMessages((node, msg) -> msg instanceof GridDhtPartitionDemandMessage);
    snpIg0.cluster().state(ACTIVE);
    assertFalse("Primary and backup in snapshot must have the same counters. Rebalance must not happen.", GridTestUtils.waitForCondition(() -> {
        boolean hasMsgs = false;
        for (Ignite g : G.allGrids()) hasMsgs |= TestRecordingCommunicationSpi.spi(g).hasBlockedMessages();
        return hasMsgs;
    }, REBALANCE_AWAIT_TIME));
    TestRecordingCommunicationSpi.stopBlockAll();
    assertPartitionsSame(idleVerify(snpIg0, dfltCacheCfg.getName(), atomicCcfg.getName()));
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) DiscoveryCustomEvent(org.apache.ignite.internal.events.DiscoveryCustomEvent) Arrays(java.util.Arrays) EVT_CLUSTER_SNAPSHOT_FINISHED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FINISHED) SNP_NODE_STOPPING_ERR_MSG(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNP_NODE_STOPPING_ERR_MSG) SNAPSHOT_METRICS(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNAPSHOT_METRICS) Transaction(org.apache.ignite.transactions.Transaction) GridDhtPartitionsAbstractMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsAbstractMessage) IgniteEx(org.apache.ignite.internal.IgniteEx) GridDhtPartitionSupplyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) FileIO(org.apache.ignite.internal.processors.cache.persistence.file.FileIO) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Map(java.util.Map) GridTestUtils.assertThrowsAnyCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsAnyCause) IgniteFuture(org.apache.ignite.lang.IgniteFuture) RandomAccessFileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.RandomAccessFileIOFactory) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) SingleNodeMessage(org.apache.ignite.internal.util.distributed.SingleNodeMessage) Predicate(java.util.function.Predicate) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) IgniteException(org.apache.ignite.IgniteException) CacheGroupDescriptor(org.apache.ignite.internal.processors.cache.CacheGroupDescriptor) IgniteSnapshotManager.isSnapshotOperation(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.isSnapshotOperation) UUID(java.util.UUID) IgniteCache(org.apache.ignite.IgniteCache) Serializable(java.io.Serializable) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) CountDownLatch(java.util.concurrent.CountDownLatch) ObjectGauge(org.apache.ignite.internal.processors.metric.impl.ObjectGauge) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridDhtPartitionDemandMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage) CU(org.apache.ignite.internal.util.typedef.internal.CU) GridCacheRebalancingSyncSelfTest.checkPartitionMapExchangeFinished(org.apache.ignite.internal.processors.cache.distributed.rebalancing.GridCacheRebalancingSyncSelfTest.checkPartitionMapExchangeFinished) Queue(java.util.Queue) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) ScanQuery(org.apache.ignite.cache.query.ScanQuery) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) NodeStoppingException(org.apache.ignite.internal.NodeStoppingException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) U(org.apache.ignite.internal.util.typedef.internal.U) EVT_DISCOVERY_CUSTOM_EVT(org.apache.ignite.internal.events.DiscoveryCustomEvent.EVT_DISCOVERY_CUSTOM_EVT) IgniteSnapshotManager.resolveSnapshotWorkDirectory(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.resolveSnapshotWorkDirectory) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) ClusterTopologyException(org.apache.ignite.cluster.ClusterTopologyException) EVT_CLUSTER_SNAPSHOT_STARTED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_STARTED) Function(java.util.function.Function) EVT_CLUSTER_SNAPSHOT_FAILED(org.apache.ignite.events.EventType.EVT_CLUSTER_SNAPSHOT_FAILED) SNP_IN_PROGRESS_ERR_MSG(org.apache.ignite.internal.processors.cache.persistence.snapshot.IgniteSnapshotManager.SNP_IN_PROGRESS_ERR_MSG) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) FileIOFactory(org.apache.ignite.internal.processors.cache.persistence.file.FileIOFactory) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) Before(org.junit.Before) G(org.apache.ignite.internal.util.typedef.G) ACTIVE(org.apache.ignite.cluster.ClusterState.ACTIVE) DistributedProcess(org.apache.ignite.internal.util.distributed.DistributedProcess) EVTS_CLUSTER_SNAPSHOT(org.apache.ignite.events.EventType.EVTS_CLUSTER_SNAPSHOT) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId) OpenOption(java.nio.file.OpenOption) IOException(java.io.IOException) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) GridDhtPartitionsSingleMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage) MetricRegistry(org.apache.ignite.internal.processors.metric.MetricRegistry) FullMessage(org.apache.ignite.internal.util.distributed.FullMessage) File(java.io.File) T2(org.apache.ignite.internal.util.typedef.T2) TimeUnit(java.util.concurrent.TimeUnit) PartitionsExchangeAware(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware) Ignition(org.apache.ignite.Ignition) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridDhtPartitionExchangeId(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionExchangeId) LongMetric(org.apache.ignite.spi.metric.LongMetric) Collections(java.util.Collections) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Transaction(org.apache.ignite.transactions.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) IgniteEx(org.apache.ignite.internal.IgniteEx) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) Ignite(org.apache.ignite.Ignite) GridDhtPartitionDemandMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionDemandMessage) Test(org.junit.Test)

Example 5 with G

use of org.apache.ignite.internal.util.typedef.G in project ignite by apache.

the class RunningQueriesTest method assertNoRunningQueries.

/**
 * Check all nodes except passed as parameter on no any running queries.
 *
 * @param excludeNodes Nodes which will be excluded from check.
 */
private void assertNoRunningQueries(IgniteEx... excludeNodes) {
    Set<UUID> excludeIds = Stream.of(excludeNodes).map((ignite) -> ignite.localNode().id()).collect(Collectors.toSet());
    for (Ignite g : G.allGrids()) {
        IgniteEx node = (IgniteEx) g;
        if (!excludeIds.contains(node.localNode().id())) {
            Collection<GridRunningQueryInfo> runningQueries = node.context().query().runningQueries(-1);
            Assert.assertEquals(0, runningQueries.size());
        }
    }
}
Also used : IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Connection(java.sql.Connection) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) GridNearAtomicFullUpdateRequest(org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicFullUpdateRequest) TimeoutException(java.util.concurrent.TimeoutException) IgniteEx(org.apache.ignite.internal.IgniteEx) SqlQuery(org.apache.ignite.cache.query.SqlQuery) Cache(javax.cache.Cache) QueryEntity(org.apache.ignite.cache.QueryEntity) CyclicBarrier(java.util.concurrent.CyclicBarrier) IgniteInClosure(org.apache.ignite.lang.IgniteInClosure) Collection(java.util.Collection) IgniteException(org.apache.ignite.IgniteException) Set(java.util.Set) Description(org.junit.runner.Description) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IgniteCache(org.apache.ignite.IgniteCache) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) Objects(java.util.Objects) TestWatcher(org.junit.rules.TestWatcher) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) Message(org.apache.ignite.plugin.extensions.communication.Message) FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) IgniteUtils.resolveIgnitePath(org.apache.ignite.internal.util.IgniteUtils.resolveIgnitePath) CustomMessageWrapper(org.apache.ignite.internal.managers.discovery.CustomMessageWrapper) GridNearAtomicSingleUpdateFilterRequest(org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFilterRequest) SQLException(java.sql.SQLException) ClusterNode(org.apache.ignite.cluster.ClusterNode) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) IgniteH2Indexing(org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) G(org.apache.ignite.internal.util.typedef.G) SchemaProposeDiscoveryMessage(org.apache.ignite.internal.processors.query.schema.message.SchemaProposeDiscoveryMessage) AbstractIndexingCommonTest(org.apache.ignite.internal.processors.cache.index.AbstractIndexingCommonTest) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) TimeUnit(java.util.concurrent.TimeUnit) Rule(org.junit.Rule) Ignore(org.junit.Ignore) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) Statement(java.sql.Statement) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) Assert(org.junit.Assert) Collections(java.util.Collections) DynamicCacheChangeBatch(org.apache.ignite.internal.processors.cache.DynamicCacheChangeBatch) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID)

Aggregations

G (org.apache.ignite.internal.util.typedef.G)6 Test (org.junit.Test)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 IgniteEx (org.apache.ignite.internal.IgniteEx)5 IgniteInterruptedCheckedException (org.apache.ignite.internal.IgniteInterruptedCheckedException)5 Collections (java.util.Collections)4 UUID (java.util.UUID)4 CountDownLatch (java.util.concurrent.CountDownLatch)4 TimeUnit (java.util.concurrent.TimeUnit)4 Ignite (org.apache.ignite.Ignite)4 IgniteCache (org.apache.ignite.IgniteCache)4 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)4 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)4 File (java.io.File)3 Collection (java.util.Collection)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Set (java.util.Set)3 IgniteException (org.apache.ignite.IgniteException)3