Search in sources :

Example 16 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class URLRepositoryTests method testMustBeSupportedProtocol.

public void testMustBeSupportedProtocol() throws IOException {
    Path directory = createTempDir();
    String repoPath = directory.resolve("repository").toUri().toURL().toString();
    Settings baseSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).put(Environment.PATH_REPO_SETTING.getKey(), directory.toString()).put(URLRepository.REPOSITORIES_URL_SETTING.getKey(), repoPath).put(URLRepository.SUPPORTED_PROTOCOLS_SETTING.getKey(), "http,https").build();
    RepositoryMetaData repositoryMetaData = new RepositoryMetaData("url", URLRepository.TYPE, baseSettings);
    try {
        new URLRepository(repositoryMetaData, new Environment(baseSettings), new NamedXContentRegistry(Collections.emptyList()));
        fail("RepositoryException should have been thrown.");
    } catch (RepositoryException e) {
        assertEquals("[url] unsupported url protocol [file] from URL [" + repoPath + "]", e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) Environment(org.elasticsearch.env.Environment) RepositoryException(org.elasticsearch.repositories.RepositoryException) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings)

Example 17 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class Netty4HttpChannelTests method testReleaseOnSendToClosedChannel.

public void testReleaseOnSendToClosedChannel() {
    final Settings settings = Settings.builder().build();
    final NamedXContentRegistry registry = xContentRegistry();
    try (Netty4HttpServerTransport httpServerTransport = new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool, registry, new NullDispatcher())) {
        final FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
        final EmbeddedChannel embeddedChannel = new EmbeddedChannel();
        final Netty4HttpRequest request = new Netty4HttpRequest(registry, httpRequest, embeddedChannel);
        final HttpPipelinedRequest pipelinedRequest = randomBoolean() ? new HttpPipelinedRequest(request.request(), 1) : null;
        final Netty4HttpChannel channel = new Netty4HttpChannel(httpServerTransport, request, pipelinedRequest, randomBoolean(), threadPool.getThreadContext());
        final TestResponse response = new TestResponse(bigArrays);
        assertThat(response.content(), instanceOf(Releasable.class));
        embeddedChannel.close();
        channel.sendResponse(response);
    // ESTestCase#after will invoke ensureAllArraysAreReleased which will fail if the response content was not released
    }
}
Also used : NullDispatcher(org.elasticsearch.http.NullDispatcher) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) HttpPipelinedRequest(org.elasticsearch.http.netty4.pipelining.HttpPipelinedRequest) Releasable(org.elasticsearch.common.lease.Releasable) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings) HttpTransportSettings(org.elasticsearch.http.HttpTransportSettings)

Example 18 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class AbstractSuggestionBuilderTestCase method init.

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

Example 19 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class SortBuilderTests method init.

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

Example 20 with NamedXContentRegistry

use of org.graylog.shaded.elasticsearch7.org.elasticsearch.common.xcontent.NamedXContentRegistry in project elasticsearch by elastic.

the class CollapseBuilderTests method init.

@BeforeClass
public static void init() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, emptyList());
    namedWriteableRegistry = new NamedWriteableRegistry(searchModule.getNamedWriteables());
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) BeforeClass(org.junit.BeforeClass)

Aggregations

NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)24 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)14 Settings (org.elasticsearch.common.settings.Settings)12 SearchModule (org.elasticsearch.search.SearchModule)12 BeforeClass (org.junit.BeforeClass)8 ArrayList (java.util.ArrayList)4 BigArrays (org.elasticsearch.common.util.BigArrays)4 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)4 NetworkPlugin (org.elasticsearch.plugins.NetworkPlugin)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 Environment (org.elasticsearch.env.Environment)3 HttpServerTransport (org.elasticsearch.http.HttpServerTransport)3 ThreadPool (org.elasticsearch.threadpool.ThreadPool)3 Path (java.nio.file.Path)2 RepositoryMetaData (org.elasticsearch.cluster.metadata.RepositoryMetaData)2 IndicesModule (org.elasticsearch.indices.IndicesModule)2 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)2 Transport (org.elasticsearch.transport.Transport)2 UserDefinedFunctionsMetadata (io.crate.expression.udf.UserDefinedFunctionsMetadata)1