You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by av...@apache.org on 2016/01/29 13:16:10 UTC
[1/2] ignite git commit: 2224-3
Repository: ignite
Updated Branches:
refs/heads/ignite-2224-3 51ee71b72 -> 93910adf4
2224-3
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/bd2bb990
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/bd2bb990
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/bd2bb990
Branch: refs/heads/ignite-2224-3
Commit: bd2bb990396bbf39b9bd33c70ae777b62533654f
Parents: 51ee71b
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Jan 29 12:29:40 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Jan 29 12:29:40 2016 +0300
----------------------------------------------------------------------
.../CacheSerializableTransactionsTest.java | 270 +++++--------------
1 file changed, 70 insertions(+), 200 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/bd2bb990/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
index 81f225b..4baef66 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheSerializableTransactionsTest.java
@@ -577,53 +577,20 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTxCommitReadOnlyGetAll() throws Exception {
- Ignite ignite0 = ignite(0);
-
- final IgniteTransactions txs = ignite0.transactions();
-
- for (CacheConfiguration<Integer, Integer> ccfg : cacheConfigurations()) {
- logCacheInfo(ccfg);
-
- try {
- IgniteCache<Integer, Integer> cache = ignite0.createCache(ccfg);
-
- Set<Integer> keys = new HashSet<>();
-
- for (int i = 0; i < 100; i++)
- keys.add(i);
-
- try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Map<Integer, Integer> map = cache.getAll(keys);
-
- assertTrue(map.isEmpty());
-
- tx.commit();
- }
-
- for (Integer key : keys)
- checkValue(key, null, cache.getName());
-
- try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Map<Integer, Integer> map = cache.getAll(keys);
-
- assertTrue(map.isEmpty());
-
- tx.rollback();
- }
-
- for (Integer key : keys)
- checkValue(key, null, cache.getName());
- }
- finally {
- destroyCache(ccfg.getName());
- }
- }
+ testTxCommitReadOnlyGetAll(false);
}
/**
* @throws Exception If failed.
*/
public void testTxCommitReadOnlyGetEntries() throws Exception {
+ testTxCommitReadOnlyGetAll(true);
+ }
+
+ /**
+ * @throws Exception If failed.
+ */
+ public void testTxCommitReadOnlyGetAll(boolean needVer) throws Exception {
Ignite ignite0 = ignite(0);
final IgniteTransactions txs = ignite0.transactions();
@@ -640,9 +607,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
keys.add(i);
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
+ if (needVer) {
+ Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
+
+ assertTrue(c.isEmpty());
+ }
+ else {
+ Map<Integer, Integer> map = cache.getAll(keys);
- assertTrue(c.isEmpty());
+ assertTrue(map.isEmpty());
+ }
tx.commit();
}
@@ -651,9 +625,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, null, cache.getName());
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
+ if (needVer) {
+ Collection<CacheEntry<Integer, Integer>> c = cache.getEntries(keys);
- assertTrue(c.isEmpty());
+ assertTrue(c.isEmpty());
+ }
+ else {
+ Map<Integer, Integer> map = cache.getAll(keys);
+
+ assertTrue(map.isEmpty());
+ }
tx.rollback();
}
@@ -702,35 +683,35 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTxConflictRead1() throws Exception {
- txConflictRead(true);
+ txConflictRead(true, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictRead2() throws Exception {
- txConflictRead(false);
+ txConflictRead(false, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadEntry1() throws Exception {
- txConflictReadEntry(true);
+ txConflictRead(true, true);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadEntry2() throws Exception {
- txConflictReadEntry(false);
+ txConflictRead(false, true);
}
/**
* @param noVal If {@code true} there is no cache value when read in tx.
* @throws Exception If failed.
*/
- private void txConflictRead(boolean noVal) throws Exception {
+ private void txConflictRead(boolean noVal, boolean needVer) throws Exception {
Ignite ignite0 = ignite(0);
final IgniteTransactions txs = ignite0.transactions();
@@ -756,9 +737,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
try {
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
+ if (needVer) {
+ CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(expVal, val);
+ assertEquals(expVal, val == null ? null : val.getValue());
+ }
+ else {
+ Integer val = cache.get(key);
+
+ assertEquals(expVal, val);
+ }
updateKey(cache, key, 1);
@@ -774,73 +762,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, 1, cache.getName());
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Object val = cache.get(key);
-
- assertEquals(1, val);
-
- tx.commit();
- }
-
- checkValue(key, 1, cache.getName());
- }
- }
- finally {
- destroyCache(ccfg.getName());
- }
- }
- }
-
- /**
- * @param noVal If {@code true} there is no cache value when read in tx.
- * @throws Exception If failed.
- */
- private void txConflictReadEntry(boolean noVal) throws Exception {
- Ignite ignite0 = ignite(0);
-
- final IgniteTransactions txs = ignite0.transactions();
-
- for (CacheConfiguration<Integer, Integer> ccfg : cacheConfigurations()) {
- logCacheInfo(ccfg);
-
- try {
- IgniteCache<Integer, Integer> cache = ignite0.createCache(ccfg);
-
- List<Integer> keys = testKeys(cache);
-
- for (Integer key : keys) {
- log.info("Test key: " + key);
-
- Integer expVal = null;
-
- if (!noVal) {
- expVal = -1;
-
- cache.put(key, expVal);
- }
-
- try {
- try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+ if (needVer) {
CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(expVal, val == null ? null : val.getValue());
-
- updateKey(cache, key, 1);
-
- tx.commit();
+ assertEquals((Integer)1, val.getValue());
}
+ else {
+ Object val = cache.get(key);
- fail();
- }
- catch (TransactionOptimisticException e) {
- log.info("Expected exception: " + e);
- }
-
- checkValue(key, 1, cache.getName());
-
- try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- CacheEntry<Integer, Integer> val = cache.getEntry(key);
-
- assertEquals((Integer)1, val.getValue());
+ assertEquals(1, val);
+ }
tx.commit();
}
@@ -858,56 +789,56 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @throws Exception If failed.
*/
public void testTxConflictReadWrite1() throws Exception {
- txConflictReadWrite(true, false);
+ txConflictReadWrite(true, false, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadWrite2() throws Exception {
- txConflictReadWrite(false, false);
+ txConflictReadWrite(false, false, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadRemove1() throws Exception {
- txConflictReadWrite(true, true);
+ txConflictReadWrite(true, true, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadRemove2() throws Exception {
- txConflictReadWrite(false, true);
+ txConflictReadWrite(false, true, false);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadEntryWrite1() throws Exception {
- txConflictReadEntryWrite(true, false);
+ txConflictReadWrite(true, false, true);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadEntryWrite2() throws Exception {
- txConflictReadEntryWrite(false, false);
+ txConflictReadWrite(false, false, true);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadEntryRemove1() throws Exception {
- txConflictReadEntryWrite(true, true);
+ txConflictReadWrite(true, true, true);
}
/**
* @throws Exception If failed.
*/
public void testTxConflictReadEntryRemove2() throws Exception {
- txConflictReadEntryWrite(false, true);
+ txConflictReadWrite(false, true, true);
}
/**
@@ -915,7 +846,7 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
* @param rmv If {@code true} tests remove, otherwise put.
* @throws Exception If failed.
*/
- private void txConflictReadWrite(boolean noVal, boolean rmv) throws Exception {
+ private void txConflictReadWrite(boolean noVal, boolean rmv, boolean needVer) throws Exception {
Ignite ignite0 = ignite(0);
final IgniteTransactions txs = ignite0.transactions();
@@ -941,9 +872,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
try {
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
+ if (needVer) {
+ CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(expVal, val);
+ assertEquals(expVal, val == null ? null : val.getValue());
+ }
+ else {
+ Integer val = cache.get(key);
+
+ assertEquals(expVal, val);
+ }
updateKey(cache, key, 1);
@@ -964,84 +902,16 @@ public class CacheSerializableTransactionsTest extends GridCommonAbstractTest {
checkValue(key, 1, cache.getName());
try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- Integer val = cache.get(key);
-
- assertEquals(1, (Object) val);
-
- if (rmv)
- cache.remove(key);
- else
- cache.put(key, 2);
-
- tx.commit();
- }
-
- checkValue(key, rmv ? null : 2, cache.getName());
- }
- }
- finally {
- destroyCache(ccfg.getName());
- }
- }
- }
-
- /**
- * @param noVal If {@code true} there is no cache value when read in tx.
- * @param rmv If {@code true} tests remove, otherwise put.
- * @throws Exception If failed.
- */
- private void txConflictReadEntryWrite(boolean noVal, boolean rmv) throws Exception {
- Ignite ignite0 = ignite(0);
-
- final IgniteTransactions txs = ignite0.transactions();
-
- for (CacheConfiguration<Integer, Integer> ccfg : cacheConfigurations()) {
- logCacheInfo(ccfg);
-
- try {
- IgniteCache<Integer, Integer> cache = ignite0.createCache(ccfg);
-
- List<Integer> keys = testKeys(cache);
-
- for (Integer key : keys) {
- log.info("Test key: " + key);
-
- Integer expVal = null;
-
- if (!noVal) {
- expVal = -1;
-
- cache.put(key, expVal);
- }
-
- try {
- try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
+ if (needVer) {
CacheEntry<Integer, Integer> val = cache.getEntry(key);
- assertEquals(expVal, val == null ? null : val.getValue());
-
- updateKey(cache, key, 1);
-
- if (rmv)
- cache.remove(key);
- else
- cache.put(key, 2);
-
- tx.commit();
+ assertEquals(1, (Object)val.getValue());
}
+ else {
+ Integer val = cache.get(key);
- fail();
- }
- catch (TransactionOptimisticException e) {
- log.info("Expected exception: " + e);
- }
-
- checkValue(key, 1, cache.getName());
-
- try (Transaction tx = txs.txStart(OPTIMISTIC, SERIALIZABLE)) {
- CacheEntry<Integer, Integer> val = cache.getEntry(key);
-
- assertEquals(1, (Object) val.getValue());
+ assertEquals(1, (Object)val);
+ }
if (rmv)
cache.remove(key);
[2/2] ignite git commit: 2224-3
Posted by av...@apache.org.
2224-3
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/93910adf
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/93910adf
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/93910adf
Branch: refs/heads/ignite-2224-3
Commit: 93910adf4f27708c71a6262ba2904e343bb8ee0f
Parents: bd2bb99
Author: Anton Vinogradov <av...@apache.org>
Authored: Fri Jan 29 15:16:11 2016 +0300
Committer: Anton Vinogradov <av...@apache.org>
Committed: Fri Jan 29 15:16:11 2016 +0300
----------------------------------------------------------------------
.../cache/CacheReadThroughRestartSelfTest.java | 128 ++++---------------
1 file changed, 22 insertions(+), 106 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/93910adf/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
index 65b3634..4a4f2ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/CacheReadThroughRestartSelfTest.java
@@ -17,8 +17,6 @@
package org.apache.ignite.internal.processors.cache;
-import java.util.HashSet;
-import java.util.Set;
import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCache;
import org.apache.ignite.cache.CacheAtomicityMode;
@@ -87,71 +85,20 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
* @throws Exception If failed.
*/
public void testReadThroughInTx() throws Exception {
- IgniteCache<String, Integer> cache = grid(1).cache(null);
-
- for (int k = 0; k < 1000; k++)
- cache.put("key" + k, k);
-
- stopAllGrids();
-
- startGrids(2);
-
- Ignite ignite = grid(1);
-
- cache = ignite.cache(null);
-
- for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
- for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
- try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) {
- for (int k = 0; k < 1000; k++) {
- String key = "key" + k;
-
- assertNotNull("Null value for key: " + key, cache.get(key));
- }
-
- tx.commit();
- }
- }
- }
+ testReadThroughInTx(false);
}
/**
* @throws Exception If failed.
*/
public void testReadEntryThroughInTx() throws Exception {
- IgniteCache<String, Integer> cache = grid(1).cache(null);
-
- for (int k = 0; k < 1000; k++)
- cache.put("key" + k, k);
-
- stopAllGrids();
-
- startGrids(2);
-
- Ignite ignite = grid(1);
-
- cache = ignite.cache(null);
-
- for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
- for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
- try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) {
- for (int k = 0; k < 1000; k++) {
- String key = "key" + k;
-
- assertNotNull("Null value for key: " + key, cache.getEntry(key));
- assertNotNull("Null value for key: " + key, cache.getEntry(key));
- }
-
- tx.commit();
- }
- }
- }
+ testReadThroughInTx(true);
}
/**
* @throws Exception If failed.
*/
- public void testReadEntriesThroughInTx() throws Exception {
+ public void testReadThroughInTx(boolean needVer) throws Exception {
IgniteCache<String, Integer> cache = grid(1).cache(null);
for (int k = 0; k < 1000; k++)
@@ -168,13 +115,17 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
for (TransactionConcurrency txConcurrency : TransactionConcurrency.values()) {
for (TransactionIsolation txIsolation : TransactionIsolation.values()) {
try (Transaction tx = ignite.transactions().txStart(txConcurrency, txIsolation, 100000, 1000)) {
- for (int k = 0; k < 100; k++) {
- Set<String> keys = new HashSet<>();
-
- for (int j = k; j < k + 10; j++)
- keys.add("key" + j);
+ for (int k = 0; k < 1000; k++) {
+ String key = "key" + k;
- assertNotNull("Null value for keys: " + k + " - " + k + 9, cache.getEntries(keys));
+ if (needVer) {
+ assertNotNull("Null value for key: " + key, cache.getEntry(key));
+ assertNotNull("Null value for key: " + key, cache.getEntry(key));
+ }
+ else {
+ assertNotNull("Null value for key: " + key, cache.get(key));
+ assertNotNull("Null value for key: " + key, cache.get(key));
+ }
}
tx.commit();
@@ -187,54 +138,20 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
* @throws Exception If failed.
*/
public void testReadThrough() throws Exception {
- IgniteCache<String, Integer> cache = grid(1).cache(null);
-
- for (int k = 0; k < 1000; k++)
- cache.put("key" + k, k);
-
- stopAllGrids();
-
- startGrids(2);
-
- Ignite ignite = grid(1);
-
- cache = ignite.cache(null);
-
- for (int k = 0; k < 1000; k++) {
- String key = "key" + k;
-
- assertNotNull("Null value for key: " + key, cache.get(key));
- }
+ testReadThrough(false);
}
/**
* @throws Exception If failed.
*/
public void testReadEntryThrough() throws Exception {
- IgniteCache<String, Integer> cache = grid(1).cache(null);
-
- for (int k = 0; k < 1000; k++)
- cache.put("key" + k, k);
-
- stopAllGrids();
-
- startGrids(2);
-
- Ignite ignite = grid(1);
-
- cache = ignite.cache(null);
-
- for (int k = 0; k < 1000; k++) {
- String key = "key" + k;
-
- assertNotNull("Null value for key: " + key, cache.getEntry(key));
- }
+ testReadThrough(true);
}
/**
* @throws Exception If failed.
*/
- public void testReadEntriesThrough() throws Exception {
+ public void testReadThrough(boolean needVer) throws Exception {
IgniteCache<String, Integer> cache = grid(1).cache(null);
for (int k = 0; k < 1000; k++)
@@ -248,13 +165,12 @@ public class CacheReadThroughRestartSelfTest extends GridCacheAbstractSelfTest {
cache = ignite.cache(null);
- for (int k = 0; k < 100; k++) {
- Set<String> keys = new HashSet<>();
-
- for (int j = k; j < k + 10; j++)
- keys.add("key" + j);
-
- assertNotNull("Null value for keys: " + k + " - " + k + 9, cache.getEntries(keys));
+ for (int k = 0; k < 1000; k++) {
+ String key = "key" + k;
+ if (needVer)
+ assertNotNull("Null value for key: " + key, cache.getEntry(key));
+ else
+ assertNotNull("Null value for key: " + key, cache.get(key));
}
}
}
\ No newline at end of file