Search in sources :

Example 1 with NamedXContentRegistry

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

the class SuggestBuilderTests method init.

/**
     * Setup for the whole base test class.
     */
@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)

Example 2 with NamedXContentRegistry

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

the class URLRepositoryTests method testWhiteListingRepoURL.

public void testWhiteListingRepoURL() throws IOException {
    String repoPath = createTempDir().resolve("repository").toUri().toURL().toString();
    Settings baseSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).put(URLRepository.ALLOWED_URLS_SETTING.getKey(), repoPath).put(URLRepository.REPOSITORIES_URL_SETTING.getKey(), repoPath).build();
    RepositoryMetaData repositoryMetaData = new RepositoryMetaData("url", URLRepository.TYPE, baseSettings);
    new URLRepository(repositoryMetaData, new Environment(baseSettings), new NamedXContentRegistry(Collections.emptyList()));
}
Also used : RepositoryMetaData(org.elasticsearch.cluster.metadata.RepositoryMetaData) Environment(org.elasticsearch.env.Environment) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings)

Example 3 with NamedXContentRegistry

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

the class URLRepositoryTests method testIfNotWhiteListedMustSetRepoURL.

public void testIfNotWhiteListedMustSetRepoURL() throws IOException {
    String repoPath = createTempDir().resolve("repository").toUri().toURL().toString();
    Settings baseSettings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).put(URLRepository.REPOSITORIES_URL_SETTING.getKey(), repoPath).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) {
        String msg = "[url] file url [" + repoPath + "] doesn't match any of the locations specified by path.repo or repositories.url.allowed_urls";
        assertEquals(msg, e.getMessage());
    }
}
Also used : 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 4 with NamedXContentRegistry

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

the class NetworkModuleTests method testOverrideDefault.

public void testOverrideDefault() {
    Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom").put(NetworkModule.HTTP_DEFAULT_TYPE_SETTING.getKey(), "default_custom").put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), "local").put(NetworkModule.TRANSPORT_TYPE_KEY, "default_custom").build();
    // content doesn't matter we check reference equality
    Supplier<Transport> customTransport = () -> null;
    Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
    Supplier<HttpServerTransport> def = FakeHttpTransport::new;
    NetworkModule module = newNetworkModule(settings, false, new NetworkPlugin() {

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

Example 5 with NamedXContentRegistry

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

the class BaseAggregationTestCase method setUp.

/**
     * Setup for the whole base test class.
     */
@Override
public void setUp() throws Exception {
    super.setUp();
    Settings settings = Settings.builder().put("node.name", AbstractQueryTestCase.class.toString()).put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).build();
    IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
    SearchModule searchModule = new SearchModule(settings, false, emptyList());
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
    entries.addAll(indicesModule.getNamedWriteables());
    entries.addAll(searchModule.getNamedWriteables());
    namedWriteableRegistry = new NamedWriteableRegistry(entries);
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
    //create some random type with some default field, those types will stick around for all of the subclasses
    currentTypes = new String[randomIntBetween(0, 5)];
    for (int i = 0; i < currentTypes.length; i++) {
        String type = randomAsciiOfLengthBetween(1, 10);
        currentTypes[i] = type;
    }
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) IndicesModule(org.elasticsearch.indices.IndicesModule) ArrayList(java.util.ArrayList) SearchModule(org.elasticsearch.search.SearchModule) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings) AbstractQueryTestCase(org.elasticsearch.test.AbstractQueryTestCase)

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