ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [43/50] [abbrv] incubator-ignite git commit: # ignite-510
Date Thu, 19 Mar 2015 17:56:50 GMT
# ignite-510


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

Branch: refs/heads/ignite-409
Commit: 385d9c8e5d13423bbb7e49e36afaa3775e075f1d
Parents: 2e6e93d
Author: sboikov <sboikov@gridgain.com>
Authored: Thu Mar 19 12:38:35 2015 +0300
Committer: sboikov <sboikov@gridgain.com>
Committed: Thu Mar 19 12:38:35 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  2 +-
 .../deployment/GridDeploymentLocalStore.java    |  5 +-
 .../GridDeploymentPerLoaderStore.java           |  5 +-
 .../GridDeploymentPerVersionStore.java          |  5 +-
 .../optimized/OptimizedClassDescriptor.java     | 20 ++++++--
 .../optimized/OptimizedMarshaller.java          | 30 +++++++-----
 .../optimized/OptimizedMarshallerUtils.java     | 50 +++++++-------------
 .../optimized/OptimizedObjectInputStream.java   | 19 ++++++--
 .../optimized/OptimizedObjectOutputStream.java  | 21 ++++++--
 .../processors/service/DummyService.java        |  4 ++
 .../optimized/OptimizedMarshallerTest.java      |  4 +-
 .../OptimizedObjectStreamSelfTest.java          |  8 +++-
 .../testframework/junits/GridAbstractTest.java  |  2 +-
 13 files changed, 106 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 031c054..ab1038c 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -1797,7 +1797,7 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
             notifyLifecycleBeansEx(LifecycleEventType.AFTER_NODE_STOP);
 
             // Clean internal class/classloader caches to avoid stopped contexts held in
memory.
-            OptimizedMarshaller.clearCache();
+            U.clearClassCache();
             MarshallerExclusions.clearCache();
             GridEnumCache.clear();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
