Repository: incubator-ignite Updated Branches: refs/heads/ignite-752 9dfdce5c5 -> d9ddfb402
ignite-752: adding documentation Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5496d10b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5496d10b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5496d10b Branch: refs/heads/ignite-752 Commit: 5496d10b3d21a42953b183d7d4724db1fff6258a Parents: 9dfdce5 Author: Denis Magda <dma...@gridgain.com> Authored: Mon Jul 20 11:30:20 2015 +0300 Committer: Denis Magda <dma...@gridgain.com> Committed: Mon Jul 20 11:30:20 2015 +0300 ---------------------------------------------------------------------- .../configuration/IgniteConfiguration.java | 32 +++++++++++++++++--- .../org/apache/ignite/spi/IgniteSpiAdapter.java | 17 ++++++----- .../IgniteSpiOperationTimeoutController.java | 30 ++++++++++-------- .../spi/IgniteSpiOperationTimeoutException.java | 9 +++++- .../ignite/spi/discovery/tcp/ServerImpl.java | 25 +++++++++++---- .../spi/discovery/tcp/TcpDiscoveryImpl.java | 2 +- .../spi/discovery/tcp/TcpDiscoverySpi.java | 17 ++++++++--- .../tcp/internal/TcpDiscoveryNode.java | 10 +++--- .../TcpDiscoveryStatusCheckMessage.java | 12 +++++--- 9 files changed, 111 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/modules/core/src/main/java/org/apache/ignite/configuration/IgniteConfiguration.java ---------------------------------------------------------------------- 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 49b53c9..50f78a5 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 @@ -1636,16 +1636,40 @@ public class IgniteConfiguration { } /** - * TODO: IGNITE-752 - * @return + * Returns failure detection threshold used by {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi} in their + * network related operations. + * <p> + * Default is {@link #DFLT_FAILURE_DETECTION_THRESHOLD}. + * </p> + * @return Failure detection threshold in milliseconds. + * @see #setFailureDetectionThreshold(long) */ public long getFailureDetectionThreshold() { return failureDetectionThreshold; } /** - * TODO: IGNITE-752 - * @param failureDetectionThreshold + * Sets failure detection threshold to use in {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi} for their + * network related operations. + * <p> + * This threshold is used as a maximum timeout for the whole network related operation that usually consists of + * request and response parts. As an example of such network operation, {@link TcpDiscoverySpi} uses this + * threshold when a message is send from one {@link ClusterNode} to another. Initially, the full value of the + * failure detection threshold is set as a socket write timeout when a node starts sending content of a message and + * then the rest of the threshold is set a socket read timeout when the sending node is waiting for response. If + * the threshold is reached during the time the message is being sent or response is being received then + * {@link TcpDiscoverySpi} will process this failure according to its implementation. + * </p> + * <p> + * The failure detection threshold is an easy and straightforward way to setup {@link TcpDiscoverySpi} and + * {@link TcpCommunicationSpi} depending on network conditions of a cluster. On the other hand if advanced setting + * of socket write, acknowledgement, network timeouts or other parameters is needed it can be done using specific + * {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi} APIs. However, sometimes by setting such a timeout or + * a parameter you will disable the failure detection threshold. The full list of such timeouts and parameters, + * that disable this threshold, is available as a part of {@link TcpDiscoverySpi} and {@link TcpCommunicationSpi} + * documentations. + * </p> + * @param failureDetectionThreshold Failure detection threshold in milliseconds. */ public void setFailureDetectionThreshold(long failureDetectionThreshold) { this.failureDetectionThreshold = failureDetectionThreshold; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java index 5f8a7d0..33a250d 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiAdapter.java @@ -593,7 +593,7 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement } /** - * TODO: IGNITE-752 + * Initiates and checks failure detection threshold value. */ protected void initFailureDetectionThreshold() { if (failureDetectionThresholdEnabled) { @@ -604,24 +604,27 @@ public abstract class IgniteSpiAdapter implements IgniteSpi, IgniteSpiManagement } /** - * TODO: IGNITE-752 - * @param enabled + * Enables or disables failure detection threshold. + * + * @param enabled {@code true} if enable, {@code false} otherwise. */ public void failureDetectionThresholdEnabled(boolean enabled) { failureDetectionThresholdEnabled = enabled; } /** - * TODO: IGNITE-752 - * @return + * Checks whether failure detection threshold is enabled for this {@link IgniteSpi}. + * + * @return {@code true} if enabled, {@code false} otherwise. */ public boolean failureDetectionThresholdEnabled() { return failureDetectionThresholdEnabled; } /** - * TODO: IGNITE-752 - * @return + * Returns failure detection threshold set to use for network related operations. + * + * @return failure detection threshold in milliseconds or {@code 0} if the threshold is disabled. */ public long failureDetectionThreshold() { return failureDetectionThreshold; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutController.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutController.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutController.java index 84ffd0f..6213893 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutController.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutController.java @@ -19,11 +19,14 @@ package org.apache.ignite.spi; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; -import java.io.*; import java.net.*; /** - * TODO: IGNITE-752 + * Object that incorporates logic that determines a timeout value for the next network related operation and checks + * whether a failure detection threshold is reached or not. + * + * A new instance of the class should be created for every complex network based operations that usually consists of + * request and response parts. */ public class IgniteSpiOperationTimeoutController { /** */ @@ -46,16 +49,18 @@ public class IgniteSpiOperationTimeoutController { public IgniteSpiOperationTimeoutController(IgniteSpiAdapter adapter) { failureDetectionThresholdEnabled = adapter.failureDetectionThresholdEnabled(); failureDetectionThreshold = adapter.failureDetectionThreshold(); - - assert !failureDetectionThresholdEnabled || failureDetectionThreshold > 0 : " [failureDetectionThreshold=" + - failureDetectionThreshold + ", thresholdEnabled=" + failureDetectionThresholdEnabled; } /** - * TODO: IGNITE-752 - * @param dfltTimeout - * @return - * @throws IgniteSpiOperationTimeoutException + * Returns a timeout value to use for the next network operation. + * + * If failure detection threshold is enabled then the returned value is a portion of time left since the last time + * this method is called. If the threshold is disabled then {@code dfltTimeout} is returned. + * + * @param dfltTimeout Timeout to use if failure detection threshold is disabled. + * @return Timeout in milliseconds. + * @throws IgniteSpiOperationTimeoutException If failure detection threshold is reached for an operation that uses + * this {@code IgniteSpiOperationTimeoutController}. */ public long nextTimeoutChunk(long dfltTimeout) throws IgniteSpiOperationTimeoutException { if (!failureDetectionThresholdEnabled) @@ -82,9 +87,10 @@ public class IgniteSpiOperationTimeoutController { } /** - * TODO: IGNITE-752 - * @param e - * @return + * Checks whether the given {@link Exception} is generated because failure detection threshold has been reached. + * + * @param e Exception. + * @return {@code true} if failure detection threshold is reached, {@code false} otherwise. */ public boolean checkFailureDetectionThresholdReached(Exception e) { if (!failureDetectionThresholdEnabled) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutException.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutException.java b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutException.java index 5dd0824..1ea05fd 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutException.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/IgniteSpiOperationTimeoutException.java @@ -18,9 +18,16 @@ package org.apache.ignite.spi; import org.apache.ignite.*; +import org.apache.ignite.spi.discovery.tcp.*; +import org.apache.ignite.spi.communication.tcp.*; +import org.apache.ignite.configuration.*; /** - * TODO: IGNITE-752 + * Kind of exception that is used when failure detection threshold is enabled for {@link TcpDiscoverySpi} or + * {@link TcpCommunicationSpi}. + * + * For more information refer to {@link IgniteConfiguration#setFailureDetectionThreshold(long)} and + * {@link IgniteSpiOperationTimeoutController}. */ public class IgniteSpiOperationTimeoutException extends IgniteCheckedException { /** */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/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 9496dbe..92800a4 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 @@ -1627,7 +1627,18 @@ class ServerImpl extends TcpDiscoveryImpl { } /** - * TODO: IGNITE-752 + * Thread performs the following two tasks: + * <ul> + * <li> + * Send connection check message to the next node with {@link TcpDiscoverySpi#connCheckFreq} frequency; + * </li> + * <li> + * Sends status check messages to next node if local node has not + * been receiving heartbeats ({@link TcpDiscoveryHeartbeatMessage}) + * for {@link TcpDiscoverySpi#getMaxMissedHeartbeats()} * + * {@link TcpDiscoverySpi#getHeartbeatFrequency()}. + * </li> + * </ul> */ private class CheckConnectionWorker extends CheckStatusSender { /** */ @@ -1672,8 +1683,9 @@ class ServerImpl extends TcpDiscoveryImpl { } /** - * TODO: IGNITE-752 - * @return + * Check connection aliveness status. + * + * @return Timeout to wait before caliing this method the next time. */ private long checkConnection() { if (U.currentTimeMillis() - locNode.lastDataReceivedTime() >= spi.failureDetectionThreshold() && @@ -1715,7 +1727,7 @@ class ServerImpl extends TcpDiscoveryImpl { } /** {@inheritDoc} */ - protected void messageProcessed() { + @Override protected void messageProcessed() { msgInQueue = false; } } @@ -4007,8 +4019,9 @@ class ServerImpl extends TcpDiscoveryImpl { } /** - * TODO: IGNITE-752 - * @param msg + * Processes connection check message. + * + * @param msg Connection check message. */ private void processConnectionCheckMessage(TcpDiscoveryConnectionCheckMessage msg) { assert msg.creatorNodeId().equals(getLocalNodeId()) && msg.senderNodeId() == null; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/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 20d49df..4dacf45 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 @@ -131,7 +131,7 @@ abstract class TcpDiscoveryImpl { } /** - * TODO: IGNITE-752 + * Called when a chunk of data is received from a remote node. */ protected void onDataReceived() { // No-op http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/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 23166f2..7ffa339 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 @@ -843,10 +843,19 @@ public class TcpDiscoverySpi extends IgniteSpiAdapter implements DiscoverySpi, T } /** - * TODO: IGNITE-752 - * - * @param connCheckFreq - * @return + * Sets connection check frequency. Used in conjunction with {@link IgniteConfiguration#failureDetectionThreshold}. + * <p> + * A node sends connection check messages to its next node in the topology with this frequency to check its + * connection status and quickly process a network related error if any. + * </p> + * <p> + * The way to check connection aliveness with connection check messages is much cheaper than to use heartbeat + * messages. The reason is that a connection check message is only processed by the next node in a topology, + * while a heartbeat message is translated twice across the ring. + * </p> + * @param connCheckFreq Frequency in milliseconds. + * @return Tcp discovery spi. + * @see IgniteConfiguration#setFailureDetectionThreshold(long) */ @IgniteSpiConfiguration(optional = true) public TcpDiscoverySpi setConnectionCheckFrequency(long connCheckFreq) { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java index b33c0c9..6485d0d 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/internal/TcpDiscoveryNode.java @@ -388,16 +388,18 @@ public class TcpDiscoveryNode extends GridMetadataAwareAdapter implements Cluste } /** - * TODO: IGNITE-752 - * @return + * Gets the last time a node received a data chunk from a remote node. + * + * @return Time in milliseconds. */ public long lastDataReceivedTime() { return lastDataReceivedTime; } /** - * TODO: IGNITE-752 - * @param lastDataReceivedTime + * Sets the last time a node receive a data chunk from a remote node in a topology. + * + * @param lastDataReceivedTime Time in milliseconds. */ public void lastDataReceivedTime(long lastDataReceivedTime) { this.lastDataReceivedTime = lastDataReceivedTime; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5496d10b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryStatusCheckMessage.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryStatusCheckMessage.java b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryStatusCheckMessage.java index b2c2e07..aa9d9ac 100644 --- a/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryStatusCheckMessage.java +++ b/modules/core/src/main/java/org/apache/ignite/spi/discovery/tcp/messages/TcpDiscoveryStatusCheckMessage.java @@ -102,16 +102,20 @@ public class TcpDiscoveryStatusCheckMessage extends TcpDiscoveryAbstractMessage } /** - * TODO: IGNITE-752 - * @return + * Checks whether this message is created and sent instead of {@link TcpDiscoveryConnectionCheckMessage} or not. + * + * @return {@code true} if yes, {@code false} otherwise. */ public boolean replacedConnCheckMsg() { return replacedConnCheckMsg; } /** - * TODO: IGNITE-752 - * @param replacedConnCheckMsg + * Sets whether this message is created and sent instead of {@link TcpDiscoveryConnectionCheckMessage} or not. This + * usually happens when the next node in a topology, that should receive this message, doesn't support processing + * of {@link TcpDiscoveryConnectionCheckMessage} messages. + * + * @param replacedConnCheckMsg {@code true} if replaced, {@code false} otherwise. */ public void replacedConnCheckMsg(boolean replacedConnCheckMsg) { this.replacedConnCheckMsg = replacedConnCheckMsg;