ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vkuliche...@apache.org
Subject incubator-ignite git commit: IGNITE-141 - Marshallers refactoring
Date Wed, 04 Mar 2015 23:30:45 GMT
Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-141 713d43e44 -> 03ca217c6


IGNITE-141 - Marshallers refactoring


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

Branch: refs/heads/ignite-141
Commit: 03ca217c663acb0b0a0f8ce541bc81e7509e005f
Parents: 713d43e
Author: Valentin Kulichenko <vkulichenko@gridgain.com>
Authored: Wed Mar 4 15:31:36 2015 -0800
Committer: Valentin Kulichenko <vkulichenko@gridgain.com>
Committed: Wed Mar 4 15:31:36 2015 -0800

----------------------------------------------------------------------
 .../IgniteExternalizableAbstractTest.java       |  9 ++++-
 .../util/future/GridFinishedFutureSelfTest.java |  6 +++
 .../marshaller/MarshallerContextTestImpl.java   |  5 +--
 .../OptimizedMarshallerEnumSelfTest.java        |  4 +-
 .../optimized/OptimizedMarshallerTest.java      | 39 +++++++++++++-------
 5 files changed, 45 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03ca217c/modules/core/src/test/java/org/apache/ignite/IgniteExternalizableAbstractTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/IgniteExternalizableAbstractTest.java
