Search in sources :

Example 46 with NearCacheConfiguration

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

the class GridCachePutAllFailoverSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
    cfg.setPeerClassLoadingEnabled(false);
    cfg.setDeploymentMode(DeploymentMode.CONTINUOUS);
    TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
    discoverySpi.setAckTimeout(60000);
    discoverySpi.setIpFinder(ipFinder);
    discoverySpi.setForceServerMode(true);
    cfg.setDiscoverySpi(discoverySpi);
    if (igniteInstanceName.startsWith("master")) {
        cfg.setClientMode(true);
        cfg.setUserAttributes(ImmutableMap.of("segment", "master"));
        // For sure.
        failoverSpi.setMaximumFailoverAttempts(100);
        cfg.setFailoverSpi(failoverSpi);
    } else if (igniteInstanceName.startsWith("worker")) {
        cfg.setUserAttributes(ImmutableMap.of("segment", "worker"));
        CacheConfiguration cacheCfg = defaultCacheConfiguration();
        cacheCfg.setName("partitioned");
        cacheCfg.setAtomicityMode(atomicityMode());
        cacheCfg.setCacheMode(PARTITIONED);
        cacheCfg.setBackups(backups);
        cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);
        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
        cfg.setCacheConfiguration(cacheCfg);
    } else
        throw new IllegalStateException("Unexpected Ignite instance name: " + igniteInstanceName);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi) 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 47 with NearCacheConfiguration

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

the class IgniteStartCacheInTransactionSelfTest method testStartConfigurationCacheWithNear.

/**
 * @throws Exception If failed.
 */
public void testStartConfigurationCacheWithNear() throws Exception {
    final Ignite ignite = grid(0);
    final String key = "key";
    final String val = "val";
    try (Transaction tx = ignite.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
        ignite.cache(DEFAULT_CACHE_NAME).put(key, val);
        GridTestUtils.assertThrows(log, new Callable<Object>() {

            @Override
            public Object call() throws Exception {
                ignite.createCache(cacheConfiguration("NEW_CACHE"), new NearCacheConfiguration());
                return null;
            }
        }, IgniteException.class, EXPECTED_MSG);
        tx.commit();
    }
}
Also used : Transaction(org.apache.ignite.transactions.Transaction) Ignite(org.apache.ignite.Ignite) IgniteException(org.apache.ignite.IgniteException) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 48 with NearCacheConfiguration

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

the class GridCacheReloadSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    cfg.setLocalHost("127.0.0.1");
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder();
    ipFinder.setAddresses(Collections.singleton("127.0.0.1:47500"));
    discoSpi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(discoSpi);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setName(CACHE_NAME);
    cacheCfg.setCacheMode(cacheMode);
    LruEvictionPolicy plc = new LruEvictionPolicy();
    plc.setMaxSize(MAX_CACHE_ENTRIES);
    cacheCfg.setEvictionPolicy(plc);
    cacheCfg.setOnheapCacheEnabled(true);
    cacheCfg.setNearConfiguration(nearEnabled ? new NearCacheConfiguration() : null);
    final CacheStore store = new CacheStoreAdapter<Integer, Integer>() {

        @Override
        public Integer load(Integer key) {
            return key;
        }

        @Override
        public void write(javax.cache.Cache.Entry<? extends Integer, ? extends Integer> e) {
        // No-op.
        }

        @Override
        public void delete(Object key) {
        // No-op.
        }
    };
    cacheCfg.setCacheStoreFactory(singletonFactory(store));
    cacheCfg.setReadThrough(true);
    cacheCfg.setWriteThrough(true);
    cacheCfg.setLoadPreviousValue(true);
    if (cacheMode == PARTITIONED)
        cacheCfg.setBackups(1);
    cfg.setCacheConfiguration(cacheCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) CacheStoreAdapter(org.apache.ignite.cache.store.CacheStoreAdapter) CacheStore(org.apache.ignite.cache.store.CacheStore) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) LruEvictionPolicy(org.apache.ignite.cache.eviction.lru.LruEvictionPolicy) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 49 with NearCacheConfiguration

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

the class GridCacheAtomicNearCacheSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setCacheMode(PARTITIONED);
    ccfg.setAtomicityMode(ATOMIC);
    ccfg.setNearConfiguration(new NearCacheConfiguration());
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setRebalanceMode(SYNC);
    ccfg.setBackups(backups);
    cfg.setCacheConfiguration(ccfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Example 50 with NearCacheConfiguration

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

the class IgfsNearOnlyMultiNodeSelfTest method beforeTestsStarted.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTestsStarted() throws Exception {
    startGrids(nodeCount());
    grid(0).createNearCache("data", new NearCacheConfiguration());
    grid(0).createNearCache("meta", new NearCacheConfiguration());
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration)

Aggregations

NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)158 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)121 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)50 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)41 Ignite (org.apache.ignite.Ignite)37 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 IgniteCache (org.apache.ignite.IgniteCache)12 CacheException (javax.cache.CacheException)11 IgniteEx (org.apache.ignite.internal.IgniteEx)9 Transaction (org.apache.ignite.transactions.Transaction)9 ArrayList (java.util.ArrayList)8 IgniteException (org.apache.ignite.IgniteException)8 HashMap (java.util.HashMap)7 FifoEvictionPolicy (org.apache.ignite.cache.eviction.fifo.FifoEvictionPolicy)7 LinkedHashMap (java.util.LinkedHashMap)6 Callable (java.util.concurrent.Callable)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6 LruEvictionPolicy (org.apache.ignite.cache.eviction.lru.LruEvictionPolicy)6 QuerySchema (org.apache.ignite.internal.processors.query.QuerySchema)6 IgniteSpiException (org.apache.ignite.spi.IgniteSpiException)6