Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elasticsearch get bounded port
val nodeRequest = new NodesInfoRequestBuilder(testCluster.esClient.admin().cluster()).all()
val nodeResponse = nodeRequest.execute().get()
val remoteAddress = nodeResponse.remoteAddress()
val nodesInfo = nodeResponse.getNodes.toList.head
val inetString = nodesInfo.getTransport.address().publishAddress().toString
val pattern =
"""
|inet\[\/\d+\.\d+\.\d+\.\d+\:(\d+)\]
""".stripMargin.r
val finallyPort = pattern.findFirstMatchIn(inetString).get.group(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.