Search in sources :

Example 1 with GridCacheTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheTestStore in project ignite by apache.

the class GridCacheColocatedDebugTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi spi = new TcpDiscoverySpi();
    spi.setIpFinder(ipFinder);
    cfg.setDiscoverySpi(spi);
    CacheConfiguration cacheCfg = defaultCacheConfiguration();
    cacheCfg.setCacheMode(PARTITIONED);
    cacheCfg.setNearConfiguration(null);
    cacheCfg.setAffinity(new RendezvousAffinityFunction(false, 30));
    cacheCfg.setBackups(1);
    cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
    if (storeEnabled) {
        cacheCfg.setCacheStoreFactory(singletonFactory(new GridCacheTestStore()));
        cacheCfg.setReadThrough(true);
        cacheCfg.setWriteThrough(true);
        cacheCfg.setLoadPreviousValue(true);
    } else
        cacheCfg.setCacheStoreFactory(null);
    cfg.setCacheConfiguration(cacheCfg);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) TcpDiscoverySpi(org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi) GridCacheTestStore(org.apache.ignite.internal.processors.cache.GridCacheTestStore)

Example 2 with GridCacheTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheTestStore in project ignite by apache.

the class GridCacheWriteBehindStorePartitionedMultiNodeSelfTest method getConfiguration.

/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration c = super.getConfiguration(igniteInstanceName);
    TcpDiscoverySpi disco = new TcpDiscoverySpi();
    disco.setIpFinder(ipFinder);
    c.setDiscoverySpi(disco);
    CacheConfiguration cc = defaultCacheConfiguration();
    cc.setCacheMode(CacheMode.PARTITIONED);
    cc.setWriteBehindEnabled(true);
    cc.setWriteBehindFlushFrequency(WRITE_BEHIND_FLUSH_FREQ);
    cc.setAtomicityMode(TRANSACTIONAL);
    cc.setNearConfiguration(new NearCacheConfiguration());
    CacheStore store = stores[idx.getAndIncrement()] = new GridCacheTestStore();
    cc.setCacheStoreFactory(singletonFactory(store));
    cc.setReadThrough(true);
    cc.setWriteThrough(true);
    cc.setLoadPreviousValue(true);
    c.setCacheConfiguration(cc);
    return c;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) 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) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) GridCacheTestStore(org.apache.ignite.internal.processors.cache.GridCacheTestStore)

Example 3 with GridCacheTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheTestStore in project ignite by apache.

the class GridCacheWriteBehindStoreSelfTest method testBatchApply.

/**
     * Tests that all values will be written to the underlying store
     * right in the same order as they were put into the store.
     *
     * @param writeCoalescing Write coalescing flag.
     * @throws Exception If failed.
     */
private void testBatchApply(boolean writeCoalescing) throws Exception {
    delegate = new GridCacheTestStore(new ConcurrentLinkedHashMap<Integer, String>());
    initStore(1, writeCoalescing);
    List<Integer> intList = new ArrayList<>(CACHE_SIZE);
    try {
        for (int i = 0; i < CACHE_SIZE; i++) {
            store.write(new CacheEntryImpl<>(i, "val" + i));
            intList.add(i);
        }
    } finally {
        shutdownStore();
    }
    Map<Integer, String> underlyingMap = delegate.getMap();
    assertTrue("Store map key set: " + underlyingMap.keySet(), F.eqOrdered(underlyingMap.keySet(), intList));
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConcurrentLinkedHashMap(org.jsr166.ConcurrentLinkedHashMap) ArrayList(java.util.ArrayList) GridCacheTestStore(org.apache.ignite.internal.processors.cache.GridCacheTestStore)

Example 4 with GridCacheTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheTestStore in project ignite by apache.

the class GridCacheColocatedDebugTest method clearStores.

/**
     * Clears all stores.
     *
     * @param cnt Grid count.
     */
private void clearStores(int cnt) {
    for (int i = 0; i < cnt; i++) {
        String cacheName = grid(i).configuration().getCacheConfiguration()[0].getName();
        GridCacheContext ctx = ((IgniteKernal) grid()).context().cache().internalCache(cacheName).context();
        CacheStore store = ctx.store().configuredStore();
        ((GridCacheTestStore) store).reset();
    }
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) CacheStore(org.apache.ignite.cache.store.CacheStore) GridCacheTestStore(org.apache.ignite.internal.processors.cache.GridCacheTestStore)

Example 5 with GridCacheTestStore

use of org.apache.ignite.internal.processors.cache.GridCacheTestStore in project ignite by apache.

the class GridCachePartitionedBasicStoreMultiNodeSelfTest method checkStoreUsage.

/**
     * @param expLoad Expected load calls.
     * @param expPut Expected put calls.
     * @param expPutAll Expected putAll calls.
     * @param expTxs Expected number of transactions.
     */
private void checkStoreUsage(int expLoad, int expPut, int expPutAll, int expTxs) {
    int load = 0;
    int put = 0;
    int putAll = 0;
    int txs = 0;
    for (GridCacheTestStore store : stores) {
        load += store.getLoadCount();
        put += store.getPutCount();
        putAll += store.getPutAllCount();
        txs += store.transactions().size();
    }
    if (expLoad != -1)
        assertEquals(expLoad, load);
    assertEquals(expPut, put);
    assertEquals(expPutAll, putAll);
    assertEquals(expTxs, txs);
}
Also used : GridCacheTestStore(org.apache.ignite.internal.processors.cache.GridCacheTestStore)

Aggregations

GridCacheTestStore (org.apache.ignite.internal.processors.cache.GridCacheTestStore)5 CacheStore (org.apache.ignite.cache.store.CacheStore)2 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)2 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)2 TcpDiscoverySpi (org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi)2 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)1 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)1 GridCacheContext (org.apache.ignite.internal.processors.cache.GridCacheContext)1 ConcurrentLinkedHashMap (org.jsr166.ConcurrentLinkedHashMap)1