Search in sources :

Example 1 with NullDispatcher

use of org.opensearch.http.NullDispatcher in project OpenSearch by opensearch-project.

the class Netty4HttpServerTransportTests method testBindUnavailableAddress.

public void testBindUnavailableAddress() {
    Settings initialSettings = createSettings();
    try (Netty4HttpServerTransport transport = new Netty4HttpServerTransport(initialSettings, networkService, bigArrays, threadPool, xContentRegistry(), new NullDispatcher(), clusterSettings, new SharedGroupFactory(Settings.EMPTY))) {
        transport.start();
        TransportAddress remoteAddress = randomFrom(transport.boundAddress().boundAddresses());
        Settings settings = Settings.builder().put("http.port", remoteAddress.getPort()).put("network.host", remoteAddress.getAddress()).build();
        try (Netty4HttpServerTransport otherTransport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool, xContentRegistry(), new NullDispatcher(), clusterSettings, new SharedGroupFactory(settings))) {
            BindHttpException bindHttpException = expectThrows(BindHttpException.class, otherTransport::start);
            assertEquals("Failed to bind to " + NetworkAddress.format(remoteAddress.address()), bindHttpException.getMessage());
        }
    }
}
Also used : NullDispatcher(org.opensearch.http.NullDispatcher) TransportAddress(org.opensearch.common.transport.TransportAddress) SharedGroupFactory(org.opensearch.transport.SharedGroupFactory) BindHttpException(org.opensearch.http.BindHttpException) Settings(org.opensearch.common.settings.Settings) HttpTransportSettings(org.opensearch.http.HttpTransportSettings) ClusterSettings(org.opensearch.common.settings.ClusterSettings)

Example 2 with NullDispatcher

use of org.opensearch.http.NullDispatcher in project OpenSearch by opensearch-project.

the class NioHttpServerTransportTests method testBindUnavailableAddress.

public void testBindUnavailableAddress() {
    final Settings initialSettings = createSettings();
    try (NioHttpServerTransport transport = new NioHttpServerTransport(initialSettings, networkService, bigArrays, pageRecycler, threadPool, xContentRegistry(), new NullDispatcher(), new NioGroupFactory(Settings.EMPTY, logger), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS))) {
        transport.start();
        TransportAddress remoteAddress = randomFrom(transport.boundAddress().boundAddresses());
        Settings settings = Settings.builder().put("http.port", remoteAddress.getPort()).put("network.host", remoteAddress.getAddress()).build();
        try (NioHttpServerTransport otherTransport = new NioHttpServerTransport(settings, networkService, bigArrays, pageRecycler, threadPool, xContentRegistry(), new NullDispatcher(), new NioGroupFactory(Settings.EMPTY, logger), new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS))) {
            BindHttpException bindHttpException = expectThrows(BindHttpException.class, () -> otherTransport.start());
            assertEquals("Failed to bind to " + NetworkAddress.format(remoteAddress.address()), bindHttpException.getMessage());
        }
    }
}
Also used : NullDispatcher(org.opensearch.http.NullDispatcher) ClusterSettings(org.opensearch.common.settings.ClusterSettings) TransportAddress(org.opensearch.common.transport.TransportAddress) NioGroupFactory(org.opensearch.transport.nio.NioGroupFactory) BindHttpException(org.opensearch.http.BindHttpException) Settings(org.opensearch.common.settings.Settings) HttpTransportSettings(org.opensearch.http.HttpTransportSettings) ClusterSettings(org.opensearch.common.settings.ClusterSettings)

Aggregations

ClusterSettings (org.opensearch.common.settings.ClusterSettings)2 Settings (org.opensearch.common.settings.Settings)2 TransportAddress (org.opensearch.common.transport.TransportAddress)2 BindHttpException (org.opensearch.http.BindHttpException)2 HttpTransportSettings (org.opensearch.http.HttpTransportSettings)2 NullDispatcher (org.opensearch.http.NullDispatcher)2 SharedGroupFactory (org.opensearch.transport.SharedGroupFactory)1 NioGroupFactory (org.opensearch.transport.nio.NioGroupFactory)1