Search in sources :

Example 1 with BindTransportException

use of org.opensearch.transport.BindTransportException in project OpenSearch by opensearch-project.

the class AbstractHttpServerTransport method bindServer.

protected void bindServer() {
    // Bind and start to accept incoming connections.
    InetAddress[] hostAddresses;
    try {
        hostAddresses = networkService.resolveBindHostAddresses(bindHosts);
    } catch (IOException e) {
        throw new BindHttpException("Failed to resolve host [" + Arrays.toString(bindHosts) + "]", e);
    }
    List<TransportAddress> boundAddresses = new ArrayList<>(hostAddresses.length);
    for (InetAddress address : hostAddresses) {
        boundAddresses.add(bindAddress(address));
    }
    final InetAddress publishInetAddress;
    try {
        publishInetAddress = networkService.resolvePublishHostAddresses(publishHosts);
    } catch (Exception e) {
        throw new BindTransportException("Failed to resolve publish address", e);
    }
    final int publishPort = resolvePublishPort(settings, boundAddresses, publishInetAddress);
    TransportAddress publishAddress = new TransportAddress(new InetSocketAddress(publishInetAddress, publishPort));
    this.boundAddress = new BoundTransportAddress(boundAddresses.toArray(new TransportAddress[0]), publishAddress);
    logger.info("{}", boundAddress);
}
Also used : BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) TransportAddress(org.opensearch.common.transport.TransportAddress) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) BindTransportException(org.opensearch.transport.BindTransportException) IOException(java.io.IOException) InetAddress(java.net.InetAddress) CancelledKeyException(java.nio.channels.CancelledKeyException) IOException(java.io.IOException) BindTransportException(org.opensearch.transport.BindTransportException)

Aggregations

IOException (java.io.IOException)1 InetAddress (java.net.InetAddress)1 InetSocketAddress (java.net.InetSocketAddress)1 CancelledKeyException (java.nio.channels.CancelledKeyException)1 ArrayList (java.util.ArrayList)1 BoundTransportAddress (org.opensearch.common.transport.BoundTransportAddress)1 TransportAddress (org.opensearch.common.transport.TransportAddress)1 BindTransportException (org.opensearch.transport.BindTransportException)1