ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [39/50] [abbrv] ignite git commit: WIP
Date Wed, 07 Sep 2016 11:17:24 GMT
WIP


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

Branch: refs/heads/ignite-2649
Commit: a2c73d09561758bac93196784cef1ed30caafd34
Parents: bed68ed
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Sep 7 13:21:00 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Sep 7 13:21:00 2016 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    |  7 ++-
 .../ignite/marshaller/MarshallerUtils.java      | 58 --------------------
 .../ignite/spi/discovery/tcp/ServerImpl.java    | 10 +---
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     | 16 +++++-
 .../spi/discovery/tcp/TcpDiscoverySpi.java      | 10 ++--
 5 files changed, 27 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/a2c73d09/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 3cc33b4..927545e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -206,6 +206,8 @@ public class GridCacheProcessor extends GridProcessorAdapter {
         caches = new ConcurrentHashMap<>();
         jCacheProxies = new ConcurrentHashMap<>();
         stopSeq = new LinkedList<>();
+
+        MarshallerUtils.withNodeName(marshaller, ctx.gridName());
     }
 
     /**
@@ -3397,7 +3399,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                         if (ldr == null)
                             ldr = val.getCacheStoreFactory().getClass().getClassLoader();
 
-                        MarshallerUtils.marshalUnmarshal(ctx.gridName(), marshaller, val.getCacheStoreFactory(),
+                        marshaller.unmarshal(marshaller.marshal(val.getCacheStoreFactory()),
                             U.resolveClassLoader(ldr, ctx.config()));
                     }
                     catch (IgniteCheckedException e) {
@@ -3407,8 +3409,7 @@ public class GridCacheProcessor extends GridProcessorAdapter {
                 }
 
                 try {
-                    return MarshallerUtils.marshalUnmarshal(ctx.gridName(), marshaller, val,
-                        U.resolveClassLoader(ctx.config()));
+                    return marshaller.unmarshal(marshaller.marshal(val), U.resolveClassLoader(ctx.config()));
                 }
                 catch (IgniteCheckedException e) {
                     throw new IgniteCheckedException("Failed to validate cache configuration
" +

http://git-wip-us.apache.org/repos/asf/ignite/blob/a2c73d09/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
index ef0a93a..0688fdb 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/MarshallerUtils.java
@@ -18,12 +18,10 @@
 package org.apache.ignite.marshaller;
 
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridKernalContext;
 import org.apache.ignite.internal.util.IgniteUtils;
 import org.jetbrains.annotations.Nullable;
 
 import java.io.InputStream;
-import java.io.OutputStream;
 
 /**
  * Utility marshaller methods.
@@ -44,18 +42,6 @@ public class MarshallerUtils {
     }
 
     /**
-     * Marshal object with node name taken from provided kernal context.
-     *
-     * @param ctx Kernal context.
-     * @param obj Object to marshal.
-     * @return Result.
-     * @throws IgniteCheckedException If failed.
-     */
-    public static byte[] marshal(GridKernalContext ctx, @Nullable Object obj) throws IgniteCheckedException
{
-        return ctx.config().getMarshaller().marshal(obj);
-    }
-
-    /**
      * Unmarshal object and set grid name thread local.
      *
      * @param name Grid name.
@@ -78,50 +64,6 @@ public class MarshallerUtils {
     }
 
     /**
-     * Unmarshal object from stream and set grid name thread local.
-     *
-     * @param name Grid name.
-     * @param marsh Marshaller.
-     * @param in Input stream.
-     * @param ldr Class loader.
-     * @return Deserialized object.
-     * @throws IgniteCheckedException If failed.
-     */
-    public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable
ClassLoader ldr)
-        throws IgniteCheckedException {
-        String oldName = IgniteUtils.setCurrentIgniteName(name);
-
-        try {
-            return marsh.unmarshal(in, ldr);
-        }
-        finally {
-            IgniteUtils.restoreCurrentIgniteName(oldName);
-        }
-    }
-
-    /**
-     * Marshal and unmarshal object.
-     *
-     * @param name Grid name.
-     * @param marsh Marshaller.
-     * @param obj Object to clone.
-     * @param clsLdr Class loader.
-     * @return Deserialized value.
-     * @throws IgniteCheckedException If failed.
-     */
-    public static <T> T marshalUnmarshal(String name, Marshaller marsh, T obj, @Nullable
ClassLoader clsLdr)
-        throws IgniteCheckedException {
-        String oldName = IgniteUtils.setCurrentIgniteName(name);
-
-        try {
-            return marsh.unmarshal(marsh.marshal(obj), clsLdr);
-        }
-        finally {
-            IgniteUtils.restoreCurrentIgniteName(oldName);
-        }
-    }
-
-    /**
      * Private constructor.
      */
     private MarshallerUtils() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/a2c73d09/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
