ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject ignite git commit: ignite-1301: added portable protocol version info to node's attributes
Date Mon, 31 Aug 2015 13:38:35 GMT
Repository: ignite
Updated Branches:
  refs/heads/master f6ddf4ea7 -> 133558065


ignite-1301: added portable protocol version info to node's attributes


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

Branch: refs/heads/master
Commit: 13355806551138d29e34d5976a93234dac6d7998
Parents: f6ddf4e
Author: Denis Magda <dmagda@gridgain.com>
Authored: Mon Aug 31 16:38:06 2015 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Mon Aug 31 16:38:06 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/internal/IgniteKernal.java    |  4 ++
 .../ignite/internal/IgniteNodeAttributes.java   |  3 ++
 .../discovery/GridDiscoveryManager.java         | 13 ++++-
 .../marshaller/portable/PortableMarshaller.java |  3 ++
 .../GridDiscoveryManagerAttributesSelfTest.java | 50 ++++++++++++++++++++
 5 files changed, 71 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/13355806/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 489973f..4fa3564 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -71,6 +71,7 @@ import org.apache.ignite.lang.*;
 import org.apache.ignite.lifecycle.*;
 import org.apache.ignite.marshaller.*;
 import org.apache.ignite.marshaller.optimized.*;
+import org.apache.ignite.marshaller.portable.*;
 import org.apache.ignite.mxbean.*;
 import org.apache.ignite.plugin.*;
 import org.apache.ignite.spi.*;
