Repository: ignite Updated Branches: refs/heads/ignite-1.5 6e0ef3480 -> 91760b9eb
ignite-2136 Added test reproducing issue, modified GridCacheJdbcBlobStoreMultithreadedSelfTest to do not fail because of this bug. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/91760b9e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/91760b9e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/91760b9e Branch: refs/heads/ignite-1.5 Commit: 91760b9ebc83b994531fc4635a7d821bfc71d77c Parents: 6e0ef34 Author: sboikov <[email protected]> Authored: Fri Dec 11 15:31:56 2015 +0300 Committer: sboikov <[email protected]> Committed: Fri Dec 11 15:31:56 2015 +0300 ---------------------------------------------------------------------- ...eJdbcStoreAbstractMultithreadedSelfTest.java | 5 +- ...CacheJdbcBlobStoreMultithreadedSelfTest.java | 2 +- .../near/NearCachePutAllMultinodeTest.java | 167 +++++++++++++++++++ 3 files changed, 172 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/91760b9e/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java index 4c4bd58..592d1cb 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/CacheJdbcStoreAbstractMultithreadedSelfTest.java @@ -137,7 +137,10 @@ public abstract class CacheJdbcStoreAbstractMultithreadedSelfTest<T extends Cach return c; } - /** */ + /** + * @return Cache configuration. + * @throws Exception If failed. + */ protected CacheConfiguration cacheConfiguration() throws Exception { CacheConfiguration cc = defaultCacheConfiguration(); http://git-wip-us.apache.org/repos/asf/ignite/blob/91760b9e/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java index 4396549..cceb55f 100644 --- a/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/cache/store/jdbc/GridCacheJdbcBlobStoreMultithreadedSelfTest.java @@ -168,7 +168,7 @@ public class GridCacheJdbcBlobStoreMultithreadedSelfTest extends GridCommonAbstr Map<Integer, String> map = new TreeMap<>(); for (int j = 0; j < 10; j++) - map.put(rnd.nextInt(1000), "value"); + map.put(j, "value"); IgniteCache<Object, Object> cache = jcache(rnd.nextInt(GRID_CNT)); http://git-wip-us.apache.org/repos/asf/ignite/blob/91760b9e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java new file mode 100644 index 0000000..bd6355a --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/near/NearCachePutAllMultinodeTest.java @@ -0,0 +1,167 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.processors.cache.distributed.near; + +import java.util.Map; +import java.util.Random; +import java.util.TreeMap; +import java.util.concurrent.Callable; +import java.util.concurrent.atomic.AtomicInteger; +import javax.cache.Cache; +import javax.cache.configuration.Factory; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.cache.store.CacheStoreAdapter; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.configuration.NearCacheConfiguration; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; + +import static org.apache.ignite.cache.CacheAtomicityMode.TRANSACTIONAL; +import static org.apache.ignite.cache.CacheMode.PARTITIONED; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC; +import static org.apache.ignite.testframework.GridTestUtils.runMultiThreaded; + +/** + * + */ +public class NearCachePutAllMultinodeTest extends GridCommonAbstractTest { + /** IP finder. */ + private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** Number of grids to start. */ + private static final int GRID_CNT = 3; + + /** Number of transactions. */ + private static final int TX_CNT = 10_000; + + /** Client flag. */ + private boolean client; + + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration c = super.getConfiguration(gridName); + + TcpDiscoverySpi disco = new TcpDiscoverySpi(); + + disco.setIpFinder(IP_FINDER); + + c.setDiscoverySpi(disco); + + if (!client) { + CacheConfiguration cc = defaultCacheConfiguration(); + + cc.setCacheMode(PARTITIONED); + cc.setWriteSynchronizationMode(FULL_SYNC); + cc.setSwapEnabled(false); + cc.setAtomicityMode(TRANSACTIONAL); + cc.setBackups(1); + + // Set store to disable one-phase commit. + cc.setCacheStoreFactory(new TestFactory()); + + c.setCacheConfiguration(cc); + } + else + c.setClientMode(true); + + return c; + } + + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + startGridsMultiThreaded(GRID_CNT - 2); + + client = true; + + Ignite grid = startGrid(GRID_CNT - 2); + + grid.createNearCache(null, new NearCacheConfiguration()); + + grid = startGrid(GRID_CNT - 1); + + grid.cache(null); + } + + /** {@inheritDoc} */ + @Override protected void afterTest() throws Exception { + stopAllGrids(); + + super.afterTest(); + } + + /** + * @throws Exception If failed. + */ + public void testMultithreadedPutAll() throws Exception { + final AtomicInteger idx = new AtomicInteger(); + + runMultiThreaded(new Callable<Object>() { + private final Random rnd = new Random(); + + @Override public Object call() throws Exception { + int threadIdx = idx.getAndIncrement(); + + int node = threadIdx % 2 + (GRID_CNT - 2); + + IgniteCache<Object, Object> cache = jcache(node); + + for (int i = 0; i < TX_CNT; i++) { + Map<Integer, String> map = new TreeMap<>(); + + for (int j = 0; j < 3; j++) + map.put(rnd.nextInt(10), "value"); + + cache.putAll(map); + + if (i % 100 == 0) + log.info("Iteration: " + i + " " + node); + } + + return null; + } + }, 8, "putAll"); + } + + /** + * + */ + static class TestFactory implements Factory<CacheStore> { + /** {@inheritDoc} */ + @Override public CacheStore create() { + return new CacheStoreAdapter() { + @Override public Object load(Object key) { + return null; + } + + @Override public void write(Cache.Entry entry) { + // No-op. + } + + @Override public void delete(Object key) { + // No-op. + } + }; + } + } +} \ No newline at end of file
