ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [15/50] [abbrv] ignite git commit: IGNITE-6073 Handy API to add binary metadata locally
Date Mon, 21 Aug 2017 08:40:24 GMT
IGNITE-6073 Handy API to add binary metadata locally


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

Branch: refs/heads/ignite-5578
Commit: bfb4c21de992af5f8975d0f3d8f97cf4d5c93bed
Parents: df2fb8c
Author: Sergey Chugunov <sergey.chugunov@gmail.com>
Authored: Wed Aug 16 17:12:27 2017 +0300
Committer: Alexey Goncharuk <alexey.goncharuk@gmail.com>
Committed: Wed Aug 16 17:12:27 2017 +0300

----------------------------------------------------------------------
 .../binary/CacheObjectBinaryProcessor.java      | 20 ++++++++++++++++----
 .../binary/CacheObjectBinaryProcessorImpl.java  | 17 ++++++++++++++++-
 2 files changed, 32 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb4c21d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
index 4d285ab..14dd5cb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessor.java
@@ -19,13 +19,13 @@ package org.apache.ignite.internal.processors.cache.binary;
 
 import java.util.Collection;
 import java.util.Map;
-import org.apache.ignite.IgniteException;
 import org.apache.ignite.IgniteBinary;
-import org.apache.ignite.internal.binary.BinaryFieldMetadata;
-import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.binary.BinaryObject;
 import org.apache.ignite.binary.BinaryObjectBuilder;
 import org.apache.ignite.binary.BinaryType;
-import org.apache.ignite.binary.BinaryObject;
+import org.apache.ignite.internal.binary.BinaryFieldMetadata;
+import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor;
 import org.jetbrains.annotations.Nullable;
 
 /**
@@ -54,6 +54,18 @@ public interface CacheObjectBinaryProcessor extends IgniteCacheObjectProcessor
{
     public void addMeta(int typeId, final BinaryType newMeta) throws IgniteException;
 
     /**
+     * Adds metadata locally without triggering discovery exchange.
+     *
+     * Must be used only during startup and only if it is guaranteed that all nodes have
the same copy
+     * of BinaryType.
+     *
+     * @param typeId Type ID.
+     * @param newMeta New meta data.
+     * @throws IgniteException In case of error.
+     */
+    public void addMetaLocally(int typeId, final BinaryType newMeta) throws IgniteException;
+
+    /**
      * @param typeId Type ID.
      * @param typeName Type name.
      * @param affKeyFieldName Affinity key field name.

http://git-wip-us.apache.org/repos/asf/ignite/blob/bfb4c21d/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
index 6a1b6dc..16d9fd0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/binary/CacheObjectBinaryProcessorImpl.java
@@ -18,7 +18,6 @@
 package org.apache.ignite.internal.processors.cache.binary;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
@@ -443,6 +442,22 @@ public class CacheObjectBinaryProcessorImpl extends IgniteCacheObjectProcessorIm
     }
 
     /** {@inheritDoc} */
+    @Override public void addMetaLocally(int typeId, BinaryType newMeta) throws BinaryObjectException
{
+        assert newMeta != null;
+        assert newMeta instanceof BinaryTypeImpl;
+
+        BinaryMetadata newMeta0 = ((BinaryTypeImpl)newMeta).metadata();
+
+        BinaryMetadataHolder metaHolder = metadataLocCache.get(typeId);
+
+        BinaryMetadata oldMeta = metaHolder != null ? metaHolder.metadata() : null;
+
+        BinaryMetadata mergedMeta = BinaryUtils.mergeMetadata(oldMeta, newMeta0);
+
+        metadataLocCache.put(typeId, new BinaryMetadataHolder(mergedMeta, 0, 0));
+    }
+
+    /** {@inheritDoc} */
     @Nullable @Override public BinaryType metadata(final int typeId) {
         BinaryMetadata meta = metadata0(typeId);
 


Mime
View raw message