IGNITE-379 Fix tests.

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

Branch: refs/heads/ignite-471
Commit: fe91e0c20bc7f4f944f95893708c953b84eb1f8a
Parents: 69b52df
Author: sevdokimov <sevdoki...@gridgain.com>
Authored: Tue Mar 24 16:20:47 2015 +0300
Committer: sevdokimov <sevdoki...@gridgain.com>
Committed: Tue Mar 24 16:20:47 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheStoreManager.java | 61 +++++++++++++++-----
 .../cache/GridCacheWriteBehindStore.java        | 36 +++++++-----
 2 files changed, 69 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe91e0c2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
index 5ac0d39..17a732d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheStoreManager.java
@@ -255,10 +255,14 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
             initSession(tx);
 
+            boolean thewEx = true;
+
             Object val = null;
 
             try {
                 val = singleThreadGate.load(storeKey);
+
+                thewEx = false;
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -270,7 +274,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 throw new IgniteCheckedException(new CacheLoaderException(e));
             }
             finally {
-                endSession(tx);
+                endSession(tx, thewEx);
             }
 
             if (log.isDebugEnabled())
@@ -406,6 +410,8 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
             initSession(tx);
 
+            boolean thewEx = true;
+
             try {
                 IgniteBiInClosure<Object, Object> c = new CI2<Object, 
Object>() {
                     @SuppressWarnings("ConstantConditions")
@@ -434,6 +440,8 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 }
                 else
                     singleThreadGate.loadAll(keys0, c);
+
+                thewEx = false;
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -445,7 +453,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 throw new IgniteCheckedException(new CacheLoaderException(e));
             }
             finally {
-                endSession(tx);
+                endSession(tx, thewEx);
             }
 
             if (log.isDebugEnabled())
@@ -470,6 +478,8 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
             initSession(null);
 
+            boolean thewEx = true;
+
             try {
                 store.loadCache(new IgniteBiInClosure<Object, Object>() {
                     @Override public void apply(Object k, Object o) {
@@ -490,6 +500,8 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                         vis.apply(cacheKey, v, ver);
                     }
                 }, args);
+
+                thewEx = false;
             }
             catch (CacheLoaderException e) {
                 throw new IgniteCheckedException(e);
@@ -498,7 +510,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 throw new IgniteCheckedException(new CacheLoaderException(e));
             }
             finally {
-                endSession(null);
+                endSession(null, thewEx);
             }
 
             if (log.isDebugEnabled())
@@ -541,8 +553,12 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
             initSession(tx);
 
+            boolean thewEx = true;
+
             try {
                 store.write(new CacheEntryImpl<>(key, locStore ? F.t(val, ver) 
: val));
+
+                thewEx = false;
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -554,7 +570,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 throw new IgniteCheckedException(new CacheWriterException(e));
             }
             finally {
-                endSession(tx);
+                endSession(tx, thewEx);
             }
 
             if (log.isDebugEnabled())
@@ -595,8 +611,12 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
                 initSession(tx);
 
+                boolean thewEx = true;
+
                 try {
                     store.writeAll(entries);
+
+                    thewEx = false;
                 }
                 catch (ClassCastException e) {
                     handleClassCastException(e);
@@ -617,7 +637,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                     throw new IgniteCheckedException(e);
                 }
                 finally {
-                    endSession(tx);
+                    endSession(tx, thewEx);
                 }
 
                 if (log.isDebugEnabled())
@@ -651,8 +671,12 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
             initSession(tx);
 
+            boolean thewEx = true;
+
             try {
                 store.delete(key);
+
+                thewEx = false;
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -664,7 +688,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 throw new IgniteCheckedException(new CacheWriterException(e));
             }
             finally {
-                endSession(tx);
+                endSession(tx, thewEx);
             }
 
             if (log.isDebugEnabled())
@@ -702,8 +726,12 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
 
             initSession(tx);
 
+            boolean thewEx = true;
+
             try {
                 store.deleteAll(keys0);
+
+                thewEx = false;
             }
             catch (ClassCastException e) {
                 handleClassCastException(e);
@@ -718,7 +746,7 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
                 throw new IgniteCheckedException(e);
             }
             finally {
-                endSession(tx);
+                endSession(tx, thewEx);
             }
 
             if (log.isDebugEnabled())
@@ -785,12 +813,19 @@ public class GridCacheStoreManager extends 
GridCacheManagerAdapter {
     /**
      * Clears session holder.
      */
-    void endSession(@Nullable IgniteInternalTx tx) {
-        if (tx == null)
-            store.sessionEnd(true);
-
-        if (sesHolder != null)
-            sesHolder.set(null);
+    void endSession(@Nullable IgniteInternalTx tx, boolean threwEx) throws 
IgniteCheckedException {
+        try {
+            if (tx == null)
+                store.sessionEnd(threwEx);
+        }
+        catch (Exception e) {
+            if (!threwEx)
+                throw U.cast(e);
+        }
+        finally {
+            if (sesHolder != null)
+                sesHolder.set(null);
+        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/fe91e0c2/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
index 5127392..50aad95 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheWriteBehindStore.java
@@ -666,22 +666,32 @@ public class GridCacheWriteBehindStore<K, V> implements 
CacheStore<K, V>, Lifecy
             storeMgr.initSession(null);
 
         try {
-            switch (operation) {
-                case PUT:
-                    store.writeAll(vals.values());
+            boolean threwEx = true;
 
-                    break;
+            try {
+                switch (operation) {
+                    case PUT:
+                        store.writeAll(vals.values());
 
-                case RMV:
-                    store.deleteAll(vals.keySet());
+                        break;
 
-                    break;
+                    case RMV:
+                        store.deleteAll(vals.keySet());
 
-                default:
-                    assert false : "Unexpected operation: " + operation;
-            }
+                        break;
+
+                    default:
+                        assert false : "Unexpected operation: " + operation;
+                }
 
-            return true;
+                threwEx = false;
+
+                return true;
+            }
+            finally {
+                if (initSes && storeMgr != null)
+                    storeMgr.endSession(null, threwEx);
+            }
         }
         catch (Exception e) {
             LT.warn(log, e, "Unable to update underlying store: " + store);
@@ -700,10 +710,6 @@ public class GridCacheWriteBehindStore<K, V> implements 
CacheStore<K, V>, Lifecy
 
             return false;
         }
-        finally {
-            if (initSes && storeMgr != null)
-                storeMgr.endSession(null);
-        }
     }
 
     /**

Reply via email to