def startNettyServer()

in flink-connector-netty/src/main/scala/org/apache/flink/streaming/connectors/netty/example/ServerTrait.scala [32:49]


  def startNettyServer(portNotInUse: Int, callbackUrl: Option[String]): InetSocketAddress

  def register(address: InetSocketAddress, callbackUrl: Option[String]): Unit = {
    callbackUrl match {
      case Some(url) =>
        val ip = address.getAddress.getHostAddress
        val newIp = if (ip.startsWith("0") || ip.startsWith("127")) {
          NettyUtil.findLocalInetAddress().getHostAddress
        } else {
          ip
        }
        val port = address.getPort
        val param = s"ip=${URLEncoder.encode(newIp, "UTF-8")}&port=$port"
        val callUrl = if (url.endsWith("?")) param else "?" + param
        NettyUtil.sendGetRequest(url + callUrl)
      case _ =>
    }
  }