Add option to turn on filter reachable addresses in TcpCommunicationSpi. This closes
@@ -311,6 +311,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
/** Default value for {@code TCP_NODELAY} socket option (value is <tt>true</tt>). */
public static final boolean DFLT_TCP_NODELAY = true;
+ /** Default value for {@code FILTER_REACHABLE_ADDRESSES} socket option (value is <tt>false</tt>). */
+ public static final boolean DFLT_FILTER_REACHABLE_ADDRESSES = false;
+
/** Default received messages threshold for sending ack. */
public static final int DFLT_ACK_SND_THRESHOLD = 32;
@@ -1016,6 +1019,9 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
/** {@code TCP_NODELAY} option value for created sockets. */
private boolean tcpNoDelay = DFLT_TCP_NODELAY;
+ /** {@code FILTER_REACHABLE_ADDRESSES} option value for created sockets. */
+ private boolean filterReachableAddresses = DFLT_FILTER_REACHABLE_ADDRESSES;
+
/** Number of received messages after which acknowledgment is sent. */
private int ackSndThreshold = DFLT_ACK_SND_THRESHOLD;
@@ -1625,6 +1631,33 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
return tcpNoDelay;
}
+ /**
+ * Gets value for {@code FILTER_REACHABLE_ADDRESSES} socket option.
+ *
+ * @return {@code True} if needed to filter reachable addresses.
+ */
+ public boolean isFilterReachableAddresses() {
+ return filterReachableAddresses;
+ }
+
+ /**
+ * Setting this option to {@code true} enables filter for reachable
+ * addresses on creating tcp client.
+ * <p>
+ * Usually its advised to set this value to {@code false}.
+ * <p>
+ * If not provided, default value is {@link #DFLT_FILTER_REACHABLE_ADDRESSES}.
+ *
+ * @param filterReachableAddresses {@code True} to filter reachable addresses.
+ * @return {@code this} for chaining.
+ */
+ @IgniteSpiConfiguration(optional = true)
+ public TcpCommunicationSpi setFilterReachableAddresses(boolean filterReachableAddresses) {
+ this.filterReachableAddresses = filterReachableAddresses;
+
+ return this;
+ }
+
/**
* Sets receive buffer size for sockets created or accepted by this SPI.
* <p>
@@ -2952,6 +2985,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
if (isExtAddrsExist)
addrs.addAll(extAddrs);
+ if (filterReachableAddresses) {
Set<InetAddress> allInetAddrs = U.newHashSet(addrs.size());
for (InetSocketAddress addr : addrs) {
@@ -2981,6 +3015,7 @@ public class TcpCommunicationSpi extends IgniteSpiAdapter implements Communicati
if (log.isDebugEnabled())
log.debug("Addresses to connect for node [rmtNode=" + node.id() + ", addrs=" + addrs.toString() + ']');
+ }
boolean conn = false;
GridCommunicationClient client = null;
