ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [46/50] [abbrv] ignite git commit: Cleanup (2).
Date Wed, 24 Aug 2016 14:05:09 GMT
Cleanup (2).


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

Branch: refs/heads/ignite-2649
Commit: 61f8b708e6b20513bb0f05e5d6b20eab6a8a0437
Parents: c451d87
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Aug 24 16:32:38 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Aug 24 16:32:38 2016 +0300

----------------------------------------------------------------------
 .../ignite/marshaller/MarshallerUtils.java      | 27 ++++++++------------
 .../ignite/spi/discovery/tcp/ClientImpl.java    |  6 ++---
 .../ignite/spi/discovery/tcp/ServerImpl.java    |  3 +--
 .../spi/discovery/tcp/TcpDiscoveryImpl.java     | 13 ++++++++++
 .../spi/discovery/tcp/TcpDiscoverySpi.java      |  4 +--
 5 files changed, 29 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/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 a73e8a5..c302351 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
@@ -100,22 +100,17 @@ public class MarshallerUtils {
 
 
 
-
-
-
-
-
     /**
-     * Unmarshal object from stream and set grid name thread local.
+     * Unmarshal object and set grid name thread local.
      *
-     * @param name Grid name.
      * @param marsh Marshaller.
-     * @param in Input stream.
+     * @param arr Binary data.
      * @param ldr Class loader.
+     * @param name Grid name.
      * @return Deserialized object.
      * @throws IgniteCheckedException If failed.
      */
-    public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable
ClassLoader ldr)
+    public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader
ldr, String name)
         throws IgniteCheckedException {
         LocalGridName gridNameTl = gridName();
 
@@ -125,7 +120,7 @@ public class MarshallerUtils {
         try {
             gridNameTl.setGridName(true, name);
 
-            return marsh.unmarshal(in, ldr);
+            return marsh.unmarshal(arr, ldr);
         }
         finally {
             gridNameTl.setGridName(init, gridNameStr);
@@ -133,17 +128,17 @@ public class MarshallerUtils {
     }
 
     /**
-     * Unmarshal object and set grid name thread local.
+     * Unmarshal object from stream and set grid name thread local.
      *
+     * @param name Grid name.
      * @param marsh Marshaller.
-     * @param arr Binary data.
+     * @param in Input stream.
      * @param ldr Class loader.
-     * @param name Grid name.
      * @return Deserialized object.
      * @throws IgniteCheckedException If failed.
      */
-    public static <T> T unmarshal(Marshaller marsh, byte[] arr, @Nullable ClassLoader
ldr,
-        String name) throws IgniteCheckedException {
+    public static <T> T unmarshal(String name, Marshaller marsh, InputStream in, @Nullable
ClassLoader ldr)
+        throws IgniteCheckedException {
         LocalGridName gridNameTl = gridName();
 
         String gridNameStr = gridNameTl.getGridName();
@@ -152,7 +147,7 @@ public class MarshallerUtils {
         try {
             gridNameTl.setGridName(true, name);
 
-            return marsh.unmarshal(arr, ldr);
+            return marsh.unmarshal(in, ldr);
         }
         finally {
             gridNameTl.setGridName(init, gridNameStr);

http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
index 60d4131..78a1911 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ClientImpl.java
@@ -887,8 +887,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                         TcpDiscoveryAbstractMessage msg;
 
                         try {
-                            msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(),
spi.marsh, in,
-                                U.resolveClassLoader(spi.ignite().configuration()));
+                            msg = unmarshal(in);
                         }
                         catch (IgniteCheckedException e) {
                             if (log.isDebugEnabled())
@@ -1213,8 +1212,7 @@ class ClientImpl extends TcpDiscoveryImpl {
                         List<TcpDiscoveryAbstractMessage> msgs = null;
 
                         while (!isInterrupted()) {
-                            TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(),
spi.marsh, in,
-                                U.resolveClassLoader(spi.ignite().configuration()));
+                            TcpDiscoveryAbstractMessage msg = unmarshal(in);
 
                             if (msg instanceof TcpDiscoveryClientReconnectMessage) {
                                 TcpDiscoveryClientReconnectMessage res = (TcpDiscoveryClientReconnectMessage)msg;

http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/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 00657db..61bdc2f 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
@@ -5437,8 +5437,7 @@ class ServerImpl extends TcpDiscoveryImpl {
 
                 while (!isInterrupted()) {
                     try {
-                        TcpDiscoveryAbstractMessage msg = MarshallerUtils.unmarshal(spi.ignite().configuration().getGridName(),
spi.marsh, in,
-                            U.resolveClassLoader(spi.ignite().configuration()));
+                        TcpDiscoveryAbstractMessage msg = unmarshal(in);
 
                         msg.senderNodeId(nodeId);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/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 7eb915e..d049314 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
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.spi.discovery.tcp;
 
+import java.io.InputStream;
 import java.net.InetSocketAddress;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
@@ -340,4 +341,16 @@ abstract class TcpDiscoveryImpl {
     protected byte[] marshal(Object obj) throws IgniteCheckedException {
         return MarshallerUtils.marshal(spi.ignite().name(), spi.marsh, obj);
     }
+
+    /**
+     * 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()));
+    }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/61f8b708/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 368480f..39dc9dc 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,8 @@ 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()));
+            return MarshallerUtils.unmarshal(ignite.configuration().getGridName(), marsh,
+                in == null ? sock.getInputStream() : in, U.resolveClassLoader(ignite.configuration()));
         }
         catch (IOException | IgniteCheckedException e) {
             if (X.hasCause(e, SocketTimeoutException.class))


Mime
View raw message