b/modules/core/src/test/java/org/apache/ignite/IgniteExternalizableAbstractTest.java
index 9ef7e98..7078dde 100644
--- a/modules/core/src/test/java/org/apache/ignite/IgniteExternalizableAbstractTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/IgniteExternalizableAbstractTest.java
@@ -28,14 +28,21 @@ import java.util.*;
  * Base externalizable test class.
  */
 public class IgniteExternalizableAbstractTest extends GridCommonAbstractTest {
+    /** */
+    private static final MarshallerContext CTX = new MarshallerContextTestImpl();
+
     /**
      * @return Marshallers.
      */
     protected List<Marshaller> getMarshallers() {
         List<Marshaller> marshallers = new ArrayList<>();
 
+        OptimizedMarshaller opt = new OptimizedMarshaller();
+
+        opt.setContext(CTX);
+
         marshallers.add(new JdkMarshaller());
-        marshallers.add(new OptimizedMarshaller());
+        marshallers.add(opt);
 
         return marshallers;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03ca217c/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFinishedFutureSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFinishedFutureSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFinishedFutureSelfTest.java
index 976f72d..a99f8ed 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFinishedFutureSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/util/future/GridFinishedFutureSelfTest.java
@@ -34,6 +34,9 @@ import static java.util.concurrent.TimeUnit.*;
  * Tests finished future use cases.
  */
 public class GridFinishedFutureSelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final MarshallerContext CTX = new MarshallerContextTestImpl();
+
     /** Create test and start grid. */
     public GridFinishedFutureSelfTest() {
         super(true);
@@ -66,6 +69,9 @@ public class GridFinishedFutureSelfTest extends GridCommonAbstractTest {
         GridKernalContext ctx = ((IgniteKernal)grid()).context();
 
         Marshaller m = new OptimizedMarshaller();
+
+        m.setContext(CTX);
+
         ClassLoader clsLdr = getClass().getClassLoader();
 
         IgniteInternalFuture<Object> orig = t == null ? new GridFinishedFuture<>(ctx,
ex) :

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03ca217c/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
index 2538f74..4d7b201 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/MarshallerContextTestImpl.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.marshaller;
 
-import org.apache.ignite.internal.util.typedef.internal.*;
 import org.jdk8.backport.*;
 
 import java.io.*;
@@ -48,11 +47,11 @@ public class MarshallerContextTestImpl implements MarshallerContext {
                     continue;
 
                 try {
-                    Class cls = U.forName(line.trim(), ldr);
+                    Class cls = Class.forName(line.trim(), false, ldr);
 
                     map.put(cls.getName().hashCode(), cls);
                 }
-                catch (ClassNotFoundException ignored) {
+                catch (ClassNotFoundException | NoClassDefFoundError ignored) {
                     // No-op.
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03ca217c/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java
index 970dd2f..81865c3 100644
--- a/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/marshaller/optimized/OptimizedMarshallerEnumSelfTest.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.marshaller.optimized;
 
 import junit.framework.*;
+import org.apache.ignite.marshaller.*;
 
 /**
  *
@@ -29,6 +30,8 @@ public class OptimizedMarshallerEnumSelfTest extends TestCase {
     public void testEnumSerialisation() throws Exception {
         OptimizedMarshaller marsh = new OptimizedMarshaller();
 
+        marsh.setContext(new MarshallerContextTestImpl());
+
         byte[] bytes = marsh.marshal(TestEnum.Bond);
 
         TestEnum unmarshalled = marsh.unmarshal(bytes, Thread.currentThread().getContextClassLoader());
@@ -58,5 +61,4 @@ public class OptimizedMarshallerEnumSelfTest extends TestCase {
 
         public abstract String getTestString();
     }
-
 }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/03ca217c/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 bf2b734..59d9a4d 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
@@ -38,12 +38,25 @@ import java.util.concurrent.*;
  */
 public class OptimizedMarshallerTest extends GridCommonAbstractTest {
     /**
+     * @return Marshaller.
+     */
+    private OptimizedMarshaller marshaller() {
+        OptimizedMarshallerUtils.clearCache();
+
+        OptimizedMarshaller marsh = new OptimizedMarshaller();
+
+        marsh.setContext(new MarshallerContextTestImpl());
+
+        return marsh;
+    }
+
+    /**
      * Tests ability to marshal non-serializable objects.
      *
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testNonSerializable() throws IgniteCheckedException {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(false);
 
@@ -58,7 +71,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testNonSerializable1() throws IgniteCheckedException {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(false);
 
@@ -79,7 +92,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testNonSerializable2() throws IgniteCheckedException {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(false);
 
@@ -112,7 +125,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testNonSerializable3() throws IgniteCheckedException {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(false);
 
@@ -129,7 +142,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testNonSerializable4() throws IgniteCheckedException {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(false);
 
@@ -148,7 +161,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testNonSerializable5() throws IgniteCheckedException {
-        Marshaller marsh = new OptimizedMarshaller();
+        Marshaller marsh = marshaller();
 
         byte[] bytes = marsh.marshal(true);
 
@@ -163,7 +176,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testSerializable() throws IgniteCheckedException {
-        Marshaller marsh = new OptimizedMarshaller();
+        Marshaller marsh = marshaller();
 
         SomeSerializable outObj = marsh.unmarshal(marsh.marshal(new SomeSerializable(null)),
null);
 
@@ -174,7 +187,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If failed.
      */
     public void testSerializableAfterChangingValue() throws IgniteCheckedException {
-        Marshaller marsh = new OptimizedMarshaller();
+        Marshaller marsh = marshaller();
 
         SomeSimpleSerializable newObj = new SomeSimpleSerializable();
 
@@ -195,7 +208,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testExternalizable() throws IgniteCheckedException {
-        Marshaller marsh = new OptimizedMarshaller();
+        Marshaller marsh = marshaller();
 
         ExternalizableA outObj = marsh.unmarshal(marsh.marshal(new ExternalizableA(null,
true)), null);
         ExternalizableA outObj1 = marsh.unmarshal(marsh.marshal(new ExternalizableA(null,
false)), null);
@@ -208,7 +221,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * Tests {@link OptimizedMarshaller#setRequireSerializable(boolean)}.
      */
     public void testRequireSerializable() {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(true);
 
@@ -228,7 +241,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws IgniteCheckedException If marshalling failed.
      */
     public void testProxy() throws IgniteCheckedException {
-        OptimizedMarshaller marsh = new OptimizedMarshaller();
+        OptimizedMarshaller marsh = marshaller();
 
         marsh.setRequireSerializable(false);
 
@@ -270,7 +283,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
             ignite.compute().execute(taskClsName, 2);
 
             ConcurrentMap<Class<?>, OptimizedClassDescriptor> cache =
-                U.staticField(OptimizedMarshallerUtils.class, "CLS_DESC_CACHE");
+                U.staticField(OptimizedMarshallerUtils.class, "DESC_BY_CLS");
 
             assertTrue(cache.containsKey(jobCls));
 
@@ -301,7 +314,7 @@ public class OptimizedMarshallerTest extends GridCommonAbstractTest {
      * @throws Exception If failed.
      */
     private void checkPerformance(int cnt, int tries) throws Exception {
-        Marshaller marsh = new OptimizedMarshaller();
+        Marshaller marsh = marshaller();
 
         for (int j = 0; j < tries; j++) {
             System.gc();


Mime
View raw message