You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/11/13 07:36:11 UTC

ignite git commit: IGNITE-1753 Fixed wrong extraction of type mapping in loadCache() method.

Repository: ignite
Updated Branches:
  refs/heads/ignite-1753-1282 5d6970029 -> 481e8e53c


IGNITE-1753 Fixed wrong extraction of type mapping in loadCache() method.


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

Branch: refs/heads/ignite-1753-1282
Commit: 481e8e53ce48304625fad4409cc3e29f63f669aa
Parents: 5d69700
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Nov 13 13:36:18 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Nov 13 13:36:18 2015 +0700

----------------------------------------------------------------------
 .../store/jdbc/CacheAbstractJdbcStore.java      | 26 ++++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/481e8e53/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
index 03ac436..d544f75 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java
@@ -642,7 +642,7 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
      * @return Type mappings for specified cache name.
      * @throws CacheException If failed to initialize cache mappings.
      */
-    private Map<Object, EntryMapping> cacheMappings(@Nullable String cacheName) throws CacheException {
+    private Map<Object, EntryMapping> getOrCreateCacheMappings(@Nullable String cacheName) throws CacheException {
         Map<Object, EntryMapping> entryMappings = cacheMappings.get(cacheName);
 
         if (entryMappings != null)
@@ -755,13 +755,15 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
      * @throws CacheException If mapping for key was not found.
      */
     private EntryMapping entryMapping(String cacheName, Object typeId) throws CacheException {
-        EntryMapping em = cacheMappings(cacheName).get(typeId);
+        Map<Object, EntryMapping> mappings = getOrCreateCacheMappings(cacheName);
+
+        EntryMapping em = mappings.get(typeId);
 
         if (em == null) {
             String maskedCacheName = U.maskName(cacheName);
 
-            throw new CacheException("Failed to find mapping description [typeId=" + typeId +
-                ", cache=" + maskedCacheName + "]. Please configure JdbcType to associate '" + maskedCacheName +
+            throw new CacheException("Failed to find mapping description [cache=" + maskedCacheName +
+                ", typeId=" + typeId + "]. Please configure JdbcType to associate cache '" + maskedCacheName +
                 "' with JdbcPojoStore.");
         }
 
@@ -780,6 +782,8 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
 
             Collection<Future<?>> futs = new ArrayList<>();
 
+            Map<Object, EntryMapping> mappings = getOrCreateCacheMappings(cacheName);
+
             if (args != null && args.length > 0) {
                 if (args.length % 2 != 0)
                     throw new CacheLoaderException("Expected even number of arguments, but found: " + args.length);
@@ -787,21 +791,18 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
                 if (log.isDebugEnabled())
                     log.debug("Start loading entries from db using user queries from arguments...");
 
-                // We must build cache mappings first.
-                cacheMappings(cacheName);
-
                 for (int i = 0; i < args.length; i += 2) {
                     String keyType = args[i].toString();
 
                     String selQry = args[i + 1].toString();
 
-                    EntryMapping em = entryMapping(cacheName, keyType);
+                    EntryMapping em = entryMapping(cacheName, typeIdForTypeName(kindForName(keyType), keyType));
 
                     futs.add(pool.submit(new LoadCacheCustomQueryWorker<>(em, selQry, clo)));
                 }
             }
             else {
-                Collection<EntryMapping> entryMappings = cacheMappings(session().cacheName()).values();
+                Collection<EntryMapping> entryMappings = mappings.values();
 
                 for (EntryMapping em : entryMappings) {
                     if (parallelLoadCacheMinThreshold > 0) {
@@ -924,7 +925,7 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
 
             String cacheName = session().cacheName();
 
-            Map<Object, LoadWorker<K, V>> workers = U.newHashMap(cacheMappings(cacheName).size());
+            Map<Object, LoadWorker<K, V>> workers = U.newHashMap(getOrCreateCacheMappings(cacheName).size());
 
             Map<K, V> res = new HashMap<>();
 
@@ -1254,13 +1255,12 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>,
 
             if (delCnt != 1)
                 U.warn(log, "Unexpected number of deleted entries [table=" + em.fullTableName() + ", key=" + key +
-                    ", expected=1, actual=" + delCnt + "]");
+                        ", expected=1, actual=" + delCnt + "]");
         }
         catch (SQLException e) {
             throw new CacheWriterException("Failed to remove value from database [table=" + em.fullTableName() +
                 ", key=" + key + "]", e);
-        }
-        finally {
+        } finally {
             end(conn, stmt);
         }
     }