Skip to content

Instantly share code, notes, and snippets.

@ppearcy
Created October 27, 2014 06:34
Show Gist options
  • Save ppearcy/c5d969326b9e6ace8046 to your computer and use it in GitHub Desktop.
Save ppearcy/c5d969326b9e6ace8046 to your computer and use it in GitHub Desktop.
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