Search in sources :

Example 51 with TestRecordingCommunicationSpi

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

the class IgniteCacheClientMultiNodeUpdateTopologyLockTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(gridName);
    cfg.setConsistentId(gridName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    cfg.setCommunicationSpi(commSpi);
    cfg.setClientMode(client);
    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 52 with TestRecordingCommunicationSpi

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

the class IgniteCacheNearLockValueSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setDiscoverySpi(new TcpDiscoverySpi().setForceServerMode(true).setIpFinder(IP_FINDER));
    if (getTestIgniteInstanceName(0).equals(igniteInstanceName))
        cfg.setClientMode(true);
    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    commSpi.record(GridNearLockRequest.class);
    cfg.setCommunicationSpi(commSpi);
    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 53 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 54 with TestRecordingCommunicationSpi

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

the class IgniteTxCachePrimarySyncTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(ipFinder);
    cfg.setClientMode(clientMode);
    TestRecordingCommunicationSpi commSpi = new TestRecordingCommunicationSpi();
    commSpi.setSharedMemoryPort(-1);
    cfg.setCommunicationSpi(commSpi);
    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 55 with TestRecordingCommunicationSpi

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

the class IgniteTxCachePrimarySyncTest method singleKeyPrimaryNodeLeft.

/**
 * @param client Node executing cache operation.
 * @param ccfg Cache configuration.
 * @param c Cache update closure.
 * @throws Exception If failed.
 */
private void singleKeyPrimaryNodeLeft(Ignite client, final CacheConfiguration<Object, Object> ccfg, final IgniteBiInClosure<Integer, IgniteCache<Object, Object>> c) throws Exception {
    Ignite ignite = startGrid(NODES);
    awaitPartitionMapExchange();
    final TestRecordingCommunicationSpi commSpiClient = (TestRecordingCommunicationSpi) client.configuration().getCommunicationSpi();
    IgniteCache<Object, Object> cache = ignite.cache(ccfg.getName());
    final Integer key = primaryKey(cache);
    cache.remove(key);
    waitKeyRemoved(ccfg.getName(), key);
    commSpiClient.blockMessages(GridNearTxFinishRequest.class, ignite.name());
    final IgniteCache<Object, Object> clientCache = client.cache(ccfg.getName());
    IgniteInternalFuture<?> fut = GridTestUtils.runAsync(new Callable<Void>() {

        @Override
        public Void call() throws Exception {
            c.apply(key, clientCache);
            return null;
        }
    });
    boolean waitMsgSnd = GridTestUtils.waitForCondition(new GridAbsPredicate() {

        @Override
        public boolean apply() {
            return commSpiClient.hasBlockedMessages();
        }
    }, 5000);
    assertTrue(waitMsgSnd);
    ignite.close();
    commSpiClient.stopBlock(false);
    fut.get();
    awaitPartitionMapExchange();
    waitKeyUpdated(client, ccfg.getBackups() + 1, ccfg.getName(), key);
    clientCache.remove(key);
    waitKeyRemoved(ccfg.getName(), key);
    c.apply(key, clientCache);
    waitKeyUpdated(client, ccfg.getBackups() + 1, ccfg.getName(), key);
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) GridAbsPredicate(org.apache.ignite.internal.util.lang.GridAbsPredicate) Ignite(org.apache.ignite.Ignite) CacheWriterException(javax.cache.integration.CacheWriterException) CacheLoaderException(javax.cache.integration.CacheLoaderException)

Aggregations

TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)61 Ignite (org.apache.ignite.Ignite)33 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)20 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)18 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)11 ClusterNode (org.apache.ignite.cluster.ClusterNode)10 Message (org.apache.ignite.plugin.extensions.communication.Message)9 ArrayList (java.util.ArrayList)6 GridDhtPartitionsFullMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsFullMessage)6 GridDhtPartitionsSingleMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsSingleMessage)6 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)5 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)5 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4 GridDhtPartitionSupplyMessage (org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionSupplyMessage)4 IgniteException (org.apache.ignite.IgniteException)3 ClusterTopologyServerNotFoundException (org.apache.ignite.internal.cluster.ClusterTopologyServerNotFoundException)3 DiscoveryCustomMessage (org.apache.ignite.internal.managers.discovery.DiscoveryCustomMessage)3 CacheAffinityChangeMessage (org.apache.ignite.internal.processors.cache.CacheAffinityChangeMessage)3 Transaction (org.apache.ignite.transactions.Transaction)3 IOException (java.io.IOException)2