Search in sources :

Example 21 with NamedXContentRegistry

use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.

the class NetworkModuleTests method testDefaultKeys.

public void testDefaultKeys() {
    Settings settings = Settings.builder().put(NetworkModule.HTTP_DEFAULT_TYPE_SETTING.getKey(), "default_custom").put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), "default_custom").build();
    Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
    Supplier<HttpServerTransport> def = FakeHttpTransport::new;
    Supplier<Transport> customTransport = () -> null;
    NetworkModule module = newNetworkModule(settings, new NetworkPlugin() {

        @Override
        public Map<String, Supplier<Transport>> getTransports(Settings settings, ThreadPool threadPool, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) {
            return Collections.singletonMap("default_custom", customTransport);
        }

        @Override
        public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, PageCacheRecycler pageCacheRecycler, CircuitBreakerService circuitBreakerService, NamedXContentRegistry xContentRegistry, NetworkService networkService, HttpServerTransport.Dispatcher requestDispatcher, ClusterSettings clusterSettings) {
            Map<String, Supplier<HttpServerTransport>> supplierMap = new HashMap<>();
            supplierMap.put("custom", custom);
            supplierMap.put("default_custom", def);
            return supplierMap;
        }
    });
    assertSame(def, module.getHttpServerTransportSupplier());
    assertSame(customTransport, module.getTransportSupplier());
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) NetworkPlugin(org.opensearch.plugins.NetworkPlugin) ClusterSettings(org.opensearch.common.settings.ClusterSettings) ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) HttpServerTransport(org.opensearch.http.HttpServerTransport) BigArrays(org.opensearch.common.util.BigArrays) PageCacheRecycler(org.opensearch.common.util.PageCacheRecycler) Transport(org.opensearch.transport.Transport) HttpServerTransport(org.opensearch.http.HttpServerTransport) CircuitBreakerService(org.opensearch.indices.breaker.CircuitBreakerService) HashMap(java.util.HashMap) Map(java.util.Map) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ClusterSettings(org.opensearch.common.settings.ClusterSettings) Settings(org.opensearch.common.settings.Settings)

Example 22 with NamedXContentRegistry

use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.

the class QueryRescorerBuilderTests method init.

/**
 * setup for the whole base test class
 */
@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.opensearch.search.SearchModule) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 23 with NamedXContentRegistry

use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.

the class AbstractSuggestionBuilderTestCase method init.

/**
 * setup for the whole base test class
 */
@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.opensearch.search.SearchModule) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 24 with NamedXContentRegistry

use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.

the class SuggestBuilderTests method init.

/**
 * Setup for the whole base test class.
 */
@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.opensearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.opensearch.search.SearchModule) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Example 25 with NamedXContentRegistry

use of org.opensearch.common.xcontent.NamedXContentRegistry in project OpenSearch by opensearch-project.

the class SortBuilderTests method init.

@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, emptyList());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : SearchModule(org.opensearch.search.SearchModule) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Aggregations

NamedXContentRegistry (org.opensearch.common.xcontent.NamedXContentRegistry)32 SearchModule (org.opensearch.search.SearchModule)16 NamedWriteableRegistry (org.opensearch.common.io.stream.NamedWriteableRegistry)13 XContentParser (org.opensearch.common.xcontent.XContentParser)11 ArrayList (java.util.ArrayList)10 Map (java.util.Map)10 BeforeClass (org.junit.BeforeClass)10 Settings (org.opensearch.common.settings.Settings)10 IOException (java.io.IOException)9 HashMap (java.util.HashMap)9 List (java.util.List)8 ClusterService (org.opensearch.cluster.service.ClusterService)7 HashSet (java.util.HashSet)6 Set (java.util.Set)6 ActionListener (org.opensearch.action.ActionListener)6 ClusterState (org.opensearch.cluster.ClusterState)5 Arrays (java.util.Arrays)4 Collections (java.util.Collections)4 Collections.singletonList (java.util.Collections.singletonList)4 Objects (java.util.Objects)4