ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [21/24] ignite git commit: IGNITE-5431: Better error message in case of SQL cache mode mismtach. This closes #2103.
Date Fri, 09 Jun 2017 14:21:30 GMT
IGNITE-5431: Better error message in case of SQL cache mode mismtach. This closes #2103.


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

Branch: refs/heads/ignite-5272-atomic
Commit: 72e2f883e1a9a1e1fa2d5c275be143163e1c16ee
Parents: 39c5b5d
Author: Alexander Paschenko <alexander.a.paschenko@gmail.com>
Authored: Fri Jun 9 16:19:37 2017 +0300
Committer: devozerov <vozerov@gridgain.com>
Committed: Fri Jun 9 16:19:37 2017 +0300

----------------------------------------------------------------------
 .../processors/cache/ClusterCachesInfo.java     | 30 +++++++++++++-------
 .../processors/cache/GridCacheAttributes.java   | 17 ++---------
 .../cache/index/H2DynamicTableSelfTest.java     |  3 +-
 3 files changed, 23 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/72e2f883/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
index 0fcc740..d5718f8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/ClusterCachesInfo.java
@@ -145,22 +145,33 @@ class ClusterCachesInfo {
         if (gridData != null && gridData.conflictErr != null)
             throw new IgniteCheckedException(gridData.conflictErr);
 
-        if (checkConsistency && joinDiscoData != null && gridData != null)
{
+        if (joinDiscoData != null && gridData != null) {
             for (CacheJoinNodeDiscoveryData.CacheInfo locCacheInfo : joinDiscoData.caches().values())
{
                 CacheConfiguration locCfg = locCacheInfo.config();
 
                 CacheData cacheData = gridData.gridData.caches().get(locCfg.getName());
 
-                if (cacheData != null)
-                    checkCache(locCacheInfo, cacheData, cacheData.receivedFrom());
+                if (cacheData != null) {
+                    if (!F.eq(cacheData.sql(), locCacheInfo.sql())) {
+                        throw new IgniteCheckedException("Cache configuration mismatch (local
cache was created " +
+                            "via " + (locCacheInfo.sql() ? "CREATE TABLE" : "Ignite API")
+ ", while remote cache " +
+                            "was created via " + (cacheData.sql() ? "CREATE TABLE" : "Ignite
API") + "): " +
+                            locCacheInfo.config().getName());
+                    }
+
+                    if (checkConsistency)
+                        checkCache(locCacheInfo, cacheData, cacheData.receivedFrom());
+                }
 
-                validateStartCacheConfiguration(locCfg);
+                if (checkConsistency)
+                    validateStartCacheConfiguration(locCfg);
             }
         }
 
         joinDiscoData = null;
         gridData = null;
     }
+
     /**
      * Checks that remote caches has configuration compatible with the local.
      *
@@ -172,8 +183,8 @@ class ClusterCachesInfo {
     @SuppressWarnings("unchecked")
     private void checkCache(CacheJoinNodeDiscoveryData.CacheInfo locInfo, CacheData rmtData,
UUID rmt)
         throws IgniteCheckedException {
-        GridCacheAttributes rmtAttr = new GridCacheAttributes(rmtData.cacheConfiguration(),
rmtData.sql());
-        GridCacheAttributes locAttr = new GridCacheAttributes(locInfo.config(), locInfo.sql());
+        GridCacheAttributes rmtAttr = new GridCacheAttributes(rmtData.cacheConfiguration());
+        GridCacheAttributes locAttr = new GridCacheAttributes(locInfo.config());
 
         CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "cacheMode", "Cache mode",
             locAttr.cacheMode(), rmtAttr.cacheMode(), true);
@@ -181,9 +192,6 @@ class ClusterCachesInfo {
         CU.checkAttributeMismatch(log, rmtAttr.groupName(), rmt, "groupName", "Cache group
name",
             locAttr.groupName(), rmtAttr.groupName(), true);
 
-        CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "sql", "SQL flag",
-            locAttr.sql(), rmtAttr.sql(), true);
-
         if (rmtAttr.cacheMode() != LOCAL) {
             CU.checkAttributeMismatch(log, rmtAttr.cacheName(), rmt, "interceptor", "Cache
Interceptor",
                 locAttr.interceptorClassName(), rmtAttr.interceptorClassName(), true);
@@ -1219,8 +1227,8 @@ class ClusterCachesInfo {
      */
     private void validateCacheGroupConfiguration(CacheConfiguration cfg, CacheConfiguration
startCfg)
         throws IgniteCheckedException {
-        GridCacheAttributes attr1 = new GridCacheAttributes(cfg, false);
-        GridCacheAttributes attr2 = new GridCacheAttributes(startCfg, false);
+        GridCacheAttributes attr1 = new GridCacheAttributes(cfg);
+        GridCacheAttributes attr2 = new GridCacheAttributes(startCfg);
 
         CU.validateCacheGroupsAttributesMismatch(log, cfg, startCfg, "cacheMode", "Cache
mode",
             cfg.getCacheMode(), startCfg.getCacheMode(), true);

http://git-wip-us.apache.org/repos/asf/ignite/blob/72e2f883/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java
index 7d97159..dca4286 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAttributes.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.processors.cache;
 
-import java.io.Externalizable;
 import java.io.Serializable;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheMode;
@@ -47,17 +46,12 @@ public class GridCacheAttributes implements Serializable {
     /** Cache configuration. */
     private CacheConfiguration ccfg;
 
-    /** SQL flag - whether the cache is created by an SQL command such as {@code CREATE TABLE}.
*/
-    private boolean sql;
-
     /**
      * @param cfg Cache configuration.
-     * @param sql SQL flag.
+     *
      */
-    public GridCacheAttributes(CacheConfiguration cfg, boolean sql) {
+    public GridCacheAttributes(CacheConfiguration cfg) {
         ccfg = cfg;
-
-        this.sql = sql;
     }
 
     /**
@@ -293,13 +287,6 @@ public class GridCacheAttributes implements Serializable {
     }
 
     /**
-     * @return SQL flag.
-     */
-    public boolean sql() {
-        return sql;
-    }
-
-    /**
      * @param obj Object to get class of.
      * @return Class name or {@code null}.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/72e2f883/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
index 2255fb8..ca1c937 100644
--- a/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
+++ b/modules/indexing/src/test/java/org/apache/ignite/internal/processors/cache/index/H2DynamicTableSelfTest.java
@@ -399,7 +399,8 @@ public class H2DynamicTableSelfTest extends AbstractSchemaSelfTest {
 
                 return null;
             }
-        }, IgniteException.class, "SQL flag mismatch (fix sql flag in cache configuration");
+        }, IgniteException.class, "Cache configuration mismatch (local cache was created
via Ignite API, while " +
+            "remote cache was created via CREATE TABLE): SQL_PUBLIC_Person");
     }
 
     /**


Mime
View raw message