You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/07/04 10:02:12 UTC
[06/50] ignite git commit: New method to register marshaller mappings
locally without triggering discovery messages exchange
New method to register marshaller mappings locally without triggering discovery messages exchange
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b6214314
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b6214314
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b6214314
Branch: refs/heads/master
Commit: b621431416a692af8ff3172331ee665efacf9ff5
Parents: 4debe5b
Author: Sergey Chugunov <se...@gmail.com>
Authored: Fri Jun 23 15:36:24 2017 +0300
Committer: Sergey Chugunov <se...@gmail.com>
Committed: Fri Jun 23 15:36:24 2017 +0300
----------------------------------------------------------------------
.../ignite/internal/MarshallerContextImpl.java | 11 ++++++++
.../ignite/marshaller/MarshallerContext.java | 27 +++++++++++++++++---
...GridBinaryMarshallerCtxDisabledSelfTest.java | 5 ++++
.../cache/GridCacheEntryMemorySizeSelfTest.java | 4 +++
4 files changed, 43 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/b6214314/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 265481e..cad06c3 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
@@ -265,6 +265,17 @@ public class MarshallerContextImpl implements MarshallerContext {
}
}
+ /** {@inheritDoc} */
+ @Override public boolean registerClassNameLocally(byte platformId, int typeId, String clsName)
+ throws IgniteCheckedException
+ {
+ ConcurrentMap<Integer, MappedName> cache = getCacheFor(platformId);
+
+ cache.put(typeId, new MappedName(clsName, true));
+
+ return true;
+ }
+
/**
* @param res result of exchange.
*/
http://git-wip-us.apache.org/repos/asf/ignite/blob/b6214314/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 6898c36..8d6cd77 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
@@ -24,17 +24,36 @@ import org.apache.ignite.IgniteCheckedException;
*/
public interface MarshallerContext {
/**
- * Registers class with provided type ID.
+ * Method to register typeId->class name mapping in marshaller context <b>cluster-wide</b>.
*
+ * This method <b>guarantees</b> that mapping is delivered to all nodes in cluster
+ * and blocks caller thread until then.
+ *
+ * @param platformId Id of a platform (java, .NET, etc.) to register mapping for.
* @param typeId Type ID.
- * @param platformId id of a platform to register class.
- * @param clsName class name.
- * @return Whether class was registered.
+ * @param clsName Class name.
+ * @return {@code True} if mapping was registered successfully.
* @throws IgniteCheckedException In case of error.
*/
public boolean registerClassName(byte platformId, int typeId, String clsName) throws IgniteCheckedException;
/**
+ * Method to register typeId->class name mapping in marshaller context <b>on local node only</b>.
+ *
+ * <b>No guarantees</b> that the mapping is presented on other nodes are provided.
+ *
+ * This method is safe to use if there is another source of mappings like metadata persisted on disk
+ * and this source is known to be solid and free of conflicts beforehand.
+ *
+ * @param platformId Id of a platform (java, .NET, etc.) to register mapping for.
+ * @param typeId Type id.
+ * @param clsName Class name.
+ * @return {@code True} if class mapping was registered successfully.
+ * @throws IgniteCheckedException In case of error.
+ */
+ public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) throws IgniteCheckedException;
+
+ /**
* Gets class for provided type ID.
*
* @param typeId Type ID.
http://git-wip-us.apache.org/repos/asf/ignite/blob/b6214314/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java
index 5ee2423..35aa9b9 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryMarshallerCtxDisabledSelfTest.java
@@ -98,6 +98,11 @@ public class GridBinaryMarshallerCtxDisabledSelfTest extends GridCommonAbstractT
}
/** {@inheritDoc} */
+ @Override public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) {
+ return false;
+ }
+
+ /** {@inheritDoc} */
@Override public Class getClass(
int typeId,
ClassLoader ldr
http://git-wip-us.apache.org/repos/asf/ignite/blob/b6214314/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
index 6939258..f18afb2 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheEntryMemorySizeSelfTest.java
@@ -151,6 +151,10 @@ public class GridCacheEntryMemorySizeSelfTest extends GridCommonAbstractTest {
return true;
}
+ @Override public boolean registerClassNameLocally(byte platformId, int typeId, String clsName) {
+ return true;
+ }
+
@Override public Class getClass(int typeId, ClassLoader ldr) {
throw new UnsupportedOperationException();
}