ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject [1/2] incubator-ignite git commit: sprint-2 - Marshaller fix
Date Fri, 27 Mar 2015 04:29:34 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/sprint-2 23ea87896 -> 988b6b914


sprint-2 - Marshaller fix


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

Branch: refs/heads/sprint-2
Commit: 756f3e6e448366de300b63b476a3f7a566101585
Parents: 23ea878
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Thu Mar 26 21:30:39 2015 -0700
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Thu Mar 26 21:30:39 2015 -0700

----------------------------------------------------------------------
 .../internal/MarshallerContextAdapter.java      |  5 +-
 .../ignite/internal/MarshallerContextImpl.java  | 62 +++++++++-----------
 .../ignite/marshaller/MarshallerContext.java    |  5 +-
 .../optimized/OptimizedMarshallerUtils.java     |  2 +-
 4 files changed, 35 insertions(+), 39 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/756f3e6e/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
index 5bd625b..08f2137 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextAdapter.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal;
 
+import org.apache.ignite.*;
 import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.*;
 import org.jsr166.*;
@@ -80,7 +81,7 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
     }
 
     /** {@inheritDoc} */
-    @Override public boolean registerClass(int id, Class cls) {
+    @Override public boolean registerClass(int id, Class cls) throws IgniteCheckedException
{
         boolean registered = true;
 
         if (!map.containsKey(id)) {
@@ -118,7 +119,7 @@ public abstract class MarshallerContextAdapter implements MarshallerContext
{
      * @param clsName Class name.
      * @return Whether class name was registered.
      */
-    protected abstract boolean registerClassName(int id, String clsName);
+    protected abstract boolean registerClassName(int id, String clsName) throws IgniteCheckedException;
 
     /**
      * Gets class name by type ID.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/756f3e6e/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
index 4947dad..fa2ae16 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java
@@ -27,9 +27,6 @@ import java.util.concurrent.*;
  * Marshaller context implementation.
  */
 public class MarshallerContextImpl extends MarshallerContextAdapter {
-    /** Class names cache update retries count. */
-    private static final int CACHE_UPDATE_RETRIES_CNT = 5;
-
     /** */
     private final CountDownLatch latch = new CountDownLatch(1);
 
@@ -39,6 +36,9 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     /** */
     private volatile GridCacheAdapter<Integer, String> cache;
 
+    /** Non-volatile on purpose. */
+    private int failedCnt;
+
     /**
      * @param ctx Kernal context.
      */
@@ -53,44 +53,36 @@ public class MarshallerContextImpl extends MarshallerContextAdapter {
     }
 
     /** {@inheritDoc} */
-    @Override protected boolean registerClassName(int id, String clsName) {
+    @Override protected boolean registerClassName(int id, String clsName) throws IgniteCheckedException
{
+        GridCacheAdapter<Integer, String> cache0 = cache;
+
+        if (cache0 == null)
+            return false;
+
+        String old;
+
         try {
-            GridCacheAdapter<Integer, String> cache0 = cache;
+            old = cache0.tryPutIfAbsent(id, clsName);
 
-            if (cache0 == null)
-                return false;
+            if (old != null && !old.equals(clsName)) {
+                U.warn(log, "Type ID collision occurred in marshaller (this can cause performance
degradation). " +
+                    "Use marshaller configuration to resolve it [id=" + id + ", clsName1="
+ clsName +
+                    "clsName2=" + old + ']');
 
-            for (int i = 0; i < CACHE_UPDATE_RETRIES_CNT; i++) {
-                try {
-                    String old;
-
-                    try {
-                        old = cache0.tryPutIfAbsent(id, clsName);
-                    }
-                    catch (GridCacheTryPutFailedException ignored) {
-                        return false;
-                    }
-
-                    if (old != null && !old.equals(clsName))
-                        throw new IgniteException("Type ID collision occurred in OptimizedMarshaller.
Use " +
-                            "OptimizedMarshallerIdMapper to resolve it [id=" + id + ", clsName1="
+ clsName +
-                            "clsName2=" + old + ']');
-
-                    break;
-                }
-                catch (IgniteCheckedException e) {
-                    if (i == CACHE_UPDATE_RETRIES_CNT - 1)
-                        throw e;
-                    else
-                        U.error(log, "Failed to update marshaller cache, will retry: " +
e);
-                }
+                return false;
             }
+
+            failedCnt = 0;
+
+            return true;
         }
-        catch (IgniteCheckedException e) {
-            throw U.convertException(e);
-        }
+        catch (CachePartialUpdateCheckedException | GridCacheTryPutFailedException e) {
+            if (failedCnt++ >= 10)
+                U.warn(log, e, "Marshaller failed to register class for more than 10 times
" +
+                    "(this can cause performance degradation).");
 
-        return true;
+            return false;
+        }
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/756f3e6e/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
index 9b81626..393a35b 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerContext.java
@@ -17,6 +17,8 @@
 
 package org.apache.ignite.marshaller;
 
+import org.apache.ignite.*;
+
 /**
  * Marshaller context.
  */
@@ -27,8 +29,9 @@ public interface MarshallerContext {
      * @param id Type ID.
      * @param cls Class.
      * @return Whether class was registered.
+     * @throws IgniteCheckedException In case of error.
      */
-    public boolean registerClass(int id, Class cls);
+    public boolean registerClass(int id, Class cls) throws IgniteCheckedException;
 
     /**
      * Gets class for provided type ID.

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/756f3e6e/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
index 7f68fbd..d5caa9d 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerUtils.java
@@ -191,7 +191,7 @@ class OptimizedMarshallerUtils {
             try {
                 registered = ctx.registerClass(typeId, cls);
             }
-            catch (Exception e) {
+            catch (IgniteCheckedException e) {
                 throw new IOException("Failed to register class: " + cls.getName(), e);
             }
 


Mime
View raw message