Class NetUtils

java.lang.Object
org.elasticsearch.core.internal.net.NetUtils

public class NetUtils
extends java.lang.Object
Utilities for network-related methods.
  • Constructor Summary

    Constructors
    Constructor Description
    NetUtils()  
  • Method Summary

    Modifier and Type Method Description
    static java.net.SocketOption<java.lang.Integer> getTcpKeepCountSocketOptionOrNull()
    Returns the extended TCP_KEEPCOUNT socket option, if available on this JDK
    static java.net.SocketOption<java.lang.Integer> getTcpKeepIdleSocketOptionOrNull()
    Returns the extended TCP_KEEPIDLE socket option, if available on this JDK
    static java.net.SocketOption<java.lang.Integer> getTcpKeepIntervalSocketOptionOrNull()
    Returns the extended TCP_KEEPINTERVAL socket option, if available on this JDK
    static void tryEnsureReasonableKeepAliveConfig​(java.nio.channels.NetworkChannel socketChannel)
    If SO_KEEPALIVE is enabled (default), this method ensures sane default values for the extended socket options TCP_KEEPIDLE and TCP_KEEPINTERVAL.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • NetUtils

      public NetUtils()
  • Method Details

    • getTcpKeepIdleSocketOptionOrNull

      public static java.net.SocketOption<java.lang.Integer> getTcpKeepIdleSocketOptionOrNull()
      Returns the extended TCP_KEEPIDLE socket option, if available on this JDK
    • getTcpKeepIntervalSocketOptionOrNull

      public static java.net.SocketOption<java.lang.Integer> getTcpKeepIntervalSocketOptionOrNull()
      Returns the extended TCP_KEEPINTERVAL socket option, if available on this JDK
    • getTcpKeepCountSocketOptionOrNull

      public static java.net.SocketOption<java.lang.Integer> getTcpKeepCountSocketOptionOrNull()
      Returns the extended TCP_KEEPCOUNT socket option, if available on this JDK
    • tryEnsureReasonableKeepAliveConfig

      public static void tryEnsureReasonableKeepAliveConfig​(java.nio.channels.NetworkChannel socketChannel)
      If SO_KEEPALIVE is enabled (default), this method ensures sane default values for the extended socket options TCP_KEEPIDLE and TCP_KEEPINTERVAL. The default value for TCP_KEEPIDLE is system dependent, but is typically 2 hours. Such a high value can result in firewalls eagerly closing these connections. To tell any intermediate devices that the connection remains alive, we explicitly set these options to 5 minutes if the defaults are higher than that.