Search in sources :

Example 31 with CacheConfiguration

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

the class GridAffinityProcessor method affinityInfoFromNode.

/**
 * Requests {@link AffinityFunction} and {@link AffinityKeyMapper} from remote node.
 *
 * @param cacheName Name of cache on which affinity is requested.
 * @param topVer Topology version.
 * @param n Node from which affinity is requested.
 * @return Affinity cached function.
 * @throws IgniteCheckedException If either local or remote node cannot get deployment for affinity objects.
 */
private AffinityInfo affinityInfoFromNode(String cacheName, AffinityTopologyVersion topVer, ClusterNode n) throws IgniteCheckedException {
    GridTuple3<GridAffinityMessage, GridAffinityMessage, GridAffinityAssignment> t = ctx.closure().callAsyncNoFailover(BROADCAST, affinityJob(cacheName, topVer), F.asList(n), true, /*system pool*/
    0, false).get();
    AffinityFunction f = (AffinityFunction) unmarshall(ctx, n.id(), t.get1());
    AffinityKeyMapper m = (AffinityKeyMapper) unmarshall(ctx, n.id(), t.get2());
    assert m != null;
    // Bring to initial state.
    f.reset();
    m.reset();
    CacheConfiguration ccfg = ctx.cache().cacheConfiguration(cacheName);
    return new AffinityInfo(f, m, t.get3(), ctx.cacheObjects().contextForCache(ccfg));
}
Also used : AffinityKeyMapper(org.apache.ignite.cache.affinity.AffinityKeyMapper) AffinityFunction(org.apache.ignite.cache.affinity.AffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 32 with CacheConfiguration

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

the class IgniteDiagnosticMessagesTest method testSeveralLongRunningTxs.

/**
 * @throws Exception If failed.
 */
public void testSeveralLongRunningTxs() throws Exception {
    int timeout = 3500;
    System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout));
    try {
        testSpi = true;
        startGrid(0);
        GridStringLogger strLog = this.strLog = new GridStringLogger();
        strLog.logLength(1024 * 100);
        startGrid(1);
        awaitPartitionMapExchange();
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setAtomicityMode(TRANSACTIONAL);
        final Ignite node0 = ignite(0);
        final Ignite node1 = ignite(1);
        node0.createCache(ccfg);
        UUID id0 = node0.cluster().localNode().id();
        TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearLockResponse.class, node1.name());
        IgniteCache<Object, Object> cache = node0.cache(DEFAULT_CACHE_NAME);
        int txCnt = 4;
        final List<Integer> keys = primaryKeys(cache, txCnt, 0);
        final AtomicInteger idx = new AtomicInteger();
        IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME);
                try (Transaction tx = node1.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
                    Integer key = keys.get(idx.getAndIncrement() % keys.size());
                    cache.putIfAbsent(key, String.valueOf(key));
                    tx.commit();
                }
                return null;
            }
        }, txCnt * 2, "tx");
        U.sleep(timeout * 2);
        assertFalse(fut.isDone());
        TestRecordingCommunicationSpi.spi(node0).stopBlock();
        fut.get();
        String log = strLog.toString();
        assertTrue(log.contains("Cache entries [cacheId=" + CU.cacheId(DEFAULT_CACHE_NAME) + ", cacheName=" + DEFAULT_CACHE_NAME + "]:"));
        assertTrue(countTxKeysInASingleBlock(log) == txCnt);
        assertTrue(log.contains("General node info [id=" + id0));
    } finally {
        System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
    }
}
Also used : GridStringLogger(org.apache.ignite.testframework.GridStringLogger) IgniteCache(org.apache.ignite.IgniteCache) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Transaction(org.apache.ignite.transactions.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 33 with CacheConfiguration

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

the class IgniteDiagnosticMessagesTest method checkBasicDiagnosticInfo.

/**
 * @throws Exception If failed.
 */
private void checkBasicDiagnosticInfo() throws Exception {
    startGrids(3);
    client = true;
    startGrid(3);
    startGrid(4);
    CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
    ccfg.setWriteSynchronizationMode(FULL_SYNC);
    ccfg.setCacheMode(REPLICATED);
    ccfg.setAtomicityMode(TRANSACTIONAL);
    ignite(0).createCache(ccfg);
    awaitPartitionMapExchange();
    sendDiagnostic();
    for (int i = 0; i < 5; i++) {
        final IgniteCache<Object, Object> cache = ignite(i).cache(DEFAULT_CACHE_NAME);
        // Put from multiple threads to create multiple connections.
        GridTestUtils.runMultiThreaded(new Runnable() {

            @Override
            public void run() {
                for (int j = 0; j < 10; j++) cache.put(ThreadLocalRandom.current().nextInt(), j);
            }
        }, 10, "cache-thread");
    }
    sendDiagnostic();
}
Also used : NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 34 with CacheConfiguration

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

the class IgniteDiagnosticMessagesTest method testLongRunning.

/**
 * @throws Exception If failed.
 */
public void testLongRunning() throws Exception {
    System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
    try {
        testSpi = true;
        startGrid(0);
        GridStringLogger strLog = this.strLog = new GridStringLogger();
        startGrid(1);
        awaitPartitionMapExchange();
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setAtomicityMode(TRANSACTIONAL);
        final Ignite node0 = ignite(0);
        node0.createCache(ccfg);
        final Ignite node1 = ignite(1);
        UUID id0 = node0.cluster().localNode().id();
        TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearSingleGetResponse.class, node1.name());
        IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Integer key = primaryKey(node0.cache(DEFAULT_CACHE_NAME));
                node1.cache(DEFAULT_CACHE_NAME).get(key);
                return null;
            }
        }, "get");
        U.sleep(10_000);
        assertFalse(fut.isDone());
        TestRecordingCommunicationSpi.spi(node0).stopBlock();
        fut.get();
        String log = strLog.toString();
        assertTrue(log.contains("GridPartitionedSingleGetFuture waiting for response [node=" + id0));
        assertTrue(log.contains("General node info [id=" + id0));
    } finally {
        System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 35 with CacheConfiguration

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

the class GridCheckpointManagerAbstractSelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    assert igniteInstanceName != null;
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi discoSpi = new TcpDiscoverySpi();
    discoSpi.setIpFinder(IP_FINDER);
    cfg.setDiscoverySpi(discoSpi);
    if (igniteInstanceName.contains("cache")) {
        String cacheName = "test-checkpoints";
        CacheConfiguration cacheCfg = defaultCacheConfiguration();
        cacheCfg.setName(cacheName);
        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
        CacheCheckpointSpi spi = new CacheCheckpointSpi();
        spi.setCacheName(cacheName);
        cfg.setCacheConfiguration(cacheCfg);
        cfg.setCheckpointSpi(spi);
    } else if (igniteInstanceName.contains("jdbc")) {
        JdbcCheckpointSpi spi = new JdbcCheckpointSpi();
        jdbcDataSource ds = new jdbcDataSource();
        ds.setDatabase("jdbc:hsqldb:mem:gg_test_" + getClass().getSimpleName());
        ds.setUser("sa");
        ds.setPassword("");
        spi.setDataSource(ds);
        spi.setCheckpointTableName("test_checkpoints");
        spi.setKeyFieldName("key");
        spi.setValueFieldName("value");
        spi.setValueFieldType("longvarbinary");
        spi.setExpireDateFieldName("expire_date");
        cfg.setCheckpointSpi(spi);
    }
    return cfg;
}
Also used : org.hsqldb.jdbc.jdbcDataSource(org.hsqldb.jdbc.jdbcDataSource) CacheCheckpointSpi(org.apache.ignite.spi.checkpoint.cache.CacheCheckpointSpi) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) JdbcCheckpointSpi(org.apache.ignite.spi.checkpoint.jdbc.JdbcCheckpointSpi) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)

Aggregations

CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)1234 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)474 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)330 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)292 Ignite (org.apache.ignite.Ignite)202 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)127 ArrayList (java.util.ArrayList)95 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)82 IgniteEx (org.apache.ignite.internal.IgniteEx)60 QueryEntity (org.apache.ignite.cache.QueryEntity)59 IgniteCache (org.apache.ignite.IgniteCache)55 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)54 CacheException (javax.cache.CacheException)51 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)51 IgniteException (org.apache.ignite.IgniteException)50 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)45 LinkedHashMap (java.util.LinkedHashMap)41 IgfsGroupDataBlocksKeyMapper (org.apache.ignite.igfs.IgfsGroupDataBlocksKeyMapper)41 TcpDiscoveryVmIpFinder (org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder)38 Transaction (org.apache.ignite.transactions.Transaction)35