Not sure why you convert the "publish" address to a string, in Java you can
find the current transport port with
// find node address
NodesInfoRequest nodesInfoRequest = new
NodesInfoRequest().transport(true);
NodesInfoResponse response =
client.admin().cluster().nodesInfo(nodesInfoRequest).actionGet();
Object obj =
response.iterator().next().getTransport().getAddress().publishAddress();
if (obj instanceof InetSocketTransportAddress) {
InetSocketTransportAddress address =
(InetSocketTransportAddress) obj;
// ... process host and port from address
}
if (obj instanceof LocalTransportAddress) {
LocalTransportAddress address = (LocalTransportAddress) obj;
// .... process local address, no host/port
}
which is, I admit, still not pretty.
Note, if you have a node set to "local(true)", there is no host/port, but a
LocalTransportAddress.
Jörg
On Mon, Oct 27, 2014 at 7:36 AM, ppearcy <[email protected]> wrote:
> When starting a cluster via testing, I want to get the bounded port since
> I am letting choose and there might be a conflict.
>
> Here is the ugly and brittle code I came up to do this:
> https://gist.github.com/ppearcy/c5d969326b9e6ace8046
>
> Is there a nicer API than having to regex out the connection string?
>
> Thanks,
> Paul
>
> --
> You received this message because you are subscribed to the Google Groups
> "elasticsearch" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elasticsearch/2a10a6e4-5f01-45f4-a9b8-0be5d35546a0%40googlegroups.com
> <https://groups.google.com/d/msgid/elasticsearch/2a10a6e4-5f01-45f4-a9b8-0be5d35546a0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHDHKvokqgZ50AAVK%3D4Mvie73ifs%3DhbkcO%3Dw%2BCEWMtFKQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.