ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sevdoki...@apache.org
Subject [07/35] incubator-ignite git commit: # IGNITE-56 Migration tests to IgniteCache
Date Tue, 10 Feb 2015 16:15:51 GMT
# IGNITE-56 Migration tests to IgniteCache


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/80f7901d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/80f7901d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/80f7901d

Branch: refs/heads/ignite-96
Commit: 80f7901dbd4cbbfc65e5eb4375330ea4381979f8
Parents: 604a680
Author: sevdokimov <sevdokimov@gridgain.com>
Authored: Mon Feb 9 17:18:17 2015 +0300
Committer: sevdokimov <sevdokimov@gridgain.com>
Committed: Mon Feb 9 17:18:17 2015 +0300

----------------------------------------------------------------------
 ...idCachePartitionedNodeRestartTxSelfTest.java |  2 +-
 .../GridCacheAbstractNodeRestartSelfTest.java   | 40 ++++++++++++--------
 2 files changed, 26 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/80f7901d/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 35cc85f..2e3737f 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
@@ -246,7 +246,7 @@ public class GridCachePartitionedNodeRestartTxSelfTest extends GridCommonAbstrac
 
         try (IgniteTx tx = grid(0).transactions().txStart(PESSIMISTIC, REPEATABLE_READ))
{
             // Put simple value.
-            grid(0).cache(null).put(key, INIT_GRID_NUM);
+            grid(0).jcache(null).put(key, INIT_GRID_NUM);
 
             tx.commit();
         }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/80f7901d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
index 2d664d3..481f43a 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/GridCacheAbstractNodeRestartSelfTest.java
@@ -19,6 +19,7 @@ package org.apache.ignite.internal.processors.cache.distributed;
 
 import org.apache.ignite.*;
 import org.apache.ignite.cache.*;
+import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
 import org.apache.ignite.internal.cluster.*;
 import org.apache.ignite.internal.transactions.*;
@@ -28,6 +29,7 @@ import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 import org.apache.ignite.transactions.*;
 
+import javax.cache.*;
 import java.util.*;
 import java.util.concurrent.*;
 import java.util.concurrent.atomic.*;
@@ -163,11 +165,11 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
         startGrids();
 
         try {
-            GridCache<Integer, String> c = grid(idx).cache(CACHE_NAME);
+            IgniteCache<Integer, String> c = grid(idx).jcache(CACHE_NAME);
 
             for (int j = 0; j < retries; j++) {
                 for (int i = 0; i < keyCnt; i++)
-                    c.putx(i, Integer.toString(i));
+                    c.put(i, Integer.toString(i));
 
                 info("Stored items.");
 
@@ -181,7 +183,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                 Ignite ignite = startGrid(idx);
 
-                c = ignite.cache(CACHE_NAME);
+                c = ignite.jcache(CACHE_NAME);
 
                 checkGet(c, j);
             }
@@ -196,7 +198,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
      * @param attempt Attempt.
      * @throws Exception If failed.
      */
-    private void checkGet(GridCache<Integer, String> c, int attempt) throws Exception
{
+    private void checkGet(IgniteCache<Integer, String> c, int attempt) throws Exception
{
         for (int i = 0; i < keyCnt; i++) {
             String v = c.get(i);
 
@@ -496,7 +498,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                             info("Starting put thread...");
 
-                            GridCache<Integer, String> cache = grid(gridIdx).cache(CACHE_NAME);
+                            IgniteCache<Integer, String> cache = grid(gridIdx).jcache(CACHE_NAME);
 
                             while (System.currentTimeMillis() < endTime && err.get()
== null) {
                                 int key = RAND.nextInt(keyCnt);
@@ -504,7 +506,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
                                 try {
                                     cache.put(key, Integer.toString(key));
                                 }
-                                catch (IgniteTxRollbackCheckedException | ClusterTopologyCheckedException
ignored) {
+                                catch (IgniteTxRollbackException | ClusterTopologyException
|CacheException ignored) {
                                     // It is ok if primary node leaves grid.
                                 }
 
@@ -616,7 +618,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                             UUID locNodeId = ignite.cluster().localNode().id();
 
-                            GridCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+                            IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
 
                             List<Integer> keys = new ArrayList<>(txKeys);
 
@@ -632,7 +634,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
                                 int c = 0;
 
                                 try {
-                                    try (IgniteTx tx = cache.txStart(txConcurrency(), REPEATABLE_READ))
{
+                                    try (IgniteTx tx = ignite.transactions().txStart(txConcurrency(),
REPEATABLE_READ)) {
                                         c = txCntr.incrementAndGet();
 
                                         if (c % logFreq == 0)
@@ -652,11 +654,19 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                                         tx.commit();
                                     }
-                                    catch (ClusterTopologyCheckedException ignored) {
+                                    catch (ClusterTopologyException | CacheException e) {
+                                        if (e instanceof CacheException
+                                            && !(e.getCause() instanceof ClusterTopologyException))
+                                            throw e;
+
                                         // It is ok if primary node leaves grid.
                                     }
                                 }
-                                catch (ClusterTopologyCheckedException ignored) {
+                                catch (ClusterTopologyException | CacheException e) {
+                                    if (e instanceof CacheException
+                                        && !(e.getCause() instanceof ClusterTopologyException))
+                                        throw e;
+
                                     // It is ok if primary node leaves grid.
                                 }
 
@@ -766,7 +776,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                             UUID locNodeId = ignite.cluster().localNode().id();
 
-                            GridCache<Integer, String> cache = ignite.cache(CACHE_NAME);
+                            IgniteCache<Integer, String> cache = ignite.jcache(CACHE_NAME);
 
                             List<Integer> keys = new ArrayList<>(txKeys);
 
@@ -781,7 +791,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                                 int c = 0;
 
-                                try (IgniteTx tx = cache.txStart(PESSIMISTIC, REPEATABLE_READ))
{
+                                try (IgniteTx tx = ignite.transactions().txStart(PESSIMISTIC,
REPEATABLE_READ)) {
                                     c = txCntr.incrementAndGet();
 
                                     if (c % logFreq == 0)
@@ -797,7 +807,7 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
 
                                     tx.commit();
                                 }
-                                catch (ClusterTopologyCheckedException ignored) {
+                                catch (ClusterTopologyException ignored) {
                                     // It is ok if primary node leaves grid.
                                 }
 
@@ -877,11 +887,11 @@ public abstract class GridCacheAbstractNodeRestartSelfTest extends GridCommonAbs
      * @param key Key.
      * @param attempt Attempt.
      */
-    private void printFailureDetails(GridCache<Integer, String> c, int key, int attempt)
{
+    private void printFailureDetails(IgniteCache<Integer, String> c, int key, int attempt)
{
         error("*** Failure details ***");
         error("Key: " + key);
         error("Partition: " + c.configuration().getAffinity().partition(key));
         error("Attempt: " + attempt);
-        error("Node: " + c.gridProjection().ignite().cluster().localNode().id());
+        error("Node: " + c.unwrap(Ignite.class).cluster().localNode().id());
     }
 }


Mime
View raw message