index 9211722..2d58842 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ServerImpl.java
@@ -2379,8 +2379,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                         if (clientMsgWorker.clientNodeId.equals(node.id())) {
                             try {
-                                msg0 = MarshallerUtils.unmarshal(spi.ignite().name(), spi.marsh,
msgBytes,
-                                    U.resolveClassLoader(spi.ignite().configuration()));
+                                msg0 = unmarshal(msgBytes);
 
                                 prepareNodeAddedMessage(msg0, clientMsgWorker.clientNodeId,
null, null, null);
 
@@ -3789,11 +3788,8 @@ class ServerImpl extends TcpDiscoveryImpl {
                         else {
                             SecurityContext subj = spi.nodeAuth.authenticateNode(node, cred);
 
-                            final IgniteConfiguration cfg = spi.ignite().configuration();
-
-                            SecurityContext coordSubj = MarshallerUtils.unmarshal(cfg.getGridName(),
spi.marsh,
-                                node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT),
-                                U.resolveClassLoader(cfg));
+                            SecurityContext coordSubj =
+                                unmarshal(node.<byte[]>attribute(IgniteNodeAttributes.ATTR_SECURITY_SUBJECT));
 
                             if (!permissionsEqual(coordSubj.subject().permissions(), subj.subject().permissions()))
{
                                 // Node has not pass authentication.

http://git-wip-us.apache.org/repos/asf/ignite/blob/a2c73d09/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
index 9dd738e..8abcb18 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoveryImpl.java
@@ -345,12 +345,24 @@ abstract class TcpDiscoveryImpl {
     /**
      * Unmarshal object.
      *
+     * @param data Data.
+     * @return Result.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected <T> T unmarshal(byte[] data) throws IgniteCheckedException {
+        return MarshallerUtils.withNodeName(spi.marsh, spi.ignite().name())
+            .unmarshal(data, U.resolveClassLoader(spi.ignite().configuration()));
+    }
+
+    /**
+     * Unmarshal object.
+     *
      * @param in Input stream.
      * @return Result.
      * @throws IgniteCheckedException If failed.
      */
     protected <T> T unmarshal(InputStream in) throws IgniteCheckedException {
-        return MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(), spi.marsh,
in,
-            U.resolveClassLoader(spi.ignite().configuration()));
+        return MarshallerUtils.withNodeName(spi.marsh, spi.ignite().name())
+            .unmarshal(in, U.resolveClassLoader(spi.ignite().configuration()));
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/a2c73d09/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
index abfa193..1de0504 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/TcpDiscoverySpi.java
@@ -1462,8 +1462,10 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
         try {
             sock.setSoTimeout((int)timeout);
 
-            return MarshallerUtils.unmarshal(ignite.configuration().getGridName(), marsh,
-                in == null ? sock.getInputStream() : in, U.resolveClassLoader(ignite.configuration()));
+            T res = MarshallerUtils.withNodeName(marsh, ignite.name()).unmarshal(in == null
?
+                sock.getInputStream() : in, U.resolveClassLoader(ignite.configuration()));
+
+            return res;
         }
         catch (IOException | IgniteCheckedException e) {
             if (X.hasCause(e, SocketTimeoutException.class))
@@ -1708,8 +1710,8 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi,
T
 
         for (Map.Entry<Integer, byte[]> entry : data.entrySet()) {
             try {
-                Serializable compData = MarshallerUtils.unmarshal(ignite.name(), marsh, entry.getValue(),
clsLdr
-                );
+                Serializable compData =
+                    MarshallerUtils.withNodeName(marsh, ignite.name()).unmarshal(entry.getValue(),
clsLdr);
 
                 data0.put(entry.getKey(), compData);
             }


Mime
View raw message