From 59114d3f63ad798a5219b77b3ab69d6ffe156088 Mon Sep 17 00:00:00 2001 From: Nikolay Date: Thu, 19 Dec 2024 14:44:19 +0300 Subject: [PATCH] IGNITE-23830 Remove setForceServerMode (#11757) --- .../configuration/IgniteConfiguration.java | 1 - .../apache/ignite/internal/IgniteKernal.java | 4 -- .../discovery/GridDiscoveryManager.java | 8 ---- .../IgniteAuthenticationProcessor.java | 6 +-- .../cache/CacheAffinitySharedManager.java | 4 -- .../utils/PlatformConfigurationUtils.java | 2 - .../ignite/spi/discovery/tcp/ClientImpl.java | 3 -- .../ignite/spi/discovery/tcp/ServerImpl.java | 44 ++++++++++++++++++ .../spi/discovery/tcp/TcpDiscoveryImpl.java | 45 ------------------- .../spi/discovery/tcp/TcpDiscoverySpi.java | 40 +---------------- .../ipfinder/TcpDiscoveryIpFinderAdapter.java | 27 ----------- .../Discovery/Tcp/TcpDiscoverySpi.cs | 8 ---- .../IgniteConfigurationSection.xsd | 7 --- 13 files changed, 48 insertions(+), 151 deletions(-) diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java index 8f01002377ed2..00ed969cce64c 100644 --- a/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java +++ b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java @@ -2588,7 +2588,6 @@ public IgniteConfiguration setCacheConfiguration(CacheConfiguration... cacheCfg) * {@link DiscoverySpi} in client mode if this property is {@code true}. * * @return Client mode flag. - * @see TcpDiscoverySpi#setForceServerMode(boolean) */ public Boolean isClientMode() { return clientMode; 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 4361c97edef2f..0973010aee3e8 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 @@ -1251,10 +1251,6 @@ public void start( assert locNode.isClient(); - if (!ctx.discovery().reconnectSupported()) - throw new IgniteCheckedException("Client node in forceServerMode " + - "is not allowed to reconnect to the cluster and will be stopped."); - if (log.isDebugEnabled()) log.debug("Failed to start node components on node start, will wait for reconnect: " + e); 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 49dd2284696b3..d95f0121d7e26 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 @@ -138,7 +138,6 @@ import org.apache.ignite.spi.discovery.DiscoverySpiNodeAuthenticator; import org.apache.ignite.spi.discovery.DiscoverySpiOrderSupport; import org.apache.ignite.spi.discovery.IgniteDiscoveryThread; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.apache.ignite.spi.discovery.tcp.internal.TcpDiscoveryNode; import org.apache.ignite.spi.systemview.view.ClusterNodeView; import org.apache.ignite.spi.systemview.view.NodeAttributeView; @@ -477,13 +476,6 @@ private void updateClientNodes(UUID leftNodeId) { } } - /** {@inheritDoc} */ - @Override protected void onKernalStart0() throws IgniteCheckedException { - if ((getSpi() instanceof TcpDiscoverySpi) && Boolean.TRUE.equals(ctx.config().isClientMode()) && !getSpi().isClientMode()) - ctx.performance().add("Enable client mode for TcpDiscoverySpi " + - "(set TcpDiscoverySpi.forceServerMode to false)"); - } - /** {@inheritDoc} */ @Override public void start() throws IgniteCheckedException { ctx.addNodeAttribute(ATTR_OFFHEAP_SIZE, requiredOffheap()); diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java index b4a39621e0f69..62e7ac2b34be2 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/authentication/IgniteAuthenticationProcessor.java @@ -287,8 +287,7 @@ else if (msg instanceof UserAuthenticateResponseMessage) if (ctx.clientNode()) { if (ctx.discovery().aliveServerNodes().isEmpty()) { throw new IgniteAccessControlException("No alive server node was found to which the authentication" + - " operation could be delegated. It is possible that the client node has been started with the" + - " \"forceServerMode\" flag enabled and no server node had been started yet."); + " operation could be delegated."); } AuthenticateFuture fut; @@ -631,8 +630,7 @@ private ClusterNode coordinator() { if (res == null && !ctx.discovery().allNodes().isEmpty() && ctx.discovery().aliveServerNodes().isEmpty()) { - U.warn(log, "Cannot find the server coordinator node. " - + "Possible a client is started with forceServerMode=true."); + U.warn(log, "Cannot find the server coordinator node."); } else assert res != null; diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java index 7c86726f9b9c1..b363cbef0ce88 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/CacheAffinitySharedManager.java @@ -77,7 +77,6 @@ import org.apache.ignite.lang.IgniteFuture; import org.apache.ignite.lang.IgniteInClosure; import org.apache.ignite.lang.IgniteUuid; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; import org.jetbrains.annotations.Nullable; import static org.apache.ignite.cache.CacheRebalanceMode.NONE; @@ -223,9 +222,6 @@ boolean onCustomEvent(CacheAffinityChangeMessage msg) { boolean isClient = cctx.discovery().localNode().isClient(); - if (cctx.kernalContext().config().getDiscoverySpi() instanceof TcpDiscoverySpi) - isClient &= !((TcpDiscoverySpi)cctx.kernalContext().config().getDiscoverySpi()).isForceServerMode(); - // Skip message if affinity was already recalculated. // Client node should just accept the flag from the mutated message. boolean exchangeNeeded = (isClient) ? msg.exchangeNeeded() : diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java index 85731d22b0705..929b70c93506d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/utils/PlatformConfigurationUtils.java @@ -1051,7 +1051,6 @@ else if (ipFinderType == 2) { disco.setNetworkTimeout(in.readLong()); disco.setJoinTimeout(in.readLong()); - disco.setForceServerMode(in.readBoolean()); disco.setClientReconnectDisabled(in.readBoolean()); disco.setLocalAddress(in.readString()); disco.setReconnectCount(in.readInt()); @@ -1627,7 +1626,6 @@ private static void writeDiscoveryConfiguration(BinaryRawWriter w, DiscoverySpi w.writeLong(tcp.getNetworkTimeout()); w.writeLong(tcp.getJoinTimeout()); - w.writeBoolean(tcp.isForceServerMode()); w.writeBoolean(tcp.isClientReconnectDisabled()); w.writeString(tcp.getLocalAddress()); w.writeInt(tcp.getReconnectCount()); 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 2c6b2e2e044ca..e228345ba4f64 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 @@ -306,9 +306,6 @@ class ClientImpl extends TcpDiscoveryImpl { sockReader = new SocketReader(); sockReader.start(); - if (spi.ipFinder.isShared() && spi.isForceServerMode()) - registerLocalNodeAddress(); - msgWorker = new MessageWorker(log); new IgniteSpiThread(msgWorker.igniteInstanceName(), msgWorker.name(), log) { 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 3359095e8b13b..8cb424bab341e 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 @@ -2017,6 +2017,50 @@ else if (log.isDebugEnabled()) log.debug("Received metrics from unknown node: " + nodeId); } + /** + * @throws IgniteSpiException If failed. + */ + private final void registerLocalNodeAddress() throws IgniteSpiException { + long spiJoinTimeout = spi.getJoinTimeout(); + + // Make sure address registration succeeded. + // ... but limit it if join timeout is configured. + long startNanos = spiJoinTimeout > 0 ? System.nanoTime() : 0; + + while (true) { + try { + spi.ipFinder.initializeLocalAddresses( + U.resolveAddresses(spi.getAddressResolver(), locNode.socketAddresses())); + + // Success. + break; + } + catch (IllegalStateException e) { + throw new IgniteSpiException("Failed to register local node address with IP finder: " + + locNode.socketAddresses(), e); + } + catch (IgniteSpiException e) { + LT.error(log, e, "Failed to register local node address in IP finder on start " + + "(retrying every " + spi.getReconnectDelay() + " ms; " + + "change 'reconnectDelay' to configure the frequency of retries)."); + } + + if (spiJoinTimeout > 0 && U.millisSinceNanos(startNanos) > spiJoinTimeout) + throw new IgniteSpiException( + "Failed to register local addresses with IP finder within join timeout " + + "(make sure IP finder configuration is correct, and operating system firewalls are disabled " + + "on all host machines, or consider increasing 'joinTimeout' configuration property) " + + "[joinTimeout=" + spiJoinTimeout + ']'); + + try { + U.sleep(spi.getReconnectDelay()); + } + catch (IgniteInterruptedCheckedException e) { + throw new IgniteSpiException("Thread has been interrupted.", e); + } + } + } + /** * FOR TEST ONLY!!! *

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 93a4be8782787..d8d5164f4afaa 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 @@ -34,7 +34,6 @@ import org.apache.ignite.cluster.ClusterMetrics; import org.apache.ignite.cluster.ClusterNode; import org.apache.ignite.internal.IgniteEx; -import org.apache.ignite.internal.IgniteInterruptedCheckedException; import org.apache.ignite.internal.processors.tracing.NoopTracing; import org.apache.ignite.internal.processors.tracing.Tracing; import org.apache.ignite.internal.util.typedef.T2; @@ -384,50 +383,6 @@ public abstract void updateMetrics(UUID nodeId, Map cacheMetrics, long tsNanos); - /** - * @throws IgniteSpiException If failed. - */ - protected final void registerLocalNodeAddress() throws IgniteSpiException { - long spiJoinTimeout = spi.getJoinTimeout(); - - // Make sure address registration succeeded. - // ... but limit it if join timeout is configured. - long startNanos = spiJoinTimeout > 0 ? System.nanoTime() : 0; - - while (true) { - try { - spi.ipFinder.initializeLocalAddresses( - U.resolveAddresses(spi.getAddressResolver(), locNode.socketAddresses())); - - // Success. - break; - } - catch (IllegalStateException e) { - throw new IgniteSpiException("Failed to register local node address with IP finder: " + - locNode.socketAddresses(), e); - } - catch (IgniteSpiException e) { - LT.error(log, e, "Failed to register local node address in IP finder on start " + - "(retrying every " + spi.getReconnectDelay() + " ms; " + - "change 'reconnectDelay' to configure the frequency of retries)."); - } - - if (spiJoinTimeout > 0 && U.millisSinceNanos(startNanos) > spiJoinTimeout) - throw new IgniteSpiException( - "Failed to register local addresses with IP finder within join timeout " + - "(make sure IP finder configuration is correct, and operating system firewalls are disabled " + - "on all host machines, or consider increasing 'joinTimeout' configuration property) " + - "[joinTimeout=" + spiJoinTimeout + ']'); - - try { - U.sleep(spi.getReconnectDelay()); - } - catch (IgniteInterruptedCheckedException e) { - throw new IgniteSpiException("Thread has been interrupted.", e); - } - } - } - /** * @param ackTimeout Acknowledgement timeout. * @return {@code True} if acknowledgement timeout is less or equal to 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 abffb63f9ec05..a2d55b094f54d 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 @@ -130,9 +130,7 @@ * TcpDiscoverySpi starts in client mode as well. In this case node does not take its place in the ring, * but it connects to random node in the ring (IP taken from IP finder configured) and * use it as a router for discovery traffic. - * Therefore slow client node or its shutdown will not affect whole cluster. If TcpDiscoverySpi - * needs to be started in server mode regardless of {@link IgniteConfiguration#clientMode}, - * {@link #forceSrvMode} should be set to true. + * Therefore slow client node or its shutdown will not affect whole cluster. *

* At startup SPI tries to send messages to random IP taken from * {@link TcpDiscoveryIpFinder} about self start (stops when send succeeds) @@ -191,7 +189,6 @@ *

  • Thread priority for threads started by SPI (see {@link #setThreadPriority(int)})
  • *
  • IP finder clean frequency (see {@link #setIpFinderCleanFrequency(long)})
  • *
  • Statistics print frequency (see {@link #setStatisticsPrintFrequency(long)}
  • - *
  • Force server mode (see {@link #setForceServerMode(boolean)}
  • * *

    Java Example

    *
    @@ -444,9 +441,6 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements IgniteDiscovery
         /** */
         protected TcpDiscoveryImpl impl;
     
    -    /** */
    -    private boolean forceSrvMode;
    -
         /** */
         private boolean clientReconnectDisabled;
     
    @@ -564,36 +558,6 @@ public void dumpDebugInfo() {
             return impl instanceof ClientImpl;
         }
     
    -    /**
    -     * If {@code true} TcpDiscoverySpi will started in server mode regardless
    -     * of {@link IgniteConfiguration#isClientMode()}
    -     *
    -     * @return forceServerMode flag.
    -     * @deprecated Will be removed at 3.0.
    -     */
    -    @Deprecated
    -    public boolean isForceServerMode() {
    -        return forceSrvMode;
    -    }
    -
    -    /**
    -     * Sets force server mode flag.
    -     * 

    - * If {@code true} TcpDiscoverySpi is started in server mode regardless - * of {@link IgniteConfiguration#isClientMode()}. - * - * @param forceSrvMode forceServerMode flag. - * @return {@code this} for chaining. - * @deprecated Will be removed at 3.0. - */ - @IgniteSpiConfiguration(optional = true) - @Deprecated - public TcpDiscoverySpi setForceServerMode(boolean forceSrvMode) { - this.forceSrvMode = forceSrvMode; - - return this; - } - /** * If {@code true} client does not try to reconnect after * server detected client node failure. @@ -2263,7 +2227,7 @@ protected void initializeImpl() { initFailureDetectionTimeout(); - if (!forceSrvMode && (Boolean.TRUE.equals(ignite.configuration().isClientMode()))) { + if (Boolean.TRUE.equals(ignite.configuration().isClientMode())) { if (ackTimeout == 0) ackTimeout = DFLT_ACK_TIMEOUT_CLIENT; diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAdapter.java index c0292e53660bb..3ddc440af784d 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/ipfinder/TcpDiscoveryIpFinderAdapter.java @@ -26,8 +26,6 @@ import org.apache.ignite.spi.IgniteSpiConfiguration; import org.apache.ignite.spi.IgniteSpiContext; import org.apache.ignite.spi.IgniteSpiException; -import org.apache.ignite.spi.discovery.DiscoverySpi; -import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; /** * IP finder interface implementation adapter. @@ -95,31 +93,6 @@ public TcpDiscoveryIpFinderAdapter setShared(boolean shared) { // No-op. } - /** - * @return {@code True} if TCP discovery works in client mode. - * @deprecated Since 2.8. May return incorrect value if client and server nodes shares same {@link - * TcpDiscoveryIpFinder} instance. - */ - @Deprecated - protected boolean discoveryClientMode() { - boolean clientMode; - - Ignite ignite0 = ignite; - - if (ignite0 != null) { // Can be null if used in tests without starting Ignite. - DiscoverySpi discoSpi = ignite0.configuration().getDiscoverySpi(); - - if (!(discoSpi instanceof TcpDiscoverySpi)) - throw new IgniteSpiException("TcpDiscoveryIpFinder should be used with TcpDiscoverySpi: " + discoSpi); - - clientMode = ignite0.configuration().isClientMode() && !((TcpDiscoverySpi)discoSpi).isForceServerMode(); - } - else - clientMode = false; - - return clientMode; - } - /** * @return SPI context. */ diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs index 154124a68384e..edd1b8dff073b 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs +++ b/modules/platforms/dotnet/Apache.Ignite.Core/Discovery/Tcp/TcpDiscoverySpi.cs @@ -114,7 +114,6 @@ internal TcpDiscoverySpi(IBinaryRawReader reader) NetworkTimeout = reader.ReadLongAsTimespan(); JoinTimeout = reader.ReadLongAsTimespan(); - ForceServerMode = reader.ReadBoolean(); ClientReconnectDisabled = reader.ReadBoolean(); LocalAddress = reader.ReadString(); ReconnectCount = reader.ReadInt(); @@ -160,12 +159,6 @@ internal TcpDiscoverySpi(IBinaryRawReader reader) /// public TimeSpan JoinTimeout { get; set; } - ///

    - /// Gets or sets a value indicating whether TcpDiscoverySpi is started in server mode - /// regardless of setting. - /// - public bool ForceServerMode { get; set; } - /// /// Gets or sets a value indicating whether client does not try to reconnect after /// server detected client node failure. @@ -247,7 +240,6 @@ internal void Write(IBinaryRawWriter writer) writer.WriteLong((long) NetworkTimeout.TotalMilliseconds); writer.WriteLong((long) JoinTimeout.TotalMilliseconds); - writer.WriteBoolean(ForceServerMode); writer.WriteBoolean(ClientReconnectDisabled); writer.WriteString(LocalAddress); writer.WriteInt(ReconnectCount); diff --git a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd index bde2ad9ededa2..9dd4779dd9925 100644 --- a/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd +++ b/modules/platforms/dotnet/Apache.Ignite.Core/IgniteConfigurationSection.xsd @@ -1125,13 +1125,6 @@ Whether client does not try to reconnect after server detected client node failure. - - - - Whether TcpDiscoveryspi is started in server mode regardless of IgniteConfiguration.ClientMode setting. - - - IP finder clean frequency.