Search in sources :

Example 21 with NearCacheConfiguration

use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.

the class CacheStoreUsageMultinodeDynamicStartAbstractTest method checkStoreWithDynamicStart.

/**
     * @param clientStart {@code True} if start cache from client node.
     * @throws Exception If failed.
     */
private void checkStoreWithDynamicStart(boolean clientStart) throws Exception {
    cacheStore = true;
    CacheConfiguration ccfg = cacheConfiguration();
    assertNotNull(ccfg.getCacheStoreFactory());
    Ignite srv = ignite(0);
    Ignite client = ignite(3);
    Ignite node = clientStart ? client : srv;
    IgniteCache cache = nearCache ? node.createCache(ccfg, new NearCacheConfiguration()) : node.createCache(ccfg);
    assertNotNull(cache);
    try {
        if (nearCache)
            client.createNearCache(DEFAULT_CACHE_NAME, new NearCacheConfiguration<>());
        checkStoreUpdate(true);
    } finally {
        cache = srv.cache(DEFAULT_CACHE_NAME);
        if (cache != null)
            cache.destroy();
    }
}
Also used : IgniteCache(org.apache.ignite.IgniteCache) Ignite(org.apache.ignite.Ignite) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 22 with NearCacheConfiguration

use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.

the class CacheTxFastFinishTest method getConfiguration.

/** {@inheritDoc} */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpDiscoverySpi) cfg.getDiscoverySpi()).setIpFinder(IP_FINDER);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ccfg.setBackups(1);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    if (nearCache)
        ccfg.setNearConfiguration(new NearCacheConfiguration());
    cfg.setCacheConfiguration(ccfg);
    cfg.setClientMode(client);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 23 with NearCacheConfiguration

use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.

the class CacheStopAndDestroySelfTest method testNearClose.

/**
     * Test Near close.
     *
     * @throws Exception If failed.
     */
public void testNearClose() throws Exception {
    fail("https://issues.apache.org/jira/browse/IGNITE-2189");
    startGridsMultiThreaded(gridCount());
    IgniteCache<String, String> cache0 = grid(0).getOrCreateCache(getNearConfig());
    // GridDhtTxPrepareRequest requests to Client node will be counted.
    CountingTxRequestsToClientNodeTcpCommunicationSpi.nodeFilter = grid(2).context().localNodeId();
    // Near Close from client node.
    IgniteCache<String, String> cache1 = grid(1).cache(CACHE_NAME_NEAR);
    IgniteCache<String, String> cache2 = grid(2).createNearCache(CACHE_NAME_NEAR, new NearCacheConfiguration());
    assert cache2.get(KEY_VAL) == null;
    // Subscribing to events.
    cache2.put(KEY_VAL, KEY_VAL);
    CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.set(0);
    cache0.put(KEY_VAL, "near-test");
    U.sleep(1000);
    //Ensure near cache was automatically updated.
    assert CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.get() != 0;
    assert cache2.localPeek(KEY_VAL).equals("near-test");
    cache2.close();
    CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.set(0);
    // Should not produce messages to client node.
    cache0.put(KEY_VAL, KEY_VAL + 0);
    U.sleep(1000);
    // Ensure near cache was NOT automatically updated.
    assert CountingTxRequestsToClientNodeTcpCommunicationSpi.cnt.get() == 0;
    // Not affected.
    assert cache0.get(KEY_VAL).equals(KEY_VAL + 0);
    // Not affected.
    assert cache1.get(KEY_VAL).equals(KEY_VAL + 0);
    try {
        // Affected.
        cache2.get(KEY_VAL);
        assert false;
    } catch (IllegalArgumentException | IllegalStateException ignored) {
    // No-op
    }
    // Near Creation from client node after closed.
    IgniteCache<String, String> cache2New = grid(2).createNearCache(CACHE_NAME_NEAR, new NearCacheConfiguration());
    assertNotSame(cache2, cache2New);
    // Subscribing to events.
    cache2New.put(KEY_VAL, KEY_VAL);
    assert cache2New.localPeek(KEY_VAL).equals(KEY_VAL);
    cache0.put(KEY_VAL, KEY_VAL + "recreated");
    assert cache0.get(KEY_VAL).equals(KEY_VAL + "recreated");
    assert cache1.get(KEY_VAL).equals(KEY_VAL + "recreated");
    assert cache2New.localPeek(KEY_VAL).equals(KEY_VAL + "recreated");
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 24 with NearCacheConfiguration

use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.

the class CacheStopAndDestroySelfTest method nearDestroy.

/**
     * Test Near Destroy.
     *
     * @throws Exception If failed.
     */
private void nearDestroy() throws Exception {
    grid(0).getOrCreateCache(getNearConfig());
    grid(2).getOrCreateNearCache(CACHE_NAME_NEAR, new NearCacheConfiguration());
    assertNull(grid(0).cache(CACHE_NAME_NEAR).get(KEY_VAL));
    assertNull(grid(2).cache(CACHE_NAME_NEAR).get(KEY_VAL));
    grid(2).cache(CACHE_NAME_NEAR).put(KEY_VAL, KEY_VAL);
    grid(0).cache(CACHE_NAME_NEAR).put(KEY_VAL, "near-test");
    assertEquals("near-test", grid(2).cache(CACHE_NAME_NEAR).localPeek(KEY_VAL));
    // Near cache destroy. Cache should be removed from each node.
    IgniteCache<Object, Object> cache = grid(2).cache(CACHE_NAME_NEAR);
    cache.destroy();
    checkDestroyed(cache);
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 25 with NearCacheConfiguration

use of org.apache.ignite.configuration.NearCacheConfiguration in project ignite by apache.

the class GridCacheVersionMultinodeTest method cacheConfiguration.

/** {@inheritDoc} */
@Override
protected CacheConfiguration cacheConfiguration(String igniteInstanceName) throws Exception {
    CacheConfiguration ccfg = super.cacheConfiguration(igniteInstanceName);
    assert atomicityMode != null;
    ccfg.setAtomicityMode(atomicityMode);
    ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
    return ccfg;
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Aggregations

NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)140 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)110 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)45 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)38 Ignite (org.apache.ignite.Ignite)32 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 CacheException (javax.cache.CacheException)11 IgniteCache (org.apache.ignite.IgniteCache)11 IgniteEx (org.apache.ignite.internal.IgniteEx)9 IgniteException (org.apache.ignite.IgniteException)8 Transaction (org.apache.ignite.transactions.Transaction)8 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)7 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)6 HashMap (java.util.HashMap)5 LinkedHashMap (java.util.LinkedHashMap)5 Callable (java.util.concurrent.Callable)5 TimeoutException (java.util.concurrent.TimeoutException)5 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)5 ArrayList (java.util.ArrayList)4 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)4