ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [1/2] ignite git commit: IGNITE-1816: WIP.
Date Thu, 12 Nov 2015 14:39:55 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-1816 58f5737c6 -> 93f12f766


IGNITE-1816: WIP.


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

Branch: refs/heads/ignite-1816
Commit: ab427d300daaddeb26f2119920ced1394b7d6848
Parents: 58f5737
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Thu Nov 12 17:02:47 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Thu Nov 12 17:02:47 2015 +0300

----------------------------------------------------------------------
 .../portable/BinaryCachingMetadataHandler.java  | 70 ++++++++++++++++++++
 .../portable/BinaryFieldsAbstractSelfTest.java  |  2 +-
 ...idPortableMarshallerCtxDisabledSelfTest.java |  2 +-
 .../GridPortableMarshallerSelfTest.java         | 49 +++++++-------
 .../PortableCompactOffsetsAbstractSelfTest.java |  2 +-
 .../portable/TestCachingMetadataHandler.java    | 54 ---------------
 6 files changed, 98 insertions(+), 81 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/ab427d30/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
new file mode 100644
index 0000000..a3c846b
--- /dev/null
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryCachingMetadataHandler.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.portable;
+
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryType;
+
+import java.util.HashMap;
+
+/**
+ * Simple caching metadata handler. Used mainly in tests.
+ */
+public class BinaryCachingMetadataHandler implements BinaryMetadataHandler {
+    /** Cached metadatas. */
+    private final HashMap<Integer, BinaryType> metas = new HashMap<>();
+
+    /**
+     * Create new handler instance.
+     *
+     * @return New handler.
+     */
+    public static BinaryCachingMetadataHandler create() {
+        return new BinaryCachingMetadataHandler();
+    }
+
+    /**
+     * Private constructor.
+     */
+    private BinaryCachingMetadataHandler() {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override public synchronized void addMeta(int typeId, BinaryType type) throws BinaryObjectException
{
+        synchronized (this) {
+            BinaryType oldType = metas.put(typeId, type);
+
+            if (oldType != null) {
+                BinaryMetadata oldMeta = ((BinaryTypeImpl)oldType).metadata();
+                BinaryMetadata newMeta = ((BinaryTypeImpl)type).metadata();
+
+                BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta);
+
+                BinaryType mergedType = mergedMeta.wrap(((BinaryTypeImpl)oldType).context());
+
+                metas.put(typeId, mergedType);
+            }
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public synchronized BinaryType metadata(int typeId) throws BinaryObjectException
{
+        return metas.get(typeId);
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/ab427d30/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
index 14fc6f3..101b3bc 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/BinaryFieldsAbstractSelfTest.java
@@ -47,7 +47,7 @@ public abstract class BinaryFieldsAbstractSelfTest extends GridCommonAbstractTes
      * @throws Exception If failed.
      */
     protected static PortableMarshaller createMarshaller() throws Exception {
-        PortableContext ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
+        PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(),
new IgniteConfiguration());
 
         PortableMarshaller marsh = new PortableMarshaller();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ab427d30/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
index e61e78f..9c0824e 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerCtxDisabledSelfTest.java
@@ -45,7 +45,7 @@ public class GridPortableMarshallerCtxDisabledSelfTest extends GridCommonAbstrac
         PortableMarshaller marsh = new PortableMarshaller();
         marsh.setContext(new MarshallerContextWithNoStorage());
 
-        PortableContext context = new PortableContext(new TestCachingMetadataHandler(), new
IgniteConfiguration());
+        PortableContext context = new PortableContext(BinaryCachingMetadataHandler.create(),
new IgniteConfiguration());
 
         IgniteUtils.invoke(PortableMarshaller.class, marsh, "setPortableContext", context);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ab427d30/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
index acc90f9..d6cd671 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/GridPortableMarshallerSelfTest.java
@@ -17,30 +17,9 @@
 
 package org.apache.ignite.internal.portable;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.InetSocketAddress;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.TreeSet;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentSkipListSet;
 import junit.framework.Assert;
 import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryObjectException;
@@ -49,7 +28,6 @@ import org.apache.ignite.binary.BinaryRawWriter;
 import org.apache.ignite.binary.BinaryReader;
 import org.apache.ignite.binary.BinarySerializer;
 import org.apache.ignite.binary.BinaryTypeConfiguration;
-import org.apache.ignite.binary.BinaryIdMapper;
 import org.apache.ignite.binary.BinaryWriter;
 import org.apache.ignite.binary.Binarylizable;
 import org.apache.ignite.configuration.IgniteConfiguration;
@@ -67,6 +45,29 @@ import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
 import org.jsr166.ConcurrentHashMap8;
 import sun.misc.Unsafe;
 
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.InetSocketAddress;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.TreeSet;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListSet;
+
 import static org.apache.ignite.internal.portable.PortableThreadLocalMemoryAllocator.THREAD_LOCAL_ALLOC;
 import static org.junit.Assert.assertArrayEquals;
 
@@ -2430,7 +2431,7 @@ public class GridPortableMarshallerSelfTest extends GridCommonAbstractTest
{
     private PortableContext initializePortableContext(PortableMarshaller marsh) throws IgniteCheckedException
{
         IgniteConfiguration iCfg = new IgniteConfiguration();
 
-        PortableContext ctx = new PortableContext(new TestCachingMetadataHandler(), iCfg);
+        PortableContext ctx = new PortableContext(BinaryCachingMetadataHandler.create(),
iCfg);
 
         marsh.setContext(new MarshallerContextTestImpl(null));
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ab427d30/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
index 9225b97..10633ae 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/portable/PortableCompactOffsetsAbstractSelfTest.java
@@ -47,7 +47,7 @@ public abstract class PortableCompactOffsetsAbstractSelfTest extends GridCommonA
     @Override protected void beforeTest() throws Exception {
         super.beforeTest();
 
-        ctx = new PortableContext(new TestCachingMetadataHandler(), new IgniteConfiguration());
+        ctx = new PortableContext(BinaryCachingMetadataHandler.create(), new IgniteConfiguration());
 
         marsh = new PortableMarshaller();
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/ab427d30/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
b/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
deleted file mode 100644
index f863317..0000000
--- a/modules/core/src/test/java/org/apache/ignite/internal/portable/TestCachingMetadataHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.portable;
-
-import org.apache.ignite.binary.BinaryObjectException;
-import org.apache.ignite.binary.BinaryType;
-
-import java.util.HashMap;
-
-/**
- * Test metadata handler.
- */
-public class TestCachingMetadataHandler implements BinaryMetadataHandler {
-    /** Cached metadatas. */
-    private final HashMap<Integer, BinaryType> metas = new HashMap<>();
-
-    /** {@inheritDoc} */
-    @Override public synchronized void addMeta(int typeId, BinaryType type) throws BinaryObjectException
{
-        synchronized (this) {
-            BinaryType oldType = metas.put(typeId, type);
-
-            if (oldType != null) {
-                BinaryMetadata oldMeta = ((BinaryTypeImpl)oldType).metadata();
-                BinaryMetadata newMeta = ((BinaryTypeImpl)type).metadata();
-
-                BinaryMetadata mergedMeta = PortableUtils.mergeMetadata(oldMeta, newMeta);
-
-                BinaryType mergedType = mergedMeta.wrap(((BinaryTypeImpl)oldType).context());
-
-                metas.put(typeId, mergedType);
-            }
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public synchronized BinaryType metadata(int typeId) throws BinaryObjectException
{
-        return metas.get(typeId);
-    }
-}


Mime
View raw message