index 195621c..cd94854 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentLocalStore.java
@@ -523,8 +523,9 @@ class GridDeploymentLocalStore extends GridDeploymentStoreAdapter {
                 // Resource cleanup.
                 ctx.resource().onUndeployed(dep);
 
-                // Clear optimized marshaller's cache. If another marshaller is used, this
is no-op.
-                OptimizedMarshaller.onUndeploy(ldr);
+                // Clear optimized marshaller's cache.
+                if (ctx.config().getMarshaller() instanceof OptimizedMarshaller)
+                    ((OptimizedMarshaller)ctx.config().getMarshaller()).onUndeploy(ldr);
 
                 clearSerializationCaches();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerLoaderStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerLoaderStore.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerLoaderStore.java
index 7a98cbc..e81cf38 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerLoaderStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerLoaderStore.java
@@ -496,8 +496,9 @@ public class GridDeploymentPerLoaderStore extends GridDeploymentStoreAdapter
{
                 ctx.cache().onUndeployed(ldr);
                 ctx.stream().onUndeployed(ldr);
 
-                // Clear optimized marshaller's cache. If another marshaller is used, this
is no-op.
-                OptimizedMarshaller.onUndeploy(ldr);
+                // Clear optimized marshaller's cache.
+                if (ctx.config().getMarshaller() instanceof OptimizedMarshaller)
+                    ((OptimizedMarshaller)ctx.config().getMarshaller()).onUndeploy(ldr);
 
                 clearSerializationCaches();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java
index dc72248..1cfe4b8 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/deployment/GridDeploymentPerVersionStore.java
@@ -1259,8 +1259,9 @@ public class GridDeploymentPerVersionStore extends GridDeploymentStoreAdapter
{
                 ctx.cache().onUndeployed(ldr);
                 ctx.stream().onUndeployed(ldr);
 
-                // Clear optimized marshaller's cache. If another marshaller is used, this
is no-op.
-                OptimizedMarshaller.onUndeploy(ldr);
+                // Clear optimized marshaller's cache.
+                if (ctx.config().getMarshaller() instanceof OptimizedMarshaller)
+                    ((OptimizedMarshaller)ctx.config().getMarshaller()).onUndeploy(ldr);
 
                 clearSerializationCaches();
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
index 2e9c659..9eaf7af 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedClassDescriptor.java
@@ -26,6 +26,7 @@ import sun.misc.*;
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
+import java.util.concurrent.*;
 
 import static java.lang.reflect.Modifier.*;
 import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.*;
@@ -44,6 +45,9 @@ class OptimizedClassDescriptor {
     /** Context. */
     private final MarshallerContext ctx;
 
+    /** */
+    private ConcurrentMap<Class, OptimizedClassDescriptor> clsMap;
+
     /** ID mapper. */
     private final OptimizedMarshallerIdMapper mapper;
 
@@ -107,16 +111,23 @@ class OptimizedClassDescriptor {
     /**
      * Creates descriptor for class.
      *
+     * @param typeId Type ID.
+     * @param clsMap Class descriptors by class map.
      * @param cls Class.
      * @param ctx Context.
      * @param mapper ID mapper.
      * @throws IOException In case of error.
      */
     @SuppressWarnings("ForLoopReplaceableByForEach")
-    OptimizedClassDescriptor(Class<?> cls, int typeId, MarshallerContext ctx, OptimizedMarshallerIdMapper
mapper)
+    OptimizedClassDescriptor(Class<?> cls,
+        int typeId,
+        ConcurrentMap<Class, OptimizedClassDescriptor> clsMap,
+        MarshallerContext ctx,
+        OptimizedMarshallerIdMapper mapper)
         throws IOException {
         this.cls = cls;
         this.typeId = typeId;
+        this.clsMap = clsMap;
         this.ctx = ctx;
         this.mapper = mapper;
 
@@ -614,7 +625,10 @@ class OptimizedClassDescriptor {
                 break;
 
             case OBJ_ARR:
-                OptimizedClassDescriptor compDesc = classDescriptor(obj.getClass().getComponentType(),
ctx, mapper);
+                OptimizedClassDescriptor compDesc = classDescriptor(clsMap,
+                    obj.getClass().getComponentType(),
+                    ctx,
+                    mapper);
 
                 compDesc.writeTypeData(out);
 
@@ -673,7 +687,7 @@ class OptimizedClassDescriptor {
                 break;
 
             case CLS:
-                OptimizedClassDescriptor clsDesc = classDescriptor((Class<?>)obj, ctx,
mapper);
+                OptimizedClassDescriptor clsDesc = classDescriptor(clsMap, (Class<?>)obj,
ctx, mapper);
 
                 clsDesc.writeTypeData(out);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
index 8ceed43..7e61d5b 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedMarshaller.java
@@ -19,11 +19,14 @@ package org.apache.ignite.marshaller.optimized;
 
 import org.apache.ignite.*;
 import org.apache.ignite.internal.util.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.*;
+import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 import sun.misc.*;
 
 import java.io.*;
+import java.util.concurrent.*;
 
 /**
  * Optimized implementation of {@link org.apache.ignite.marshaller.Marshaller}. Unlike {@link
org.apache.ignite.marshaller.jdk.JdkMarshaller},
@@ -82,6 +85,9 @@ public class OptimizedMarshaller extends AbstractMarshaller {
     /** ID mapper. */
     private OptimizedMarshallerIdMapper mapper;
 
+    /** Class descriptors by class. */
+    private final ConcurrentMap<Class, OptimizedClassDescriptor> clsMap = new ConcurrentHashMap8<>();
+
     /**
      * Creates new marshaller will all defaults.
      *
@@ -89,7 +95,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
      */
     public OptimizedMarshaller() {
         if (!available())
-            throw new IgniteException("Using GridOptimizedMarshaller on unsupported JVM version
(some of " +
+            throw new IgniteException("Using OptimizedMarshaller on unsupported JVM version
(some of " +
                 "JVM-private APIs required for the marshaller to work are missing).");
     }
 
@@ -149,7 +155,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
         try {
             objOut = OptimizedObjectStreamRegistry.out();
 
-            objOut.context(ctx, mapper, requireSer);
+            objOut.context(clsMap, ctx, mapper, requireSer);
 
             objOut.out().outputStream(out);
 
@@ -170,7 +176,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
         try {
             objOut = OptimizedObjectStreamRegistry.out();
 
-            objOut.context(ctx, mapper, requireSer);
+            objOut.context(clsMap, ctx, mapper, requireSer);
 
             objOut.writeObject(obj);
 
@@ -194,7 +200,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
         try {
             objIn = OptimizedObjectStreamRegistry.in();
 
-            objIn.context(ctx, mapper, clsLdr != null ? clsLdr : dfltClsLdr);
+            objIn.context(clsMap, ctx, mapper, clsLdr != null ? clsLdr : dfltClsLdr);
 
             objIn.in().inputStream(in);
 
@@ -223,7 +229,7 @@ public class OptimizedMarshaller extends AbstractMarshaller {
         try {
             objIn = OptimizedObjectStreamRegistry.in();
 
-            objIn.context(ctx, mapper, clsLdr != null ? clsLdr : dfltClsLdr);
+            objIn.context(clsMap, ctx, mapper, clsLdr != null ? clsLdr : dfltClsLdr);
 
             objIn.in().bytes(arr, arr.length);
 
@@ -278,14 +284,12 @@ public class OptimizedMarshaller extends AbstractMarshaller {
      *
      * @param ldr Class loader being undeployed.
      */
-    public static void onUndeploy(ClassLoader ldr) {
-        OptimizedMarshallerUtils.onUndeploy(ldr);
-    }
+    public void onUndeploy(ClassLoader ldr) {
+        for (Class<?> cls : clsMap.keySet()) {
+            if (ldr.equals(cls.getClassLoader()))
+                clsMap.remove(cls);
+        }
 
-    /**
-     * Clears internal caches and frees memory. Usually called on system stop.
-     */
-    public static void clearCache() {
-        OptimizedMarshallerUtils.clearCache();
+        U.clearClassCache(ldr);
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/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 8c64e33..ec8039c 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
@@ -151,9 +151,6 @@ class OptimizedMarshallerUtils {
     /** JDK marshaller. */
     static final JdkMarshaller JDK_MARSH = new JdkMarshaller();
 
-    /** Class descriptors by class. */
-    private static final ConcurrentMap<Class, OptimizedClassDescriptor> DESC_BY_CLS
= new ConcurrentHashMap8<>();
-
     static {
         try {
             HASH_SET_MAP_OFF = UNSAFE.objectFieldOffset(HashSet.class.getDeclaredField("map"));
@@ -172,18 +169,21 @@ class OptimizedMarshallerUtils {
     /**
      * Gets descriptor for provided class.
      *
+     * @param clsMap Class descriptors by class map.
      * @param cls Class.
      * @param ctx Context.
      * @param mapper ID mapper.
      * @return Descriptor.
      * @throws IOException In case of error.
      */
-    static OptimizedClassDescriptor classDescriptor(Class cls,
+    static OptimizedClassDescriptor classDescriptor(
+        ConcurrentMap<Class, OptimizedClassDescriptor> clsMap,
+        Class cls,
         MarshallerContext ctx,
         OptimizedMarshallerIdMapper mapper)
         throws IOException
     {
-        OptimizedClassDescriptor desc = DESC_BY_CLS.get(cls);
+        OptimizedClassDescriptor desc = clsMap.get(cls);
 
         if (desc == null) {
             int typeId = resolveTypeId(cls.getName(), mapper);
@@ -197,10 +197,10 @@ class OptimizedMarshallerUtils {
                 throw new IOException("Failed to register class: " + cls.getName(), e);
             }
 
-            desc = new OptimizedClassDescriptor(cls, registered ? typeId : 0, ctx, mapper);
+            desc = new OptimizedClassDescriptor(cls, registered ? typeId : 0, clsMap, ctx,
mapper);
 
             if (registered) {
-                OptimizedClassDescriptor old = DESC_BY_CLS.putIfAbsent(cls, desc);
+                OptimizedClassDescriptor old = clsMap.putIfAbsent(cls, desc);
 
                 if (old != null)
                     desc = old;
@@ -233,6 +233,7 @@ class OptimizedMarshallerUtils {
     /**
      * Gets descriptor for provided ID.
      *
+     * @param clsMap Class descriptors by class map.
      * @param id ID.
      * @param ldr Class loader.
      * @param ctx Context.
@@ -241,15 +242,19 @@ class OptimizedMarshallerUtils {
      * @throws IOException In case of error.
      * @throws ClassNotFoundException If class was not found.
      */
-    static OptimizedClassDescriptor classDescriptor(int id, ClassLoader ldr, MarshallerContext
ctx,
+    static OptimizedClassDescriptor classDescriptor(
+        ConcurrentMap<Class, OptimizedClassDescriptor> clsMap,
+        int id,
+        ClassLoader ldr,
+        MarshallerContext ctx,
         OptimizedMarshallerIdMapper mapper) throws IOException, ClassNotFoundException {
         Class cls = ctx.getClass(id, ldr);
 
-        OptimizedClassDescriptor desc = DESC_BY_CLS.get(cls);
+        OptimizedClassDescriptor desc = clsMap.get(cls);
 
         if (desc == null) {
-            OptimizedClassDescriptor old = DESC_BY_CLS.putIfAbsent(cls, desc =
-                new OptimizedClassDescriptor(cls, resolveTypeId(cls.getName(), mapper), ctx,
mapper));
+            OptimizedClassDescriptor old = clsMap.putIfAbsent(cls, desc =
+                new OptimizedClassDescriptor(cls, resolveTypeId(cls.getName(), mapper), clsMap,
ctx, mapper));
 
             if (old != null)
                 desc = old;
@@ -259,29 +264,6 @@ class OptimizedMarshallerUtils {
     }
 
     /**
-     * Undeployment callback.
-     *
-     * @param ldr Undeployed class loader.
-     */
-    public static void onUndeploy(ClassLoader ldr) {
-        for (Class<?> cls : DESC_BY_CLS.keySet()) {
-            if (ldr.equals(cls.getClassLoader()))
-                DESC_BY_CLS.remove(cls);
-        }
-
-        U.clearClassCache(ldr);
-    }
-
-    /**
-     * Intended for test purposes only.
-     */
-    public static void clearCache() {
-        DESC_BY_CLS.clear();
-
-        U.clearClassCache();
-    }
-
-    /**
      * Computes the serial version UID value for the given class.
      * The code is taken from {@link ObjectStreamClass#computeDefaultSUID(Class)}.
      *

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
index 23af9f1..4bc648f 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectInputStream.java
@@ -29,6 +29,7 @@ import sun.misc.*;
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
+import java.util.concurrent.*;
 
 import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.*;
 
@@ -72,6 +73,9 @@ class OptimizedObjectInputStream extends ObjectInputStream {
     /** */
     private Class<?> curCls;
 
+    /** */
+    private ConcurrentMap<Class, OptimizedClassDescriptor> clsMap;
+
     /**
      * @param in Input.
      * @throws IOException In case of error.
@@ -81,11 +85,18 @@ class OptimizedObjectInputStream extends ObjectInputStream {
     }
 
     /**
+     * @param clsMap Class descriptors by class map.
      * @param ctx Context.
      * @param mapper ID mapper.
      * @param clsLdr Class loader.
      */
-    void context(MarshallerContext ctx, OptimizedMarshallerIdMapper mapper, ClassLoader clsLdr)
{
+    void context(
+        ConcurrentMap<Class, OptimizedClassDescriptor> clsMap,
+        MarshallerContext ctx,
+        OptimizedMarshallerIdMapper mapper,
+        ClassLoader clsLdr)
+    {
+        this.clsMap = clsMap;
         this.ctx = ctx;
         this.mapper = mapper;
         this.clsLdr = clsLdr;
@@ -244,8 +255,8 @@ class OptimizedObjectInputStream extends ObjectInputStream {
                 int typeId = readInt();
 
                 OptimizedClassDescriptor desc = typeId == 0 ?
-                    classDescriptor(U.forName(readUTF(), clsLdr), ctx, mapper):
-                    classDescriptor(typeId, clsLdr, ctx, mapper);
+                    classDescriptor(clsMap, U.forName(readUTF(), clsLdr), ctx, mapper):
+                    classDescriptor(clsMap, typeId, clsLdr, ctx, mapper);
 
                 curCls = desc.describedClass();
 
@@ -275,7 +286,7 @@ class OptimizedObjectInputStream extends ObjectInputStream {
         int compTypeId = readInt();
 
         return compTypeId == 0 ? U.forName(readUTF(), clsLdr) :
-            classDescriptor(compTypeId, clsLdr, ctx, mapper).describedClass();
+            classDescriptor(clsMap, compTypeId, clsLdr, ctx, mapper).describedClass();
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
index 59f1547..06c2554 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/optimized/OptimizedObjectOutputStream.java
@@ -27,6 +27,7 @@ import org.apache.ignite.marshaller.*;
 import java.io.*;
 import java.lang.reflect.*;
 import java.util.*;
+import java.util.concurrent.*;
 
 import static org.apache.ignite.marshaller.optimized.OptimizedMarshallerUtils.*;
 
@@ -68,6 +69,9 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
     /** */
     private PutFieldImpl curPut;
 
+    /** */
+    private ConcurrentMap<Class, OptimizedClassDescriptor> clsMap;
+
     /**
      * @param out Output.
      * @throws IOException In case of error.
@@ -77,11 +81,16 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
     }
 
     /**
+     * @param clsMap Class descriptors by class map.
      * @param ctx Context.
      * @param mapper ID mapper.
      * @param requireSer Require {@link Serializable} flag.
      */
-    void context(MarshallerContext ctx, OptimizedMarshallerIdMapper mapper, boolean requireSer)
{
+    void context(ConcurrentMap<Class, OptimizedClassDescriptor> clsMap,
+        MarshallerContext ctx,
+        OptimizedMarshallerIdMapper mapper,
+        boolean requireSer) {
+        this.clsMap = clsMap;
         this.ctx = ctx;
         this.mapper = mapper;
         this.requireSer = requireSer;
@@ -170,7 +179,10 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
             }
             else {
                 OptimizedClassDescriptor desc = classDescriptor(
-                    obj instanceof Object[] ? Object[].class : obj.getClass(), ctx, mapper);
+                    clsMap,
+                    obj instanceof Object[] ? Object[].class : obj.getClass(),
+                    ctx,
+                    mapper);
 
                 if (desc.excluded()) {
                     writeByte(NULL);
@@ -194,7 +206,10 @@ class OptimizedObjectOutputStream extends ObjectOutputStream {
                 if (obj0 != obj) {
                     obj = obj0;
 
-                    desc = classDescriptor(obj instanceof Object[] ? Object[].class : obj.getClass(),
ctx, mapper);
+                    desc = classDescriptor(clsMap,
+                        obj instanceof Object[] ? Object[].class : obj.getClass(),
+                        ctx,
+                        mapper);
                 }
 
                 if (handle >= 0) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/test/java/org/apache/ignite/internal/processors/service/DummyService.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/DummyService.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/DummyService.java
index a633bb5..bf7e681 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/service/DummyService.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/service/DummyService.java
@@ -104,6 +104,7 @@ public class DummyService implements Service {
     }
 
     /**
+     * @param name Service name.
      * @return Cancelled flag.
      */
     public static int cancelled(String name) {
@@ -113,6 +114,7 @@ public class DummyService implements Service {
     }
 
     /**
+     * @param name Service name.
      * @return Started counter.
      */
     public static int started(String name) {
@@ -133,6 +135,7 @@ public class DummyService implements Service {
     }
 
     /**
+     * @param name Service name.
      * @param latch Count down latch.
      */
     public static void exeLatch(String name, CountDownLatch latch) {
@@ -140,6 +143,7 @@ public class DummyService implements Service {
     }
 
     /**
+     * @param name Service name.
      * @param latch Cancel latch.
      */
     public static void cancelLatch(String name, CountDownLatch latch) {

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerTest.java
b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerTest.java
index 59d9a4d..135c5c2 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerTest.java
@@ -41,7 +41,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @return Marshaller.
      */
     private OptimizedMarshaller marshaller() {
-        OptimizedMarshallerUtils.clearCache();
+        U.clearClassCache();
 
         OptimizedMarshaller marsh = new OptimizedMarshaller();
 
@@ -283,7 +283,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
             ignite.compute().execute(taskClsName, 2);
 
             ConcurrentMap<Class<?>, OptimizedClassDescriptor> cache =
-                U.staticField(OptimizedMarshallerUtils.class, "DESC_BY_CLS");
+                U.field(ignite.configuration().getMarshaller(), "clsMap");
 
             assertTrue(cache.containsKey(jobCls));
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamSelfTest.java
index 5f63730..17868f2 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedObjectStreamSelfTest.java
@@ -25,6 +25,7 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.marshaller.*;
 import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
+import org.jdk8.backport.*;
 import org.jetbrains.annotations.*;
 
 import java.io.*;
@@ -43,6 +44,9 @@ public class OptimizedObjectStreamSelfTest extends GridCommonAbstractTest
{
     /** */
     private static final MarshallerContext CTX = new MarshallerContextTestImpl();
 
+    /** */
+    private ConcurrentMap<Class, OptimizedClassDescriptor> clsMap = new ConcurrentHashMap8<>();
+
     /**
      * @throws Exception If failed.
      */
@@ -1022,7 +1026,7 @@ public class OptimizedObjectStreamSelfTest extends GridCommonAbstractTest
{
         try {
             out = OptimizedObjectStreamRegistry.out();
 
-            out.context(CTX, null, true);
+            out.context(clsMap, CTX, null, true);
 
             out.writeObject(obj);
 
@@ -1030,7 +1034,7 @@ public class OptimizedObjectStreamSelfTest extends GridCommonAbstractTest
{
 
             in = OptimizedObjectStreamRegistry.in();
 
-            in.context(CTX, null, getClass().getClassLoader());
+            in.context(clsMap, CTX, null, getClass().getClassLoader());
 
             in.in().bytes(arr, arr.length);
 

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/385d9c8e/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
index f0cec80..f114b6b 100644
--- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java
@@ -1180,7 +1180,7 @@ public abstract class GridAbstractTest extends TestCase {
 
                 // Remove resources cached in static, if any.
                 GridClassLoaderCache.clear();
-                OptimizedMarshaller.clearCache();
+                U.clearClassCache();
                 MarshallerExclusions.clearCache();
                 GridEnumCache.clear();
             }


Mime
View raw message