请选择 进入手机版 | 继续访问电脑版
  • 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NamedXContentRegistry类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.common.xcontent.NamedXContentRegistry的典型用法代码示例。如果您正苦于以下问题:Java NamedXContentRegistry类的具体用法?Java NamedXContentRegistry怎么用?Java NamedXContentRegistry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NamedXContentRegistry类属于org.elasticsearch.common.xcontent包,在下文中一共展示了NamedXContentRegistry类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: URLRepository

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
/**
 * Constructs a read-only URL-based repository
 */
public URLRepository(RepositoryMetaData metadata, Environment environment,
                     NamedXContentRegistry namedXContentRegistry) throws IOException {
    super(metadata, environment.settings(), namedXContentRegistry);

    if (URL_SETTING.exists(metadata.settings()) == false && REPOSITORIES_URL_SETTING.exists(settings) ==  false) {
        throw new RepositoryException(metadata.name(), "missing url");
    }
    supportedProtocols = SUPPORTED_PROTOCOLS_SETTING.get(settings);
    urlWhiteList = ALLOWED_URLS_SETTING.get(settings).toArray(new URIPattern[]{});
    this.environment = environment;

    URL url = URL_SETTING.exists(metadata.settings()) ? URL_SETTING.get(metadata.settings()) : REPOSITORIES_URL_SETTING.get(settings);
    URL normalizedURL = checkURL(url);
    blobStore = new URLBlobStore(settings, normalizedURL);
    basePath = BlobPath.cleanPath();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:20,代码来源:URLRepository.java


示例2: setUp

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
/**
 * 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;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:25,代码来源:BaseAggregationTestCase.java


示例3: testParser

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
public void testParser() throws IOException {
    ContextParser<Void, PipelineConfiguration> parser = PipelineConfiguration.getParser();
    XContentType xContentType = randomFrom(XContentType.values());
    final BytesReference bytes;
    try (XContentBuilder builder = XContentBuilder.builder(xContentType.xContent())) {
        new PipelineConfiguration("1", new BytesArray("{}".getBytes(StandardCharsets.UTF_8)), XContentType.JSON)
            .toXContent(builder, ToXContent.EMPTY_PARAMS);
        bytes = builder.bytes();
    }

    XContentParser xContentParser = xContentType.xContent().createParser(NamedXContentRegistry.EMPTY, bytes);
    PipelineConfiguration parsed = parser.parse(xContentParser, null);
    assertEquals(xContentType, parsed.getXContentType());
    assertEquals("{}", XContentHelper.convertToJson(parsed.getConfig(), false, parsed.getXContentType()));
    assertEquals("1", parsed.getId());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:PipelineConfigurationTests.java


示例4: MapperService

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry,
                     SimilarityService similarityService, MapperRegistry mapperRegistry,
                     Supplier<QueryShardContext> queryShardContextSupplier) {
    super(indexSettings);
    this.indexAnalyzers = indexAnalyzers;
    this.fieldTypes = new FieldTypeLookup();
    this.documentParser = new DocumentMapperParser(indexSettings, this, indexAnalyzers, xContentRegistry, similarityService,
            mapperRegistry, queryShardContextSupplier);
    this.indexAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultIndexAnalyzer(), p -> p.indexAnalyzer());
    this.searchAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchAnalyzer(), p -> p.searchAnalyzer());
    this.searchQuoteAnalyzer = new MapperAnalyzerWrapper(indexAnalyzers.getDefaultSearchQuoteAnalyzer(), p -> p.searchQuoteAnalyzer());
    this.mapperRegistry = mapperRegistry;

    this.dynamic = this.indexSettings.getValue(INDEX_MAPPER_DYNAMIC_SETTING);
    defaultMappingSource = "{\"_default_\":{}}";

    if (logger.isTraceEnabled()) {
        logger.trace("using dynamic[{}], default mapping source[{}]", dynamic, defaultMappingSource);
    } else if (logger.isDebugEnabled()) {
        logger.debug("using dynamic[{}]", dynamic);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:23,代码来源:MapperService.java


示例5: RestRequest

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
/**
 * Creates a new RestRequest
 * @param xContentRegistry the xContentRegistry to use when parsing XContent
 * @param uri the URI of the request that potentially contains request parameters
 * @param headers a map of the headers. This map should implement a Case-Insensitive hashing for keys as HTTP header names are case
 *                insensitive
 */
public RestRequest(NamedXContentRegistry xContentRegistry, String uri, Map<String, List<String>> headers) {
    this.xContentRegistry = xContentRegistry;
    final Map<String, String> params = new HashMap<>();
    int pathEndPos = uri.indexOf('?');
    if (pathEndPos < 0) {
        this.rawPath = uri;
    } else {
        this.rawPath = uri.substring(0, pathEndPos);
        RestUtils.decodeQueryString(uri, pathEndPos + 1, params);
    }
    this.params = params;
    this.headers = Collections.unmodifiableMap(headers);
    final List<String> contentType = getAllHeaderValues("Content-Type");
    final XContentType xContentType = parseContentType(contentType);
    if (xContentType != null) {
        this.xContentType.set(xContentType);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:26,代码来源:RestRequest.java


示例6: MockRepository

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
public MockRepository(RepositoryMetaData metadata, Environment environment,
                      NamedXContentRegistry namedXContentRegistry) throws IOException {
    super(overrideSettings(metadata, environment), environment, namedXContentRegistry);
    randomControlIOExceptionRate = metadata.settings().getAsDouble("random_control_io_exception_rate", 0.0);
    randomDataFileIOExceptionRate = metadata.settings().getAsDouble("random_data_file_io_exception_rate", 0.0);
    useLuceneCorruptionException = metadata.settings().getAsBoolean("use_lucene_corruption", false);
    maximumNumberOfFailures = metadata.settings().getAsLong("max_failure_number", 100L);
    blockOnControlFiles = metadata.settings().getAsBoolean("block_on_control", false);
    blockOnDataFiles = metadata.settings().getAsBoolean("block_on_data", false);
    blockOnInitialization = metadata.settings().getAsBoolean("block_on_init", false);
    randomPrefix = metadata.settings().get("random", "default");
    waitAfterUnblock = metadata.settings().getAsLong("wait_after_unblock", 0L);
    atomicMove = metadata.settings().getAsBoolean("atomic_move", true);
    logger.info("starting mock repository with random prefix {}", randomPrefix);
    mockBlobStore = new MockBlobStore(super.blobStore());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:MockRepository.java


示例7: createComponents

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
@Override
public Collection<Object> createComponents(
        Client client,
        ClusterService clusterService,
        ThreadPool threadPool,
        ResourceWatcherService resourceWatcherService,
        ScriptService scriptService,
        NamedXContentRegistry xContentRegistry) {
    final int concurrentConnects = UnicastZenPing.DISCOVERY_ZEN_PING_UNICAST_CONCURRENT_CONNECTS_SETTING.get(settings);
    final ThreadFactory threadFactory = EsExecutors.daemonThreadFactory(settings, "[file_based_discovery_resolve]");
    fileBasedDiscoveryExecutorService = EsExecutors.newScaling(
        "file_based_discovery_resolve",
        0,
        concurrentConnects,
        60,
        TimeUnit.SECONDS,
        threadFactory,
        threadPool.getThreadContext());

    return Collections.emptyList();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:22,代码来源:FileBasedDiscoveryPlugin.java


示例8: writeRawField

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
@Override
public void writeRawField(String name, InputStream content, XContentType contentType) throws IOException {
    if (mayWriteRawData(contentType) == false) {
        // EMPTY is safe here because we never call namedObject when writing raw data
        try (XContentParser parser = XContentFactory.xContent(contentType).createParser(NamedXContentRegistry.EMPTY, content)) {
            parser.nextToken();
            writeFieldName(name);
            copyCurrentStructure(parser);
        }
    } else {
        writeStartRaw(name);
        flush();
        Streams.copy(content, os);
        writeEndRaw();
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:17,代码来源:JsonXContentGenerator.java


示例9: Netty4HttpRequest

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
Netty4HttpRequest(NamedXContentRegistry xContentRegistry, FullHttpRequest request, Channel channel) {
    super(xContentRegistry, request.uri(), new HttpHeadersMap(request.headers()));
    this.request = request;
    this.channel = channel;
    if (request.content().isReadable()) {
        this.content = Netty4Utils.toBytesReference(request.content());
    } else {
        this.content = BytesArray.EMPTY;
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Netty4HttpRequest.java


示例10: getHttpTransports

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
                                                                    CircuitBreakerService circuitBreakerService,
                                                                    NamedWriteableRegistry namedWriteableRegistry,
                                                                    NamedXContentRegistry xContentRegistry,
                                                                    NetworkService networkService,
                                                                    HttpServerTransport.Dispatcher dispatcher) {
    return Collections.singletonMap(NETTY_HTTP_TRANSPORT_NAME,
        () -> new Netty4HttpServerTransport(settings, networkService, bigArrays, threadPool, xContentRegistry, dispatcher));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:Netty4Plugin.java


示例11: initialSearchEntity

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
static HttpEntity initialSearchEntity(SearchRequest searchRequest, BytesReference query) {
    // EMPTY is safe here because we're not calling namedObject
    try (XContentBuilder entity = JsonXContent.contentBuilder();
            XContentParser queryParser = XContentHelper.createParser(NamedXContentRegistry.EMPTY, query)) {
        entity.startObject();

        entity.field("query"); {
            /* We're intentionally a bit paranoid here - copying the query as xcontent rather than writing a raw field. We don't want
             * poorly written queries to escape. Ever. */
            entity.copyCurrentStructure(queryParser);
            XContentParser.Token shouldBeEof = queryParser.nextToken();
            if (shouldBeEof != null) {
                throw new ElasticsearchException(
                        "query was more than a single object. This first token after the object is [" + shouldBeEof + "]");
            }
        }

        if (searchRequest.source().fetchSource() != null) {
            entity.field("_source", searchRequest.source().fetchSource());
        } else {
            entity.field("_source", true);
        }

        entity.endObject();
        BytesRef bytes = entity.bytes().toBytesRef();
        return new ByteArrayEntity(bytes.bytes, bytes.offset, bytes.length, ContentType.APPLICATION_JSON);
    } catch (IOException e) {
        throw new ElasticsearchException("unexpected error building entity", e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:31,代码来源:RemoteRequestBuilders.java


示例12: testDispatchBadRequest

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
public void testDispatchBadRequest() {
    final FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).build();
    final AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.BAD_REQUEST);
    restController.dispatchBadRequest(
            fakeRestRequest,
            channel,
            new ThreadContext(Settings.EMPTY),
            randomBoolean() ? new IllegalStateException("bad request") : new Throwable("bad request"));
    assertTrue(channel.getSendResponseCalled());
    assertThat(channel.getRestResponse().content().utf8ToString(), containsString("bad request"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:RestControllerTests.java


示例13: testWhiteListingRepoURL

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
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()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:URLRepositoryTests.java


示例14: testCorruption

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
public void testCorruption() throws IOException {
    Path[] dirs = new Path[randomIntBetween(1, 5)];
    for (int i = 0; i < dirs.length; i++) {
        dirs[i] = createTempDir();
    }
    final long id = addDummyFiles("foo-", dirs);
    Format format = new Format(randomFrom(XContentType.values()), "foo-");
    DummyState state = new DummyState(randomRealisticUnicodeOfCodepointLengthBetween(1, 1000), randomInt(), randomLong(), randomDouble(), randomBoolean());
    int version = between(0, Integer.MAX_VALUE/2);
    format.write(state, dirs);
    for (Path file : dirs) {
        Path[] list = content("*", file);
        assertEquals(list.length, 1);
        assertThat(list[0].getFileName().toString(), equalTo(MetaDataStateFormat.STATE_DIR_NAME));
        Path stateDir = list[0];
        assertThat(Files.isDirectory(stateDir), is(true));
        list = content("foo-*", stateDir);
        assertEquals(list.length, 1);
        assertThat(list[0].getFileName().toString(), equalTo("foo-" + id + ".st"));
        DummyState read = format.read(NamedXContentRegistry.EMPTY, list[0]);
        assertThat(read, equalTo(state));
        // now corrupt it
        corruptFile(list[0], logger);
        try {
            format.read(NamedXContentRegistry.EMPTY, list[0]);
            fail("corrupted file");
        } catch (CorruptStateException ex) {
            // expected
        }
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:32,代码来源:MetaDataStateFormatTests.java


示例15: RestHighLevelClient

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
/**
 * Creates a {@link RestHighLevelClient} given the low level {@link RestClient} that it should use to perform requests and
 * a list of entries that allow to parse custom response sections added to Elasticsearch through plugins.
 */
protected RestHighLevelClient(RestClient restClient, List<NamedXContentRegistry.Entry> namedXContentEntries) {
    this.client = Objects.requireNonNull(restClient);
    this.registry = new NamedXContentRegistry(Stream.of(
            getNamedXContents().stream(),
            namedXContentEntries.stream()
    ).flatMap(Function.identity()).collect(toList()));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:RestHighLevelClient.java


示例16: TransportGetTaskAction

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
@Inject
public TransportGetTaskAction(Settings settings, ThreadPool threadPool, TransportService transportService, ActionFilters actionFilters,
        IndexNameExpressionResolver indexNameExpressionResolver, ClusterService clusterService, Client client,
        NamedXContentRegistry xContentRegistry) {
    super(settings, GetTaskAction.NAME, threadPool, transportService, actionFilters, indexNameExpressionResolver, GetTaskRequest::new);
    this.clusterService = clusterService;
    this.transportService = transportService;
    this.client = client;
    this.xContentRegistry = xContentRegistry;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:TransportGetTaskAction.java


示例17: setUp

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
public void setUp() throws Exception {
    super.setUp();
    IndicesModule indicesModule = new IndicesModule(Collections.emptyList());
    searchExtPlugin = new TestSearchExtPlugin();
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.singletonList(searchExtPlugin));
    List<NamedWriteableRegistry.Entry> entries = new ArrayList<>();
    entries.addAll(indicesModule.getNamedWriteables());
    entries.addAll(searchModule.getNamedWriteables());
    namedWriteableRegistry = new NamedWriteableRegistry(entries);
    xContentRegistry = new NamedXContentRegistry(searchModule.getNamedXContents());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:AbstractSearchTestCase.java


示例18: xContentRegistry

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
@Override
protected NamedXContentRegistry xContentRegistry() {
    if (isInternalCluster() && cluster().size() > 0) {
        // If it's internal cluster - using existing registry in case plugin registered custom data
        return internalCluster().getInstance(NamedXContentRegistry.class);
    } else {
        // If it's external cluster - fall back to the standard set
        return new NamedXContentRegistry(ClusterModule.getNamedXWriteables());
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:11,代码来源:ESIntegTestCase.java


示例19: init

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
/**
 * 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());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:SuggestBuilderTests.java


示例20: FakeRestRequest

import org.elasticsearch.common.xcontent.NamedXContentRegistry; //导入依赖的package包/类
private FakeRestRequest(NamedXContentRegistry xContentRegistry, Map<String, List<String>> headers, Map<String, String> params,
                        BytesReference content, Method method, String path, SocketAddress remoteAddress) {
    super(xContentRegistry, params, path, headers);
    this.content = content;
    this.method = method;
    this.remoteAddress = remoteAddress;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:8,代码来源:FakeRestRequest.java



注:本文中的org.elasticsearch.common.xcontent.NamedXContentRegistry类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XStorable类代码示例发布时间:2022-05-21
下一篇:
Java ProcessingInstruction类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap