ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [2/2] ignite git commit: Added node-aware infrastructure.
Date Tue, 06 Sep 2016 16:07:42 GMT
Added node-aware infrastructure.


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

Branch: refs/heads/ignite-1.5.31-1
Commit: 869e88319b6910d21091792a5a183d6b17c884cc
Parents: be343ca
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Tue Sep 6 19:07:24 2016 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Tue Sep 6 19:07:24 2016 +0300

----------------------------------------------------------------------
 .../internal/binary/BinaryMarshaller.java       |  8 ++++----
 .../internal/processors/igfs/IgfsPaths.java     |  4 +++-
 .../rest/protocols/tcp/GridTcpRestParser.java   |  7 ++++---
 .../AbstractNodeNameAwareMarshaller.java        |  9 ++++++++-
 .../ignite/marshaller/MarshallerUtils.java      | 21 --------------------
 .../ignite/marshaller/jdk/JdkMarshaller.java    |  8 ++++----
 .../sharedfs/SharedFsCheckpointSpi.java         |  4 ++++
 .../spi/checkpoint/sharedfs/SharedFsUtils.java  |  2 +-
 8 files changed, 28 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
index 7d63353..a1dac66 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryMarshaller.java
@@ -81,12 +81,12 @@ public class BinaryMarshaller extends AbstractNodeNameAwareMarshaller
{
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] marshal0(@Nullable Object obj) throws IgniteCheckedException
{
+    @Override protected byte[] marshal0(@Nullable Object obj) throws IgniteCheckedException
{
         return impl.marshal(obj);
     }
 
     /** {@inheritDoc} */
-    @Override public void marshal0(@Nullable Object obj, OutputStream out) throws IgniteCheckedException
{
+    @Override protected void marshal0(@Nullable Object obj, OutputStream out) throws IgniteCheckedException
{
         byte[] arr = marshal(obj);
 
         try {
@@ -98,12 +98,12 @@ public class BinaryMarshaller extends AbstractNodeNameAwareMarshaller
{
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T unmarshal0(byte[] bytes, @Nullable ClassLoader clsLdr) throws
IgniteCheckedException {
+    @Override protected <T> T unmarshal0(byte[] bytes, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
         return impl.deserialize(bytes, clsLdr);
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T unmarshal0(InputStream in, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
+    @Override protected <T> T unmarshal0(InputStream in, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
         ByteArrayOutputStream buf = new ByteArrayOutputStream();
 
         // we have to fully read the InputStream because GridBinaryMarshaller requires support
of a method that

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
index 9892bc8..13f1daf 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/igfs/IgfsPaths.java
@@ -78,7 +78,9 @@ public class IgfsPaths implements Externalizable {
         else {
             ByteArrayOutputStream out = new ByteArrayOutputStream();
 
-            MarshallerUtils.marshal(igfsCtx.kernalContext().gridName(), new JdkMarshaller(),
payload, out);
+            JdkMarshaller marsh = new JdkMarshaller().nodeName(igfsCtx.kernalContext().gridName());
+
+            marsh.marshal(payload, out);
 
             payloadBytes = out.toByteArray();
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
index 133d754..77179b7 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/rest/protocols/tcp/GridTcpRestParser.java
@@ -38,7 +38,6 @@ import org.apache.ignite.internal.util.nio.GridNioParser;
 import org.apache.ignite.internal.util.nio.GridNioSession;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.MarshallerUtils;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.jetbrains.annotations.Nullable;
@@ -70,7 +69,7 @@ public class GridTcpRestParser implements GridNioParser {
     private static final Charset UTF_8 = Charset.forName("UTF-8");
 
     /** JDK marshaller. */
-    private final Marshaller jdkMarshaller = new JdkMarshaller();
+    private final JdkMarshaller jdkMarshaller = new JdkMarshaller();
 
     /** Router client flag. */
     private final boolean routerClient;
@@ -806,7 +805,9 @@ public class GridTcpRestParser implements GridNioParser {
             flags |= BYTE_ARR_FLAG;
         }
         else {
-            MarshallerUtils.marshal(gridName, jdkMarshaller, obj, out);
+            jdkMarshaller.nodeName(gridName);
+
+            jdkMarshaller.marshal(obj, out);
 
             flags |= SERIALIZED_FLAG;
         }

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/marshaller/AbstractNodeNameAwareMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/AbstractNodeNameAwareMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/AbstractNodeNameAwareMarshaller.java
index 5f7af9b..4425dfd 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/AbstractNodeNameAwareMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/AbstractNodeNameAwareMarshaller.java
@@ -30,6 +30,9 @@ import java.io.OutputStream;
  * Marshaller allowing for {@link Ignition#localIgnite()} calls.
  */
 public abstract class AbstractNodeNameAwareMarshaller extends AbstractMarshaller {
+    /** Whether node name is set. */
+    private volatile boolean nodeNameSet;
+
     /** Node name. */
     private volatile String nodeName = U.LOC_IGNITE_NAME_EMPTY;
 
@@ -41,7 +44,11 @@ public abstract class AbstractNodeNameAwareMarshaller extends AbstractMarshaller
      */
     @SuppressWarnings("unchecked")
     public <T> T nodeName(@Nullable String nodeName) {
-        this.nodeName = nodeName;
+        if (!nodeNameSet) {
+            this.nodeName = nodeName;
+
+            nodeNameSet = true;
+        }
 
         return (T)this;
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/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 8c86160..3c5a1df 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
@@ -30,27 +30,6 @@ import java.io.OutputStream;
  */
 public class MarshallerUtils {
     /**
-     * Marshal object to stream and set grid name thread local.
-     *
-     * @param name Grid name.
-     * @param marshaller Marshaller.
-     * @param obj Object to marshal.
-     * @param out Output stream.
-     * @throws IgniteCheckedException If fail.
-     */
-    public static void marshal(String name, Marshaller marshaller, @Nullable Object obj,
OutputStream out)
-        throws IgniteCheckedException {
-        String oldName = IgniteUtils.setCurrentIgniteName(name);
-
-        try {
-            marshaller.marshal(obj, out);
-        }
-        finally {
-            IgniteUtils.restoreCurrentIgniteName(oldName);
-        }
-    }
-
-    /**
      * Marshal object with node name taken from provided kernal context.
      *
      * @param ctx Kernal context.

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
index bcde7f4..7a130d3 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/jdk/JdkMarshaller.java
@@ -67,7 +67,7 @@ import org.jetbrains.annotations.Nullable;
  */
 public class JdkMarshaller extends AbstractNodeNameAwareMarshaller {
     /** {@inheritDoc} */
-    @Override public void marshal0(@Nullable Object obj, OutputStream out) throws IgniteCheckedException
{
+    @Override protected void marshal0(@Nullable Object obj, OutputStream out) throws IgniteCheckedException
{
         assert out != null;
 
         ObjectOutputStream objOut = null;
@@ -89,7 +89,7 @@ public class JdkMarshaller extends AbstractNodeNameAwareMarshaller {
     }
 
     /** {@inheritDoc} */
-    @Override public byte[] marshal0(@Nullable Object obj) throws IgniteCheckedException
{
+    @Override protected byte[] marshal0(@Nullable Object obj) throws IgniteCheckedException
{
         GridByteArrayOutputStream out = null;
 
         try {
@@ -106,7 +106,7 @@ public class JdkMarshaller extends AbstractNodeNameAwareMarshaller {
 
     /** {@inheritDoc} */
     @SuppressWarnings({"unchecked"})
-    @Override public <T> T unmarshal0(InputStream in, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
+    @Override protected <T> T unmarshal0(InputStream in, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
         assert in != null;
 
         if (clsLdr == null)
@@ -133,7 +133,7 @@ public class JdkMarshaller extends AbstractNodeNameAwareMarshaller {
     }
 
     /** {@inheritDoc} */
-    @Override public <T> T unmarshal0(byte[] arr, @Nullable ClassLoader clsLdr) throws
IgniteCheckedException {
+    @Override protected <T> T unmarshal0(byte[] arr, @Nullable ClassLoader clsLdr)
throws IgniteCheckedException {
         GridByteArrayInputStream in = null;
 
         try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
index 7a12582..0dad446 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsCheckpointSpi.java
@@ -34,6 +34,7 @@ import org.apache.ignite.internal.util.typedef.internal.A;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.internal.util.typedef.internal.SB;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.marshaller.AbstractNodeNameAwareMarshaller;
 import org.apache.ignite.marshaller.Marshaller;
 import org.apache.ignite.marshaller.jdk.JdkMarshaller;
 import org.apache.ignite.resources.IgniteInstanceResource;
@@ -217,6 +218,9 @@ public class SharedFsCheckpointSpi extends IgniteSpiAdapter implements
Checkpoin
         marsh = ignite.configuration().getMarshaller() instanceof BinaryMarshaller ? new
JdkMarshaller() :
             ignite.configuration().getMarshaller();
 
+        if (marsh instanceof AbstractNodeNameAwareMarshaller)
+            ((AbstractNodeNameAwareMarshaller)marsh).nodeName(ignite.name());
+
         folder = getNextSharedPath();
 
         if (folder == null)

http://git-wip-us.apache.org/repos/asf/ignite/blob/869e8831/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
index 29a6a36..e16f6ca 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/checkpoint/sharedfs/SharedFsUtils.java
@@ -94,7 +94,7 @@ final class SharedFsUtils {
         try {
             out = new FileOutputStream(file);
 
-            MarshallerUtils.marshal(igniteCfg.getGridName(), m, data, out);
+            m.marshal(data, out);
         }
         finally {
             U.close(out, log);


Mime
View raw message