ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agoncha...@apache.org
Subject [1/8] incubator-ignite git commit: GG-9141 - Check for cache enlist in TX
Date Fri, 19 Dec 2014 03:21:58 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-1 e248ca73f -> fb1913090


GG-9141 - Check for cache enlist in TX


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

Branch: refs/heads/ignite-1
Commit: a70cfa2c24cd56656f09e3717326a94decd2c544
Parents: e248ca7
Author: Alexey Goncharuk <agoncharuk@gridgain.com>
Authored: Tue Dec 16 23:02:17 2014 -0800
Committer: Alexey Goncharuk <agoncharuk@gridgain.com>
Committed: Tue Dec 16 23:02:17 2014 -0800

----------------------------------------------------------------------
 .../processors/cache/GridCacheContext.java      |  1 -
 .../cache/GridCacheTxLocalAdapter.java          | 27 +++++++++++++++++---
 2 files changed, 24 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a70cfa2c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
index c6cb355..98766fb 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheContext.java
@@ -15,7 +15,6 @@ import org.apache.ignite.configuration.*;
 import org.apache.ignite.lang.*;
 import org.apache.ignite.marshaller.*;
 import org.apache.ignite.portables.*;
-import org.gridgain.grid.*;
 import org.gridgain.grid.cache.*;
 import org.gridgain.grid.cache.cloner.*;
 import org.gridgain.grid.kernal.*;

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a70cfa2c/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
index abb9fef..59f0e97 100644
--- a/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
+++ b/modules/core/src/main/java/org/gridgain/grid/kernal/processors/cache/GridCacheTxLocalAdapter.java
@@ -2610,10 +2610,31 @@ public abstract class GridCacheTxLocalAdapter<K, V> extends
GridCacheTxAdapter<K
      *      cache (e.g. they have different stores).
      */
     private void addActiveCache(GridCacheContext<K, V> cacheCtx) throws IgniteCheckedException
{
+        int cacheId = cacheCtx.cacheId();
+
         // If this is a first cache to work on, capture cache settings.
-        if (activeCacheIds.isEmpty() ||
-            !activeCacheIds.contains(cacheCtx.cacheId()) && cctx.txCompatible(activeCacheIds,
cacheCtx))
-            activeCacheIds.add(cacheCtx.cacheId());
+        if (activeCacheIds.isEmpty())
+            activeCacheIds.add(cacheId);
+        // Else check if we can enlist new cache to transaction.
+        else if (!activeCacheIds.contains(cacheId)) {
+            if (!cctx.txCompatible(activeCacheIds, cacheCtx)) {
+                StringBuilder cacheNames = new StringBuilder();
+
+                for (Integer activeCacheId : activeCacheIds) {
+                    cacheNames.append(cctx.cacheContext(activeCacheId).name());
+
+                    cacheNames.append(", ");
+                }
+
+                cacheNames.setLength(cacheNames.length() - 2);
+
+                throw new IgniteCheckedException("Failed to enlist new cache to existing
transaction " +
+                    "(cache configurations are not compatible) [activeCaches=[" + cacheNames
+
+                    "], cacheName=" + cacheCtx.name() + ']');
+            }
+            else
+                activeCacheIds.add(cacheId);
+        }
     }
 
     /**


Mime
View raw message