Search in sources :

Example 26 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class IgniteCacheReadFromBackupTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    return cfg;
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Example 27 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class GridCacheDhtPreloadMessageCountTest method testAutomaticPreload.

/**
     * @throws Exception If failed.
     */
public void testAutomaticPreload() throws Exception {
    Ignite g0 = startGrid(0);
    int cnt = KEY_CNT;
    IgniteCache<String, Integer> c0 = g0.cache(DEFAULT_CACHE_NAME);
    for (int i = 0; i < cnt; i++) c0.put(Integer.toString(i), i);
    Ignite g1 = startGrid(1);
    Ignite g2 = startGrid(2);
    U.sleep(1000);
    IgniteCache<String, Integer> c1 = g1.cache(DEFAULT_CACHE_NAME);
    IgniteCache<String, Integer> c2 = g2.cache(DEFAULT_CACHE_NAME);
    TestRecordingCommunicationSpi spi0 = (TestRecordingCommunicationSpi) g0.configuration().getCommunicationSpi();
    TestRecordingCommunicationSpi spi1 = (TestRecordingCommunicationSpi) g1.configuration().getCommunicationSpi();
    TestRecordingCommunicationSpi spi2 = (TestRecordingCommunicationSpi) g2.configuration().getCommunicationSpi();
    info(spi0.recordedMessages(false).size() + " " + spi1.recordedMessages(false).size() + " " + spi2.recordedMessages(false).size());
    checkCache(c0, cnt);
    checkCache(c1, cnt);
    checkCache(c2, cnt);
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite)

Example 28 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheExchangeMessageDuplicatedStateTest method checkFullMessages.

/**
     * @param crdIdx Coordinator node index.
     */
private void checkFullMessages(int crdIdx) {
    TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ignite(crdIdx).configuration().getCommunicationSpi();
    List<Object> msgs = commSpi0.recordedMessages(false);
    assertTrue(msgs.size() > 0);
    for (Object msg : msgs) {
        assertTrue("Unexpected messages: " + msg, msg instanceof GridDhtPartitionsFullMessage);
        checkFullMessage((GridDhtPartitionsFullMessage) msg);
    }
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) GridDhtPartitionsFullMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage)

Example 29 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheLateAffinityAssignmentTest method testJoinExchangeBecomeCoordinator.

/**
     * @throws Exception If failed.
     */
public void testJoinExchangeBecomeCoordinator() throws Exception {
    long topVer = 0;
    final int NODES = 3;
    for (int i = 0; i < NODES; i++) startServer(i, ++topVer);
    checkAffinity(NODES, topVer(topVer, 1), true);
    for (int i = 0; i < NODES; i++) {
        TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi) ignite(i).configuration().getCommunicationSpi();
        spi.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {

            @Override
            public boolean apply(ClusterNode node, Message msg) {
                return msg.getClass().equals(GridDhtPartitionsSingleMessage.class) || msg.getClass().equals(GridDhtPartitionsFullMessage.class);
            }
        });
    }
    final CountDownLatch latch = new CountDownLatch(1);
    IgniteInternalFuture<?> stopFut = GridTestUtils.runAsync(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            latch.await();
            U.sleep(5000);
            for (int i = 0; i < NODES; i++) stopGrid(getTestIgniteInstanceName(i), false, false);
            return null;
        }
    }, "stop-thread");
    latch.countDown();
    Ignite node = startGrid(NODES);
    assertEquals(NODES + 1, node.cluster().localNode().order());
    stopFut.get();
    for (int i = 0; i < NODES + 1; i++) calculateAffinity(++topVer);
    checkAffinity(1, topVer(topVer, 0), true);
    for (int i = 0; i < NODES; i++) startServer(i, ++topVer);
    checkAffinity(NODES + 1, topVer(topVer, 1), true);
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridDhtPartitionSupplyMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage) GridIoMessage(org.apache.ignite.internal.managers.communication.GridIoMessage) DiscoverySpiCustomMessage(org.apache.ignite.spi.discovery.DiscoverySpiCustomMessage) Message(org.apache.ignite.plugin.extensions.communication.Message) DiscoveryCustomMessage(org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage) GridDhtPartitionsSingleMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage) GridDhtPartitionsFullMessage(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage) CacheAffinityChangeMessage(org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteException(org.apache.ignite.IgniteException) ClusterTopologyServerNotFoundException(org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite)

Example 30 with TestRecordingCommunicationSpi

use of org.apache.ignite.internal.TestRecordingCommunicationSpi in project ignite by apache.

the class CacheLateAffinityAssignmentTest method delayAssignmentMultipleJoin.

/**
     * @param joinCnt Number of joining nodes.
     * @throws Exception If failed.
     */
private void delayAssignmentMultipleJoin(int joinCnt) throws Exception {
    Ignite ignite0 = startServer(0, 1);
    TestRecordingCommunicationSpi spi = (TestRecordingCommunicationSpi) ignite0.configuration().getCommunicationSpi();
    blockSupplySend(spi, CACHE_NAME1);
    int majorVer = 1;
    for (int i = 0; i < joinCnt; i++) {
        majorVer++;
        startServer(i + 1, majorVer);
        checkAffinity(majorVer, topVer(majorVer, 0), false);
    }
    List<IgniteInternalFuture<?>> futs = affFutures(majorVer, topVer(majorVer, 1));
    U.sleep(1000);
    for (IgniteInternalFuture<?> fut : futs) assertFalse(fut.isDone());
    spi.stopBlock();
    checkAffinity(majorVer, topVer(majorVer, 1), true);
    for (IgniteInternalFuture<?> fut : futs) assertTrue(fut.isDone());
    awaitPartitionMapExchange();
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Ignite(org.apache.ignite.Ignite) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture)

Aggregations

TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)41 Ignite (org.apache.ignite.Ignite)25 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)11 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)10 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)9 ClusterNode (org.apache.ignite.cluster.ClusterNode)8 Message (org.apache.ignite.plugin.extensions.communication.Message)7 GridDhtPartitionsSingleMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage)5 GridDhtPartitionsFullMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage)4 ArrayList (java.util.ArrayList)3 GridIoMessage (org.apache.ignite.internal.managers.communication.GridIoMessage)3 GridDhtPartitionSupplyMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage)3 Transaction (org.apache.ignite.transactions.Transaction)3 List (java.util.List)2 CacheLoaderException (javax.cache.integration.CacheLoaderException)2 CacheWriterException (javax.cache.integration.CacheWriterException)2 IgniteException (org.apache.ignite.IgniteException)2 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)2 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)2 DiscoveryCustomMessage (org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)2