http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheCountDownLatchSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheCountDownLatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheCountDownLatchSelfTest.java deleted file mode 100644 index 498581b..0000000 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheCountDownLatchSelfTest.java +++ /dev/null @@ -1,408 +0,0 @@ -/* - * 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.datastructures; - -import org.apache.ignite.*; -import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; -import org.apache.ignite.internal.*; -import org.apache.ignite.lang.*; -import org.apache.ignite.resources.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.testframework.*; -import org.apache.ignite.testframework.junits.common.*; -import org.jetbrains.annotations.*; - -import java.io.*; -import java.util.*; -import java.util.concurrent.*; - -import static java.util.concurrent.TimeUnit.*; -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CacheDistributionMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; - -/** - * Cache count down latch self test. - */ -public class GridCacheCountDownLatchSelfTest extends GridCommonAbstractTest implements Externalizable { - /** */ - private static final int NODES_CNT = 4; - - /** */ - private static final int THREADS_CNT = 5; - - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - - /** */ - private static final Random RND = new Random(); - - /** - * - */ - public GridCacheCountDownLatchSelfTest() { - super(false /* start grid. */); - } - - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - cfg.setLocalHost("127.0.0.1"); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - - CacheConfiguration repCacheCfg = defaultCacheConfiguration(); - - repCacheCfg.setName("replicated"); - repCacheCfg.setCacheMode(REPLICATED); - repCacheCfg.setPreloadMode(SYNC); - repCacheCfg.setWriteSynchronizationMode(FULL_SYNC); - repCacheCfg.setEvictionPolicy(null); - repCacheCfg.setAtomicityMode(TRANSACTIONAL); - repCacheCfg.setDistributionMode(NEAR_PARTITIONED); - - CacheConfiguration partCacheCfg = defaultCacheConfiguration(); - - partCacheCfg.setName("partitioned"); - partCacheCfg.setCacheMode(PARTITIONED); - partCacheCfg.setBackups(1); - partCacheCfg.setPreloadMode(SYNC); - partCacheCfg.setWriteSynchronizationMode(FULL_SYNC); - partCacheCfg.setEvictionPolicy(null); - partCacheCfg.setNearEvictionPolicy(null); - partCacheCfg.setAtomicityMode(TRANSACTIONAL); - partCacheCfg.setDistributionMode(NEAR_PARTITIONED); - - CacheConfiguration locCacheCfg = defaultCacheConfiguration(); - - locCacheCfg.setName("local"); - locCacheCfg.setCacheMode(LOCAL); - locCacheCfg.setWriteSynchronizationMode(FULL_SYNC); - locCacheCfg.setEvictionPolicy(null); - locCacheCfg.setAtomicityMode(TRANSACTIONAL); - locCacheCfg.setDistributionMode(NEAR_PARTITIONED); - - cfg.setCacheConfiguration(repCacheCfg, partCacheCfg, locCacheCfg); - - return cfg; - } - - /** {@inheritDoc} */ - @Override protected void beforeTestsStarted() throws Exception { - super.beforeTestsStarted(); - - startGrids(NODES_CNT); - } - - /** {@inheritDoc} */ - @Override protected void afterTestsStopped() throws Exception { - super.afterTestsStopped(); - - stopAllGrids(); - } - - /** - * @throws Exception If failed. - */ - public void testLatchReplicated() throws Exception { - checkLatch("replicated"); - } - - /** - * @throws Exception If failed. - */ - public void testLatchPartitioned() throws Exception { - checkLatch("partitioned"); - } - - /** - * @throws Exception If failed. - */ - public void testLatchLocal() throws Exception { - // Test main functionality. - IgniteCountDownLatch latch = grid(0).cache("local").dataStructures().countDownLatch("latch", 2, false, - true); - - assert latch.count() == 2; - - IgniteFuture<?> fut = GridTestUtils.runMultiThreadedAsync( - new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - IgniteCountDownLatch latch = grid(0).cache("local").dataStructures() - .countDownLatch("latch", 2, false, true); - - assert latch != null && latch.count() == 2; - - info("Thread is going to wait on latch: " + Thread.currentThread().getName()); - - assert latch.await(1, MINUTES); - - info("Thread is again runnable: " + Thread.currentThread().getName()); - - return null; - } - }, - THREADS_CNT, - "test-thread" - ); - - Thread.sleep(3000); - - assert latch.countDown() == 1; - - assert latch.countDown() == 0; - - assert latch.await(1, SECONDS); - - // Ensure there are no hangs. - fut.get(); - - // Test operations on removed latch. - grid(0).cache("local").dataStructures().removeCountDownLatch("latch"); - - checkRemovedLatch(latch); - } - - /** - * @param cacheName Cache name. - * @throws Exception If failed. - */ - private void checkLatch(final String cacheName) throws Exception { - // Test API. - checkAutoDelete(cacheName); - - checkAwait(cacheName); - - checkCountDown(cacheName); - - // Test main functionality. - IgniteCountDownLatch latch1 = grid(0).cache(cacheName).dataStructures().countDownLatch("latch", 2, false, - true); - - assert latch1.count() == 2; - - IgniteCompute comp = grid(0).compute().enableAsync(); - - comp.call(new IgniteCallable<Object>() { - @IgniteInstanceResource - private Ignite ignite; - - @IgniteLoggerResource - private IgniteLogger log; - - @Nullable @Override public Object call() throws Exception { - // Test latch in multiple threads on each node. - IgniteFuture<?> fut = GridTestUtils.runMultiThreadedAsync( - new Callable<Object>() { - @Nullable @Override public Object call() throws Exception { - IgniteCountDownLatch latch = ignite.cache(cacheName).dataStructures() - .countDownLatch("latch", 2, false, true); - - assert latch != null && latch.count() == 2; - - log.info("Thread is going to wait on latch: " + Thread.currentThread().getName()); - - assert latch.await(1, MINUTES); - - log.info("Thread is again runnable: " + Thread.currentThread().getName()); - - return null; - } - }, - 5, - "test-thread" - ); - - fut.get(); - - return null; - } - }); - - IgniteFuture<Object> fut = comp.future(); - - Thread.sleep(3000); - - assert latch1.countDown() == 1; - - assert latch1.countDown() == 0; - - // Ensure there are no hangs. - fut.get(); - - // Test operations on removed latch. - grid(0).cache(cacheName).dataStructures().removeCountDownLatch("latch"); - - checkRemovedLatch(latch1); - } - - /** - * @param latch Latch. - * - * @throws Exception If failed. - */ - private void checkRemovedLatch(IgniteCountDownLatch latch) throws Exception { - assert latch.removed(); - - assert latch.count() == 0; - - // Test await on removed future. - latch.await(); - assert latch.await(10); - assert latch.await(10, SECONDS); - - latch.await(); - - // Test countdown. - assert latch.countDown() == 0; - assert latch.countDown(5) == 0; - latch.countDownAll(); - } - - /** - * @param cacheName Cache name. - * @throws Exception Exception. - */ - private void checkAutoDelete(String cacheName) throws Exception { - IgniteCountDownLatch latch = createLatch(cacheName, "rmv", 5, true); - - latch.countDownAll(); - - // Latch should be removed since autoDelete = true - checkRemovedLatch(latch); - - IgniteCountDownLatch latch1 = createLatch(cacheName, "rmv1", 5, false); - - latch1.countDownAll(); - - // Latch should NOT be removed since autoDelete = false - assert !latch1.removed(); - - removeLatch(cacheName, "rmv1"); - } - - /** - * @param cacheName Cache name. - * @throws Exception Exception. - */ - private void checkAwait(String cacheName) throws Exception { - // Check only 'false' cases here. Successful await is tested over the grid. - IgniteCountDownLatch latch = createLatch(cacheName, "await", 5, true); - - assert !latch.await(10); - assert !latch.await(10, MILLISECONDS); - - removeLatch(cacheName, "await"); - } - - /** - * @param cacheName Cache name. - * @throws Exception Exception. - */ - private void checkCountDown(String cacheName) throws Exception { - IgniteCountDownLatch latch = createLatch(cacheName, "cnt", 10, true); - - assert latch.countDown() == 9; - assert latch.countDown(2) == 7; - - latch.countDownAll(); - - assert latch.count() == 0; - - checkRemovedLatch(latch); - - IgniteCountDownLatch latch1 = createLatch(cacheName, "cnt1", 10, true); - - assert latch1.countDown() == 9; - assert latch1.countDown(2) == 7; - - latch1.countDownAll(); - - assert latch1.count() == 0; - - checkRemovedLatch(latch1); - } - - /** - * @param cacheName Cache name. - * @param latchName Latch name. - * @param cnt Count. - * @param autoDel Auto delete flag. - * @throws Exception If failed. - * @return New latch. - */ - private IgniteCountDownLatch createLatch(String cacheName, String latchName, int cnt, boolean autoDel) - throws Exception { - IgniteCountDownLatch latch = grid(RND.nextInt(NODES_CNT)).cache(cacheName).dataStructures() - .countDownLatch(latchName, cnt, autoDel, true); - - // Test initialization. - assert latchName.equals(latch.name()); - assert latch.count() == cnt; - assert latch.initialCount() == cnt; - assert latch.autoDelete() == autoDel; - - return latch; - } - - /** - * @param cacheName Cache name. - * @param latchName Latch name. - * @throws Exception If failed. - */ - private void removeLatch(String cacheName, String latchName) - throws Exception { - IgniteCountDownLatch latch = grid(RND.nextInt(NODES_CNT)).cache(cacheName).dataStructures() - .countDownLatch(latchName, 10, false, true); - - assert latch != null; - - if (latch.count() > 0) - latch.countDownAll(); - - // Remove latch on random node. - grid(RND.nextInt(NODES_CNT)).cache(cacheName).dataStructures().removeCountDownLatch(latchName); - - // Ensure latch is removed on all nodes. - for (Ignite g : G.allGrids()) - assertNull(((GridKernal)g).context().dataStructures().countDownLatch(latchName, 10, true, false)); - - checkRemovedLatch(latch); - } - - /** {@inheritDoc} */ - @Override public void writeExternal(ObjectOutput out) throws IOException { - // No-op. - } - - /** {@inheritDoc} */ - @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { - // No-op. - } -}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java index 8b16936..5e16dd5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/GridCacheQueueApiSelfAbstractTest.java @@ -19,54 +19,25 @@ package org.apache.ignite.internal.processors.cache.datastructures; import org.apache.ignite.*; import org.apache.ignite.configuration.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.testframework.junits.common.*; import java.io.*; import java.util.*; import java.util.concurrent.*; -import java.util.concurrent.atomic.*; /** * Queue basic tests. */ -public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstractTest { - /** */ - private static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - +public abstract class GridCacheQueueApiSelfAbstractTest extends IgniteCollectionAbstractTest { /** */ private static final int QUEUE_CAPACITY = 3; /** */ private static final int THREAD_NUM = 2; - /** */ - private static AtomicInteger cntr = new AtomicInteger(); - - /** - * Default constructor. - * - */ - protected GridCacheQueueApiSelfAbstractTest() { - super(true /** Start grid. */); - } - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - TcpDiscoverySpi spi = new TcpDiscoverySpi(); - - spi.setIpFinder(ipFinder); - - cfg.setDiscoverySpi(spi); - - cfg.setLocalHost("127.0.0.1"); - - return cfg; + @Override protected int gridCount() { + return 1; } /** @@ -79,9 +50,11 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra String queueName1 = UUID.randomUUID().toString(); String queueName2 = UUID.randomUUID().toString(); - IgniteQueue queue1 = grid().cache(null).dataStructures().queue(queueName1, 0, false, true); - IgniteQueue queue2 = grid().cache(null).dataStructures().queue(queueName2, 0, false, true); - IgniteQueue queue3 = grid().cache(null).dataStructures().queue(queueName1, 0, false, true); + IgniteCollectionConfiguration colCfg = collectionConfiguration(); + + IgniteQueue queue1 = grid(0).queue(queueName1, colCfg, 0, true); + IgniteQueue queue2 = grid(0).queue(queueName2, colCfg, 0, true); + IgniteQueue queue3 = grid(0).queue(queueName1, colCfg, 0, true); assertNotNull(queue1); assertNotNull(queue2); @@ -90,10 +63,12 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra assert queue3.equals(queue1); assert !queue3.equals(queue2); - assert grid().cache(null).dataStructures().removeQueue(queueName1); - assert grid().cache(null).dataStructures().removeQueue(queueName2); - assert !grid().cache(null).dataStructures().removeQueue(queueName1); - assert !grid().cache(null).dataStructures().removeQueue(queueName2); + queue1.close(); + queue2.close(); + queue3.close(); + + assertNull(grid(0).queue(queueName1, null, 0, false)); + assertNull(grid(0).queue(queueName2, null, 0, false)); } /** @@ -107,7 +82,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra String val = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures().queue(queueName, 0, false, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); assert queue.add(val); @@ -125,7 +100,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra String val = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures().queue(queueName, 0, false, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); assert queue.add(val); @@ -143,8 +118,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - // TODO was LIFO - IgniteQueue<SameHashItem> queue = grid().cache(null).dataStructures().queue(queueName, 0, false, true); + IgniteQueue<SameHashItem> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); int retries = 100; @@ -220,7 +194,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures().queue(queueName, 0, false, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); assert queue.add("1"); @@ -242,7 +216,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures().queue(queueName, 0, true, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collocatedCollectionConfiguration(), 0, true); String item1 = "1"; assert queue.add(item1); @@ -267,7 +241,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures().queue(queueName, 0, false, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); for (int i = 0; i < 100; i++) assert queue.add(Integer.toString(i)); @@ -323,8 +297,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, QUEUE_CAPACITY, false, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), QUEUE_CAPACITY, true); String thName = Thread.currentThread().getName(); @@ -346,11 +319,10 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - final IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, QUEUE_CAPACITY, false, true); + final IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), QUEUE_CAPACITY, true); - multithreaded(new Callable<String>() { - @Override public String call() throws Exception { + multithreaded(new Callable<Void>() { + @Override public Void call() throws Exception { String thName = Thread.currentThread().getName(); for (int i = 0; i < 5; i++) { @@ -359,7 +331,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra queue.take(); } - return ""; + return null; } }, THREAD_NUM); @@ -375,8 +347,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - final IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, QUEUE_CAPACITY, false, true); + final IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), QUEUE_CAPACITY, true); multithreaded(new Callable<String>() { @Override public String call() throws Exception { @@ -403,10 +374,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. final String queueName = UUID.randomUUID().toString(); - final AtomicInteger rmvNum = new AtomicInteger(0); - - final IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, QUEUE_CAPACITY, false, true); + final IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), QUEUE_CAPACITY, true); final CountDownLatch putLatch = new CountDownLatch(THREAD_NUM); @@ -445,17 +413,13 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra Thread th = new Thread(new Runnable() { @Override public void run() { try { - if (grid().cache(null).dataStructures().removeQueue(queueName, 0)) { - rmvNum.incrementAndGet(); + IgniteQueue<String> queue = grid(0).queue(queueName, null, 0, false); - if (log.isDebugEnabled()) - log.debug("Queue removed [queue " + queue + ']'); - } + if (queue != null) + queue.close(); } - catch (IgniteCheckedException e) { - info("Caught expected exception: " + e.getMessage()); - - assert queue.removed(); + catch (Exception e) { + fail("Unexpected exception: " + e); } finally { clearLatch.countDown(); @@ -469,96 +433,6 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra assert clearLatch.await(3, TimeUnit.MINUTES); - assert rmvNum.get() == 1 : "Expected 1 but was " + rmvNum.get(); - - try { - assert queue.isEmpty() : queue.size(); - fail("Queue must be removed."); - } - catch (IgniteException e) { - assert e.getMessage().contains("removed"); - - assert queue.removed(); - } - } - - /** - * JUnit. - * - * @throws Exception If failed. - */ - public void testQueueRemoveMultithreadUnbounded() throws Exception { - // Random queue name. - final String queueName = UUID.randomUUID().toString(); - - final AtomicInteger rmvNum = new AtomicInteger(0); - - final IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, QUEUE_CAPACITY, false, true); - - final CountDownLatch takeLatch = new CountDownLatch(THREAD_NUM); - - final CountDownLatch clearLatch = new CountDownLatch(THREAD_NUM); - - for (int t = 0; t < THREAD_NUM; t++) { - Thread th = new Thread(new Runnable() { - @Override public void run() { - if (log.isDebugEnabled()) - log.debug("Thread has been started." + Thread.currentThread().getName()); - - try { - // Thread must be blocked on take operation. - for (int i = 0; i < (QUEUE_CAPACITY * THREAD_NUM); i++) { - queue.poll(3, TimeUnit.MINUTES); - - fail("Queue failed"); - } - } - catch (IgniteException e) { - takeLatch.countDown(); - - assert e.getMessage().contains("removed"); - - assert queue.removed(); - - if (log.isDebugEnabled()) - log.debug("Thread has been stopped." + Thread.currentThread().getName()); - } - } - }); - th.start(); - } - - for (int t = 0; t < THREAD_NUM; t++) { - Thread th = new Thread(new Runnable() { - @Override public void run() { - try { - if (grid().cache(null).dataStructures().removeQueue(queueName, 0)) { - rmvNum.incrementAndGet(); - - if (log.isDebugEnabled()) - log.debug("Queue has been removed." + queue); - } - } - catch (IgniteCheckedException e) { - info("Caught expected exception: " + e.getMessage()); - - assert queue.removed(); - } - finally { - clearLatch.countDown(); - } - } - }); - th.start(); - } - - assert takeLatch.await(3, TimeUnit.MINUTES); - - assert clearLatch.await(3, TimeUnit.MINUTES); - - assert rmvNum.get() == 1 : "Expected 1 but was " + rmvNum.get(); - try { assert queue.isEmpty() : queue.size(); @@ -576,46 +450,11 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra * * @throws Exception If failed. */ - public void testPutRemoveAll() throws Exception { - final Collection<Integer> keys = new LinkedList<>(); - - for (int j = 0; j < QUEUE_CAPACITY; j++) { - for (int i = 0; i < QUEUE_CAPACITY; i++) { - int key = cntr.getAndIncrement(); - - keys.add(key); - - grid().cache(null).put(key, "123"); - } - - multithreaded( - new Callable<String>() { - @Override public String call() throws Exception { - info("Removing all keys: " + keys); - - grid().cache(null).removeAll(keys); - - info("Thread finished for keys: " + keys); - - return ""; - } - }, - THREAD_NUM - ); - } - } - - /** - * JUnit. - * - * @throws Exception If failed. - */ public void testPutRemoveUnbounded() throws Exception { // Random queue name. String queueName = UUID.randomUUID().toString(); - IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, 0, false, true); + IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); String thread = Thread.currentThread().getName(); @@ -640,8 +479,7 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra // Random queue name. String queueName = UUID.randomUUID().toString(); - final IgniteQueue<String> queue = grid().cache(null).dataStructures() - .queue(queueName, 0, false, true); + final IgniteQueue<String> queue = grid(0).queue(queueName, collectionConfiguration(), 0, true); multithreaded( new Callable<String>() { @@ -687,23 +525,26 @@ public abstract class GridCacheQueueApiSelfAbstractTest extends GridCommonAbstra return s; } + /** {@inheritDoc} */ @Override public int hashCode() { return 0; } + /** {@inheritDoc} */ @Override public boolean equals(Object o) { - { - if (this == o) - return true; - if (o instanceof SameHashItem) { - SameHashItem i = (SameHashItem)o; - return s.equals(i.s); - } + if (this == o) + return true; + + if (o instanceof SameHashItem) { + SameHashItem i = (SameHashItem)o; - return false; + return s.equals(i.s); } + + return false; } + /** {@inheritDoc} */ @Override public String toString() { return S.toString(SameHashItem.class, this); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java index 609df62..ea90578 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteAtomicsAbstractTest.java @@ -31,7 +31,7 @@ public abstract class IgniteAtomicsAbstractTest extends GridCommonAbstractTest { /** */ protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); - /** {@inheritDoc} */ + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java new file mode 100644 index 0000000..f4e72fe --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/IgniteCollectionAbstractTest.java @@ -0,0 +1,119 @@ +/* + * 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.datastructures; + +import org.apache.ignite.cache.*; +import org.apache.ignite.configuration.*; +import org.apache.ignite.spi.discovery.tcp.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.*; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; +import org.apache.ignite.testframework.junits.common.*; + +import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; +import static org.apache.ignite.cache.CacheDistributionMode.*; +import static org.apache.ignite.cache.CachePreloadMode.*; +import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; + +/** + * + */ +public abstract class IgniteCollectionAbstractTest extends GridCommonAbstractTest { + /** */ + protected static TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true); + + /** {@inheritDoc} */ + @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { + IgniteConfiguration cfg = super.getConfiguration(gridName); + + TcpDiscoverySpi spi = new TcpDiscoverySpi(); + + spi.setIpFinder(ipFinder); + + cfg.setDiscoverySpi(spi); + + // TODO IGNITE-29: remove cache configuration when dynamic cache start is implemented. + IgniteCollectionConfiguration colCfg = collectionConfiguration(); + + assertNotNull(colCfg); + + CacheConfiguration ccfg = new CacheConfiguration(); + + ccfg.setName("TEST_COLLECTION_CACHE"); + ccfg.setCacheMode(colCfg.getCacheMode()); + ccfg.setAtomicityMode(colCfg.getAtomicityMode()); + ccfg.setAtomicWriteOrderMode(PRIMARY); + ccfg.setBackups(colCfg.getBackups()); + ccfg.setMemoryMode(colCfg.getMemoryMode()); + ccfg.setDistributionMode(colCfg.getDistributionMode()); + ccfg.setWriteSynchronizationMode(FULL_SYNC); + ccfg.setPreloadMode(SYNC); + + cfg.setCacheConfiguration(ccfg); + + return cfg; + } + + /** + * @return Collection configuration. + */ + IgniteCollectionConfiguration collectionConfiguration() { + IgniteCollectionConfiguration colCfg = new IgniteCollectionConfiguration(); + + colCfg.setCacheMode(collectionCacheMode()); + colCfg.setAtomicityMode(collectionCacheAtomicityMode()); + colCfg.setDistributionMode(PARTITIONED_ONLY); + + return colCfg; + } + + /** + * @return Collection configuration with {@link IgniteCollectionConfiguration#isCollocated()} flag set. + */ + protected IgniteCollectionConfiguration collocatedCollectionConfiguration() { + IgniteCollectionConfiguration colCfg = collectionConfiguration(); + + colCfg.setCollocated(true); + + return colCfg; + } + + /** + * @return Number of nodes to start. + */ + protected abstract int gridCount(); + + /** + * @return Collection cache mode. + */ + protected abstract CacheMode collectionCacheMode(); + + /** + * @return Collection cache atomicity mode. + */ + protected abstract CacheAtomicityMode collectionCacheAtomicityMode(); + + /** {@inheritDoc} */ + @Override protected void beforeTestsStarted() throws Exception { + startGridsMultiThreaded(gridCount()); + } + + /** {@inheritDoc} */ + @Override protected void afterTestsStopped() throws Exception { + stopAllGrids(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicLongApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicLongApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicLongApiSelfTest.java new file mode 100644 index 0000000..c250fe0 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicLongApiSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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.datastructures.local; + +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class GridCacheLocalAtomicLongApiSelfTest extends GridCacheAtomicLongApiAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return LOCAL; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicQueueApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicQueueApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicQueueApiSelfTest.java index de91846..7c818cf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicQueueApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalAtomicQueueApiSelfTest.java @@ -18,7 +18,6 @@ package org.apache.ignite.internal.processors.cache.datastructures.local; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -27,13 +26,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*; */ public class GridCacheLocalAtomicQueueApiSelfTest extends GridCacheLocalQueueApiSelfTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - CacheConfiguration ccfg = cfg.getCacheConfiguration()[0]; - - ccfg.setAtomicityMode(ATOMIC); - - return cfg; + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { + return ATOMIC; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalCountDownLatchSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalCountDownLatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalCountDownLatchSelfTest.java new file mode 100644 index 0000000..b927253 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalCountDownLatchSelfTest.java @@ -0,0 +1,95 @@ +/* + * 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.datastructures.local; + +import org.apache.ignite.*; +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; +import org.apache.ignite.lang.*; +import org.apache.ignite.testframework.*; +import org.jetbrains.annotations.*; + +import java.util.concurrent.*; + +import static java.util.concurrent.TimeUnit.*; +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class GridCacheLocalCountDownLatchSelfTest extends GridCacheCountDownLatchAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return LOCAL; + } + + /** {@inheritDoc} */ + @Override protected int gridCount() { + return 1; + } + + /** {@inheritDoc} */ + @Override public void testLatch() throws Exception { + // Test main functionality. + IgniteCountDownLatch latch = grid(0).countDownLatch("latch", 2, false, true); + + assertNotNull(latch); + + assertEquals(2, latch.count()); + + IgniteFuture<?> fut = GridTestUtils.runMultiThreadedAsync( + new Callable<Object>() { + @Nullable @Override public Object call() throws Exception { + IgniteCountDownLatch latch = grid(0).countDownLatch("latch", 2, false, true); + + assert latch != null && latch.count() == 2; + + info("Thread is going to wait on latch: " + Thread.currentThread().getName()); + + assert latch.await(1, MINUTES); + + info("Thread is again runnable: " + Thread.currentThread().getName()); + + return null; + } + }, + THREADS_CNT, + "test-thread" + ); + + Thread.sleep(3000); + + assert latch.countDown() == 1; + + assert latch.countDown() == 0; + + assert latch.await(1, SECONDS); + + // Ensure there are no hangs. + fut.get(); + + // Test operations on removed latch. + IgniteCountDownLatch latch0 = grid(0).countDownLatch("latch", 0, false, false); + + assertNotNull(latch0); + + latch0.close(); + + checkRemovedLatch(latch); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalQueueApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalQueueApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalQueueApiSelfTest.java index 4e563d5..3c90d0e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalQueueApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/local/GridCacheLocalQueueApiSelfTest.java @@ -18,27 +18,22 @@ package org.apache.ignite.internal.processors.cache.datastructures.local; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * Queue tests with local cache. */ public class GridCacheLocalQueueApiSelfTest extends GridCacheQueueApiSelfAbstractTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - // Default cache configuration. - CacheConfiguration dfltCacheCfg = defaultCacheConfiguration(); - - dfltCacheCfg.setCacheMode(LOCAL); - dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cfg.setCacheConfiguration(dfltCacheCfg); + @Override protected CacheMode collectionCacheMode() { + return LOCAL; + } - return cfg; + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { + return TRANSACTIONAL; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicLongApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicLongApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicLongApiSelfTest.java new file mode 100644 index 0000000..7d52858 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicLongApiSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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.datastructures.partitioned; + +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class GridCachePartitionedAtomicLongApiSelfTest extends GridCacheAtomicLongApiAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return PARTITIONED; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueApiSelfTest.java index 8c38d1d..94c04a0 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueApiSelfTest.java @@ -18,9 +18,7 @@ package org.apache.ignite.internal.processors.cache.datastructures.partitioned; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; -import static org.apache.ignite.cache.CacheAtomicWriteOrderMode.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; /** @@ -28,14 +26,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*; */ public class GridCachePartitionedAtomicQueueApiSelfTest extends GridCachePartitionedQueueApiSelfTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - CacheConfiguration ccfg = cfg.getCacheConfiguration()[0]; - - ccfg.setAtomicityMode(ATOMIC); - ccfg.setAtomicWriteOrderMode(PRIMARY); - - return cfg; + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { + return ATOMIC; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.java index 4d84c7b..19854be 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest.java @@ -28,7 +28,7 @@ import static org.apache.ignite.cache.CacheAtomicityMode.*; public class GridCachePartitionedAtomicQueueFailoverDataConsistencySelfTest extends GridCacheAbstractQueueFailoverDataConsistencySelfTest { /** {@inheritDoc} */ - @Override protected CacheAtomicityMode atomicityMode() { + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { return ATOMIC; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicReferenceApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicReferenceApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicReferenceApiSelfTest.java index c502179..c191de6 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicReferenceApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicReferenceApiSelfTest.java @@ -22,26 +22,21 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * AtomicReference basic tests. */ public class GridCachePartitionedAtomicReferenceApiSelfTest extends GridCacheAtomicReferenceApiSelfAbstractTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - // Default cache configuration. - CacheConfiguration cacheCfg = getCacheConfiguration(); + @Override protected CacheMode atomicsCacheMode() { + return PARTITIONED; + } - cacheCfg.setCacheMode(PARTITIONED); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setBackups(1); - cacheCfg.setPreloadMode(SYNC); + /** {@inheritDoc} */ + @Override protected IgniteAtomicConfiguration atomicConfiguration() { + IgniteAtomicConfiguration cfg = super.atomicConfiguration(); - cfg.setCacheConfiguration(cacheCfg); + cfg.setBackups(1); return cfg; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java index 04f9d9b..19b4d70 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicSequenceMultiThreadedTest.java @@ -20,66 +20,40 @@ package org.apache.ignite.internal.processors.cache.datastructures.partitioned; import org.apache.ignite.*; import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; import org.apache.ignite.internal.processors.datastructures.*; -import org.apache.ignite.internal.util.typedef.*; -import org.apache.ignite.spi.discovery.tcp.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.*; -import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import org.apache.ignite.internal.util.typedef.internal.*; -import org.apache.ignite.testframework.junits.common.*; import java.util.*; -import static org.apache.ignite.cache.CacheAtomicityMode.*; -import static org.apache.ignite.cache.CacheDistributionMode.*; import static org.apache.ignite.cache.CacheMode.*; /** * Cache partitioned multi-threaded tests. */ -public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCommonAbstractTest { - /** IP finder. */ - private static final TcpDiscoveryIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); - +public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends IgniteAtomicsAbstractTest { /** Number of threads for multithreaded test. */ private static final int THREAD_NUM = 30; /** Number of iterations per thread for multithreaded test. */ private static final int ITERATION_NUM = 4000; - /** Constructor. Starts grid. */ - public GridCachePartitionedAtomicSequenceMultiThreadedTest() { - super(true /** Start grid. */); + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return PARTITIONED; } /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - IgniteAtomicConfiguration atomicCfg = new IgniteAtomicConfiguration(); - - atomicCfg.setAtomicSequenceReserveSize(10); - atomicCfg.setCacheMode(PARTITIONED); - atomicCfg.setBackups(1); - - cfg.setAtomicConfiguration(atomicCfg); - - TcpDiscoverySpi disco = new TcpDiscoverySpi(); - - disco.setIpFinder(IP_FINDER); - - cfg.setDiscoverySpi(disco); - - // Default cache configuration. - CacheConfiguration dfltCacheCfg = defaultCacheConfiguration(); + @Override protected int gridCount() { + return 1; + } - dfltCacheCfg.setCacheMode(PARTITIONED); - dfltCacheCfg.setBackups(1); - dfltCacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); - dfltCacheCfg.setAtomicityMode(TRANSACTIONAL); - dfltCacheCfg.setDistributionMode(NEAR_PARTITIONED); + /** {@inheritDoc} */ + @Override protected IgniteAtomicConfiguration atomicConfiguration() { + IgniteAtomicConfiguration cfg = super.atomicConfiguration(); - cfg.setCacheConfiguration(dfltCacheCfg); + cfg.setBackups(1); + cfg.setAtomicSequenceReserveSize(10); return cfg; } @@ -88,7 +62,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom public void testValues() throws Exception { String seqName = UUID.randomUUID().toString(); - final GridCacheAtomicSequenceImpl seq = (GridCacheAtomicSequenceImpl)grid().atomicSequence(seqName, 0, true); + final GridCacheAtomicSequenceImpl seq = (GridCacheAtomicSequenceImpl)grid(0).atomicSequence(seqName, 0, true); // Local reservations. assertEquals(1, seq.incrementAndGet()); @@ -174,7 +148,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -190,7 +164,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -206,7 +180,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -222,7 +196,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -238,7 +212,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -254,7 +228,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -270,7 +244,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -291,7 +265,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom // Random sequence names. String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); runSequenceClosure(new GridInUnsafeClosure<IgniteAtomicSequence>() { @Override public void apply(IgniteAtomicSequence t) throws IgniteCheckedException { @@ -337,7 +311,7 @@ public class GridCachePartitionedAtomicSequenceMultiThreadedTest extends GridCom private void checkUpdate(boolean updated) throws Exception { String seqName = UUID.randomUUID().toString(); - final IgniteAtomicSequence seq = grid().atomicSequence(seqName, 0L, true); + final IgniteAtomicSequence seq = grid(0).atomicSequence(seqName, 0L, true); long curVal = 0; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicStampedApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicStampedApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicStampedApiSelfTest.java index 75e8089..54ead35 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicStampedApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedAtomicStampedApiSelfTest.java @@ -21,31 +21,22 @@ import org.apache.ignite.cache.*; import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; -import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CacheDistributionMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * AtomicReference basic tests. */ public class GridCachePartitionedAtomicStampedApiSelfTest extends GridCacheAtomicStampedApiSelfAbstractTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - // Default cache configuration. - CacheConfiguration cacheCfg = defaultCacheConfiguration(); + @Override protected CacheMode atomicsCacheMode() { + return PARTITIONED; + } - cacheCfg.setCacheMode(PARTITIONED); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cacheCfg.setPreloadMode(SYNC); - cacheCfg.setBackups(1); - cacheCfg.setAtomicityMode(TRANSACTIONAL); - cacheCfg.setDistributionMode(NEAR_PARTITIONED); + /** {@inheritDoc} */ + @Override protected IgniteAtomicConfiguration atomicConfiguration() { + IgniteAtomicConfiguration cfg = super.atomicConfiguration(); - cfg.setCacheConfiguration(cacheCfg); + cfg.setBackups(1); return cfg; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedCountDownLatchSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedCountDownLatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedCountDownLatchSelfTest.java new file mode 100644 index 0000000..cbd94d4 --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedCountDownLatchSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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.datastructures.partitioned; + +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class GridCachePartitionedCountDownLatchSelfTest extends GridCacheCountDownLatchAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return PARTITIONED; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java index f5d4617..0a018ff 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedDataStructuresFailoverSelfTest.java @@ -28,7 +28,7 @@ import static org.apache.ignite.cache.CacheMode.*; public class GridCachePartitionedDataStructuresFailoverSelfTest extends GridCacheAbstractDataStructuresFailoverSelfTest { /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { + @Override protected CacheMode atomicsCacheMode() { return PARTITIONED; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java index 659ef28..92b4012 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedNodeRestartTxSelfTest.java @@ -78,6 +78,13 @@ public class GridCachePartitionedNodeRestartTxSelfTest extends GridCommonAbstrac cfg.setCacheConfiguration(cacheCfg); + IgniteAtomicConfiguration atomicCfg = new IgniteAtomicConfiguration(); + + atomicCfg.setCacheMode(PARTITIONED); + atomicCfg.setBackups(1); + + cfg.setAtomicConfiguration(atomicCfg); + return cfg; } @@ -170,7 +177,7 @@ public class GridCachePartitionedNodeRestartTxSelfTest extends GridCommonAbstrac } /** - * Test {@link GridCacheInternalKey}/{@link org.apache.ignite.internal.processors.datastructures.GridCacheAtomicLongValue}. + * Test {@link GridCacheInternalKey}/{@link GridCacheAtomicLongValue}. * @param name Name. * @throws Exception If failed. */ @@ -211,7 +218,7 @@ public class GridCachePartitionedNodeRestartTxSelfTest extends GridCommonAbstrac assert PARTITIONED == grid(i).cache(null).configuration().getCacheMode(); - IgniteAtomicLong atomic = grid(i).cache(null).dataStructures().atomicLong(name, 0, true); + IgniteAtomicLong atomic = grid(i).atomicLong(name, 0, true); long val = atomic.get(); @@ -285,9 +292,9 @@ public class GridCachePartitionedNodeRestartTxSelfTest extends GridCommonAbstrac assert PARTITIONED == grid(i).cache(null).configuration().getCacheMode(); // Init cache data. - grid(0).cache(null).dataStructures().atomicLong(key, 0, true).getAndSet(INIT_GRID_NUM); + grid(0).atomicLong(key, 0, true).getAndSet(INIT_GRID_NUM); - assert INIT_GRID_NUM == grid(0).cache(null).dataStructures().atomicLong(key, 0, true).get(); + assertEquals(INIT_GRID_NUM, grid(0).atomicLong(key, 0, true).get()); stopGrid(0); } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueApiSelfTest.java index dd15b73..c46e86b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueApiSelfTest.java @@ -18,35 +18,22 @@ package org.apache.ignite.internal.processors.cache.datastructures.partitioned; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CacheDistributionMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * Queue tests with partitioned cache. */ public class GridCachePartitionedQueueApiSelfTest extends GridCacheQueueApiSelfAbstractTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration c = super.getConfiguration(); - - // Default cache configuration. - CacheConfiguration cc = defaultCacheConfiguration(); - - cc.setCacheMode(PARTITIONED); - cc.setWriteSynchronizationMode(FULL_SYNC); - cc.setBackups(1); - cc.setPreloadMode(SYNC); - cc.setAtomicityMode(TRANSACTIONAL); - cc.setDistributionMode(NEAR_PARTITIONED); - - c.setCacheConfiguration(cc); + @Override protected CacheMode collectionCacheMode() { + return PARTITIONED; + } - return c; + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { + return TRANSACTIONAL; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java index 5abb9ff..8579c7a 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/partitioned/GridCachePartitionedQueueFailoverDataConsistencySelfTest.java @@ -17,11 +17,18 @@ package org.apache.ignite.internal.processors.cache.datastructures.partitioned; +import org.apache.ignite.cache.*; import org.apache.ignite.internal.processors.cache.datastructures.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; + /** * Queue failover test for transactional cache. */ public class GridCachePartitionedQueueFailoverDataConsistencySelfTest extends GridCacheAbstractQueueFailoverDataConsistencySelfTest { + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { + return TRANSACTIONAL; + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicLongApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicLongApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicLongApiSelfTest.java new file mode 100644 index 0000000..9deb2fa --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicLongApiSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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.datastructures.replicated; + +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class GridCacheReplicatedAtomicLongApiSelfTest extends GridCacheAtomicLongApiAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return REPLICATED; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicReferenceApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicReferenceApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicReferenceApiSelfTest.java index b8b5ae2..99b5ffd 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicReferenceApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicReferenceApiSelfTest.java @@ -18,28 +18,16 @@ package org.apache.ignite.internal.processors.cache.datastructures.replicated; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * AtomicReference tests with replicated cache. */ public class GridCacheReplicatedAtomicReferenceApiSelfTest extends GridCacheAtomicReferenceApiSelfAbstractTest { - /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - IgniteConfiguration cfg = super.getConfiguration(gridName); - - // Default cache configuration. - CacheConfiguration cacheCfg = getCacheConfiguration(); - - cacheCfg.setCacheMode(REPLICATED); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cfg.setCacheConfiguration(cacheCfg); - - return cfg; + @Override protected CacheMode atomicsCacheMode() { + return REPLICATED; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicStampedApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicStampedApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicStampedApiSelfTest.java index 629e3b0..d4cdd6b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicStampedApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedAtomicStampedApiSelfTest.java @@ -18,27 +18,16 @@ package org.apache.ignite.internal.processors.cache.datastructures.replicated; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * AtomicReference tests with replicated cache. */ public class GridCacheReplicatedAtomicStampedApiSelfTest extends GridCacheAtomicStampedApiSelfAbstractTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - // Default cache configuration. - CacheConfiguration cacheCfg = defaultCacheConfiguration(); - - cacheCfg.setCacheMode(REPLICATED); - cacheCfg.setWriteSynchronizationMode(FULL_SYNC); - cfg.setCacheConfiguration(cacheCfg); - - return cfg; + @Override protected CacheMode atomicsCacheMode() { + return REPLICATED; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedCountDownLatchSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedCountDownLatchSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedCountDownLatchSelfTest.java new file mode 100644 index 0000000..18ca3ca --- /dev/null +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedCountDownLatchSelfTest.java @@ -0,0 +1,33 @@ +/* + * 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.datastructures.replicated; + +import org.apache.ignite.cache.*; +import org.apache.ignite.internal.processors.cache.datastructures.*; + +import static org.apache.ignite.cache.CacheMode.*; + +/** + * + */ +public class GridCacheReplicatedCountDownLatchSelfTest extends GridCacheCountDownLatchAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected CacheMode atomicsCacheMode() { + return REPLICATED; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java index 7cacf42..b0a936b 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedDataStructuresFailoverSelfTest.java @@ -28,7 +28,7 @@ import static org.apache.ignite.cache.CacheMode.*; public class GridCacheReplicatedDataStructuresFailoverSelfTest extends GridCacheAbstractDataStructuresFailoverSelfTest { /** {@inheritDoc} */ - @Override protected CacheMode cacheMode() { + @Override protected CacheMode atomicsCacheMode() { return REPLICATED; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedQueueApiSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedQueueApiSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedQueueApiSelfTest.java index fb7e23a..9c02b14 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedQueueApiSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/datastructures/replicated/GridCacheReplicatedQueueApiSelfTest.java @@ -18,30 +18,22 @@ package org.apache.ignite.internal.processors.cache.datastructures.replicated; import org.apache.ignite.cache.*; -import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.datastructures.*; +import static org.apache.ignite.cache.CacheAtomicityMode.*; import static org.apache.ignite.cache.CacheMode.*; -import static org.apache.ignite.cache.CachePreloadMode.*; -import static org.apache.ignite.cache.CacheWriteSynchronizationMode.*; /** * Queue tests with replicated cache. */ public class GridCacheReplicatedQueueApiSelfTest extends GridCacheQueueApiSelfAbstractTest { /** {@inheritDoc} */ - @Override protected IgniteConfiguration getConfiguration() throws Exception { - IgniteConfiguration cfg = super.getConfiguration(); - - // Default cache configuration. - CacheConfiguration dfltCacheCfg = defaultCacheConfiguration(); - - dfltCacheCfg.setCacheMode(REPLICATED); - dfltCacheCfg.setWriteSynchronizationMode(FULL_SYNC); - dfltCacheCfg.setPreloadMode(SYNC); - - cfg.setCacheConfiguration(dfltCacheCfg); + @Override protected CacheMode collectionCacheMode() { + return REPLICATED; + } - return cfg; + /** {@inheritDoc} */ + @Override protected CacheAtomicityMode collectionCacheAtomicityMode() { + return TRANSACTIONAL; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/349d51ed/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestIgnite.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestIgnite.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestIgnite.java index a4309b4..b830ef8 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestIgnite.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridTestIgnite.java @@ -256,5 +256,24 @@ public class GridTestIgnite implements Ignite { } /** {@inheritDoc} */ + @Nullable @Override public <T> IgniteQueue<T> queue(String name, + IgniteCollectionConfiguration cfg, + int cap, + boolean create) + throws IgniteCheckedException + { + return null; + } + + /** {@inheritDoc} */ + @Nullable @Override public <T> IgniteSet<T> set(String name, + IgniteCollectionConfiguration cfg, + boolean create) + throws IgniteCheckedException + { + return null; + } + + /** {@inheritDoc} */ @Override public void close() throws IgniteCheckedException {} }