Repository: incubator-ignite Updated Branches: refs/heads/ignite-gg-9966-1 [created] 4abb0e8ec
#ignite-gg-9966: Add node validator. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/ccfe100b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/ccfe100b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/ccfe100b Branch: refs/heads/ignite-gg-9966-1 Commit: ccfe100b4b6752f651922ac2ee2fcdeea848f52f Parents: 07ca9fa Author: ivasilinets <ivasilin...@gridgain.com> Authored: Thu Apr 2 17:25:18 2015 +0300 Committer: ivasilinets <ivasilin...@gridgain.com> Committed: Thu Apr 2 17:25:18 2015 +0300 ---------------------------------------------------------------------- .../internal/managers/GridManagerAdapter.java | 11 +- .../ignite/internal/spi/EntNodeValidator.java | 59 +++++++++++ .../ignite/spi/discovery/NodeValidator.java | 58 +++++++++++ .../spi/discovery/tcp/TcpDiscoverySpi.java | 104 ------------------- 4 files changed, 127 insertions(+), 105 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ccfe100b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java index 982ca86..fb4f5d4 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/GridManagerAdapter.java @@ -28,9 +28,11 @@ import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; +import org.apache.ignite.plugin.*; import org.apache.ignite.plugin.extensions.communication.*; import org.apache.ignite.plugin.security.*; import org.apache.ignite.spi.*; +import org.apache.ignite.spi.discovery.*; import org.apache.ignite.spi.swapspace.*; import org.jetbrains.annotations.*; @@ -477,7 +479,14 @@ public abstract class GridManagerAdapter<T extends IgniteSpi> implements GridMan return err; } - return null; + for (PluginProvider pl : ctx.plugins().allProviders()) { + NodeValidator val = (NodeValidator) pl.createComponent(ctx.plugins().pluginContextForProvider(pl), NodeValidator.class); + + if (val != null) + return val.validateNode(ctx.discovery().localNode(), node); + } + + return new NodeValidator().validateNode(ctx.discovery().localNode(), node); } @Override public Collection<GridSecuritySubject> authenticatedSubjects() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ccfe100b/modules/core/src/main/java/org/apache/ignite/internal/spi/EntNodeValidator.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/spi/EntNodeValidator.java b/modules/core/src/main/java/org/apache/ignite/internal/spi/EntNodeValidator.java new file mode 100644 index 0000000..08d445e --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/internal/spi/EntNodeValidator.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.internal.spi; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.spi.*; +import org.apache.ignite.spi.discovery.*; + +import java.util.*; + +import static org.apache.ignite.internal.IgniteNodeAttributes.*; + +/** + * Validate node's versions. + */ +public class EntNodeValidator extends NodeValidator { + + /** {@inheritDoc} */ + @Override public IgniteSpiNodeValidationResult validateNode(ClusterNode locNode, ClusterNode node) { + // Check version. + String locBuildVer = locNode.attribute(ATTR_BUILD_VER); + String rmtBuildVer = node.attribute(ATTR_BUILD_VER); + + if (!F.eq(rmtBuildVer, locBuildVer)) { + Collection<String> locCompatibleVers = locNode.attribute(ATTR_COMPATIBLE_VERS); + Collection<String> rmtCompatibleVers = node.attribute(ATTR_COMPATIBLE_VERS); + + if (F.contains(rmtCompatibleVers, locBuildVer) || F.contains(locCompatibleVers, rmtBuildVer)) { + String errMsg = "Local node's build version differs from remote node's, " + + "but they are compatible (will continue join process) " + + "[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + rmtBuildVer + + ", locNodeAddrs=" + U.addressesAsString(locNode) + + ", rmtNodeAddrs=" + U.addressesAsString(node) + + ", locNodeId=" + locNode.id() + ", rmtNodeId=" + node.id() + ']'; + + return new IgniteSpiNodeValidationResult(node.id(), errMsg, errMsg); + } + } + + return null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ccfe100b/modules/core/src/main/java/org/apache/ignite/spi/discovery/NodeValidator.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/NodeValidator.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/NodeValidator.java new file mode 100644 index 0000000..9fea060 --- /dev/null +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/NodeValidator.java @@ -0,0 +1,58 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.spi.discovery; + +import org.apache.ignite.cluster.*; +import org.apache.ignite.internal.util.typedef.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.apache.ignite.spi.*; + +import static org.apache.ignite.internal.IgniteNodeAttributes.*; + +/** + * Validate node's versions. + */ +public class NodeValidator { + /** + * @param locNode Local node. + * @param node Remote node. + * @return Ignite spi node validation result. + */ + public IgniteSpiNodeValidationResult validateNode(ClusterNode locNode, ClusterNode node) { + // Check version. + String locBuildVer = locNode.attribute(ATTR_BUILD_VER); + String rmtBuildVer = node.attribute(ATTR_BUILD_VER); + + if (!F.eq(rmtBuildVer, locBuildVer)) { + // OS nodes don't support rolling updates. + if (!locBuildVer.equals(rmtBuildVer)) { + String errMsg = "Local node and remote node have different version numbers " + + "(node will not join, Ignite does not support rolling updates, " + + "so versions must be exactly the same) " + + "[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + rmtBuildVer + + ", locNodeAddrs=" + U.addressesAsString(locNode) + + ", rmtNodeAddrs=" + U.addressesAsString(node) + + ", locNodeId=" + locNode.id() + ", rmtNodeId=" + node.id() + ']'; + + return new IgniteSpiNodeValidationResult(node.id(), errMsg, errMsg); + } + } + + return null; + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/ccfe100b/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 d5c05f7..d17f9b3 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 @@ -3254,110 +3254,6 @@ public class TcpDiscoverySpi extends TcpDiscoverySpiAdapter implements TcpDiscov return; } - // Check version. - String locBuildVer = locNode.attribute(ATTR_BUILD_VER); - String rmtBuildVer = node.attribute(ATTR_BUILD_VER); - - if (!F.eq(rmtBuildVer, locBuildVer)) { - // OS nodes don't support rolling updates. - if (!locBuildVer.equals(rmtBuildVer)) { - String errMsg = "Local node and remote node have different version numbers " + - "(node will not join, Ignite does not support rolling updates, " + - "so versions must be exactly the same) " + - "[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + rmtBuildVer + - ", locNodeAddrs=" + U.addressesAsString(locNode) + - ", rmtNodeAddrs=" + U.addressesAsString(node) + - ", locNodeId=" + locNode.id() + ", rmtNodeId=" + msg.creatorNodeId() + ']'; - - LT.warn(log, null, errMsg); - - // Always output in debug. - if (log.isDebugEnabled()) - log.debug(errMsg); - - try { - String sndMsg = "Local node and remote node have different version numbers " + - "(node will not join, Ignite does not support rolling updates, " + - "so versions must be exactly the same) " + - "[locBuildVer=" + rmtBuildVer + ", rmtBuildVer=" + locBuildVer + - ", locNodeAddrs=" + U.addressesAsString(node) + ", locPort=" + node.discoveryPort() + - ", rmtNodeAddr=" + U.addressesAsString(locNode) + ", locNodeId=" + node.id() + - ", rmtNodeId=" + locNode.id() + ']'; - - trySendMessageDirectly(node, - new TcpDiscoveryCheckFailedMessage(locNodeId, sndMsg)); - } - catch (IgniteSpiException e) { - if (log.isDebugEnabled()) - log.debug("Failed to send version check failed message to node " + - "[node=" + node + ", err=" + e.getMessage() + ']'); - - onException("Failed to send version check failed message to node " + - "[node=" + node + ", err=" + e.getMessage() + ']', e); - } - - // Ignore join request. - return; - } - - Collection<String> locCompatibleVers = locNode.attribute(ATTR_COMPATIBLE_VERS); - Collection<String> rmtCompatibleVers = node.attribute(ATTR_COMPATIBLE_VERS); - - if (F.contains(rmtCompatibleVers, locBuildVer) || F.contains(locCompatibleVers, rmtBuildVer)) { - String errMsg = "Local node's build version differs from remote node's, " + - "but they are compatible (will continue join process) " + - "[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + rmtBuildVer + - ", locNodeAddrs=" + U.addressesAsString(locNode) + - ", rmtNodeAddrs=" + U.addressesAsString(node) + - ", locNodeId=" + locNode.id() + ", rmtNodeId=" + msg.creatorNodeId() + ']'; - - LT.warn(log, null, errMsg); - - // Always output in debug. - if (log.isDebugEnabled()) - log.debug(errMsg); - } - else { - String errMsg = "Local node's and remote node's build versions are not compatible " + - "(topologies built with different Ignite versions " + - "are supported in Enterprise version only) " + - "[locBuildVer=" + locBuildVer + ", rmtBuildVer=" + rmtBuildVer + - ", locNodeAddrs=" + U.addressesAsString(locNode) + - ", rmtNodeAddrs=" + U.addressesAsString(node) + - ", locNodeId=" + locNode.id() + ", rmtNodeId=" + msg.creatorNodeId() + ']'; - - LT.warn(log, null, errMsg); - - // Always output in debug. - if (log.isDebugEnabled()) - log.debug(errMsg); - - try { - String sndMsg = "Local node's and remote node's build versions are not compatible " + - "(topologies built with different Ignite versions " + - "are supported in Enterprise version only) " + - " [locBuildVer=" + rmtBuildVer + ", rmtBuildVer=" + locBuildVer + - ", locNodeAddrs=" + U.addressesAsString(node) + ", locPort=" + node.discoveryPort() + - ", rmtNodeAddr=" + U.addressesAsString(locNode) + ", locNodeId=" + node.id() + - ", rmtNodeId=" + locNode.id() + ']'; - - trySendMessageDirectly(node, - new TcpDiscoveryCheckFailedMessage(locNodeId, sndMsg)); - } - catch (IgniteSpiException e) { - if (log.isDebugEnabled()) - log.debug("Failed to send version check failed message to node " + - "[node=" + node + ", err=" + e.getMessage() + ']'); - - onException("Failed to send version check failed message to node " + - "[node=" + node + ", err=" + e.getMessage() + ']', e); - } - - // Ignore join request. - return; - } - } - String locMarsh = locNode.attribute(ATTR_MARSHALLER); String rmtMarsh = node.attribute(ATTR_MARSHALLER);