@@ -1170,6 +1171,9 @@ public class IgniteKernal implements IgniteEx, IgniteMXBean, Externalizable
{
         add(ATTR_MARSHALLER, cfg.getMarshaller().getClass().getName());
         add(ATTR_USER_NAME, System.getProperty("user.name"));
         add(ATTR_GRID_NAME, gridName);
+        add(ATTR_PORTABLE_PROTO_VER, cfg.getMarshaller() instanceof PortableMarshaller ?
+            ((PortableMarshaller)cfg.getMarshaller()).getProtocolVersion().toString() :
+            PortableMarshaller.DFLT_PORTABLE_PROTO_VER.toString());
 
         add(ATTR_PEER_CLASSLOADING, cfg.isPeerClassLoadingEnabled());
         add(ATTR_DEPLOYMENT_MODE, cfg.getDeploymentMode());

http://git-wip-us.apache.org/repos/asf/ignite/blob/13355806/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
index 10b8df0..ea3eafd 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteNodeAttributes.java
@@ -135,6 +135,9 @@ public final class IgniteNodeAttributes {
     /** Node consistent id. */
     public static final String ATTR_NODE_CONSISTENT_ID = ATTR_PREFIX + ".consistent.id";
 
+    /** Portable protocol version. */
+    public static final String ATTR_PORTABLE_PROTO_VER = ATTR_PREFIX + ".portable.proto.ver";
+
     /**
      * Enforces singleton.
      */

http://git-wip-us.apache.org/repos/asf/ignite/blob/13355806/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
index a7363af..8437468 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManager.java
@@ -906,6 +906,8 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
         // Fetch local node attributes once.
         String locPreferIpV4 = locNode.attribute("java.net.preferIPv4Stack");
 
+        String locPortableProtoVer = locNode.attribute(ATTR_PORTABLE_PROTO_VER);
+
         Object locMode = locNode.attribute(ATTR_DEPLOYMENT_MODE);
 
         int locJvmMajVer = nodeJavaMajorVersion(locNode);
@@ -950,11 +952,18 @@ public class GridDiscoveryManager extends GridManagerAdapter<DiscoverySpi>
{
                 boolean rmtP2pEnabled = n.attribute(ATTR_PEER_CLASSLOADING);
 
                 if (locP2pEnabled != rmtP2pEnabled)
-                    throw new IgniteCheckedException("Remote node has peer class loading
enabled flag different from local " +
-                        "[locId8=" + U.id8(locNode.id()) + ", locPeerClassLoading=" + locP2pEnabled
+
+                    throw new IgniteCheckedException("Remote node has peer class loading
enabled flag different from" +
+                        " local [locId8=" + U.id8(locNode.id()) + ", locPeerClassLoading="
+ locP2pEnabled +
                         ", rmtId8=" + U.id8(n.id()) + ", rmtPeerClassLoading=" + rmtP2pEnabled
+
                         ", rmtAddrs=" + U.addressesAsString(n) + ']');
             }
+
+            String rmtPortableProtoVer = n.attribute(ATTR_PORTABLE_PROTO_VER);
+
+            // In order to support backward compatibility skip the check for nodes that don't
have this attribute.
+            if (rmtPortableProtoVer != null && !F.eq(locPortableProtoVer, rmtPortableProtoVer))
+                throw new IgniteCheckedException("Remote node has portable protocol version
different from local " +
+                    "[locVersion=" + locPortableProtoVer + ", rmtVersion=" + rmtPortableProtoVer
+ ']');
         }
 
         if (log.isDebugEnabled())

http://git-wip-us.apache.org/repos/asf/ignite/blob/13355806/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
index 2cac90e..32f8b29 100644
--- a/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
+++ b/modules/core/src/main/java/org/apache/ignite/marshaller/portable/PortableMarshaller.java
@@ -277,6 +277,9 @@ public class PortableMarshaller extends AbstractMarshaller {
      * @param protoVer Portable protocol version.
      */
     public void setProtocolVersion(PortableProtocolVersion protoVer) {
+        if (protoVer == null)
+            throw new IllegalArgumentException("Wrong portable protocol version: " + protoVer);
+
         this.protoVer = protoVer;
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/13355806/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
index e76c615..7e11592 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/managers/discovery/GridDiscoveryManagerAttributesSelfTest.java
@@ -18,12 +18,17 @@
 package org.apache.ignite.internal.managers.discovery;
 
 import org.apache.ignite.*;
+import org.apache.ignite.cluster.*;
 import org.apache.ignite.configuration.*;
+import org.apache.ignite.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
 import org.apache.ignite.testframework.junits.common.*;
 
+import java.lang.reflect.*;
+import java.util.*;
+
 import static org.apache.ignite.configuration.DeploymentMode.*;
 
 /**
@@ -151,6 +156,51 @@ public abstract class GridDiscoveryManagerAttributesSelfTest extends
GridCommonA
     }
 
     /**
+     * @throws Exception If failed.
+     */
+    public void testDifferentPortableProtocolVersions() throws Exception {
+        startGridWithPortableProtocolVer("VER_99_99_99");
+
+        try {
+            startGrid(1);
+
+            fail();
+        }
+        catch (IgniteCheckedException e) {
+            if (!e.getCause().getMessage().startsWith("Remote node has portable protocol
version different from local"))
+                throw e;
+        }
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNullPortableProtocolVersion() throws Exception {
+        startGridWithPortableProtocolVer(null);
+
+        // Must not fail in order to preserve backward compatibility with the nodes that
don't have this property yet.
+        startGrid(1);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void startGridWithPortableProtocolVer(String ver) throws Exception {
+        Ignite ignite = startGrid(0);
+
+        ClusterNode clusterNode = ignite.cluster().localNode();
+
+        Field f = clusterNode.getClass().getDeclaredField("attrs");
+        f.setAccessible(true);
+
+        Map<String, Object> attrs = new HashMap<>((Map<String, Object>)f.get(clusterNode));
+
+        attrs.put(IgniteNodeAttributes.ATTR_PORTABLE_PROTO_VER, ver);
+
+        f.set(clusterNode, attrs);
+    }
+
+    /**
      * @param preferIpV4 {@code java.net.preferIPv4Stack} system property value.
      * @throws Exception If failed.
      */


Mime
View raw message