org.apache.lucene.index.IndexFormatTooOldException#org.elasticsearch.common.xcontent.NamedXContentRegistry源码实例Demo

下面列出了org.apache.lucene.index.IndexFormatTooOldException#org.elasticsearch.common.xcontent.NamedXContentRegistry 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
        CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry,
        NamedXContentRegistry xContentRegistry, NetworkService networkService, Dispatcher dispatcher) {
    
    final Map<String, Supplier<HttpServerTransport>> httpTransports = new HashMap<String, Supplier<HttpServerTransport>>(1);
    if (!client && httpSSLEnabled) {
        
        final ValidatingDispatcher validatingDispatcher = new ValidatingDispatcher(threadPool.getThreadContext(), dispatcher, settings, configPath, NOOP_SSL_EXCEPTION_HANDLER);
        final OpenDistroSecuritySSLNettyHttpServerTransport sgsnht = new OpenDistroSecuritySSLNettyHttpServerTransport(settings, networkService, bigArrays, threadPool, odsks, xContentRegistry, validatingDispatcher, NOOP_SSL_EXCEPTION_HANDLER);
        
        httpTransports.put("com.amazon.opendistroforelasticsearch.security.ssl.http.netty.OpenDistroSecuritySSLNettyHttpServerTransport", () -> sgsnht);
        
    }
    return httpTransports;
}
 
源代码2 项目: crate   文件: GeoUtils.java
/**
 * Parses the value as a geopoint. The following types of values are supported:
 * <p>
 * Object: has to contain either lat and lon or geohash fields
 * <p>
 * String: expected to be in "latitude, longitude" format or a geohash
 * <p>
 * Array: two or more elements, the first element is longitude, the second is latitude, the rest is ignored if ignoreZValue is true
 */
public static GeoPoint parseGeoPoint(Object value, final boolean ignoreZValue) throws ElasticsearchParseException {
    try {
        XContentBuilder content = JsonXContent.contentBuilder();
        content.startObject();
        content.field("null_value", value);
        content.endObject();

        try (InputStream stream = BytesReference.bytes(content).streamInput();
             XContentParser parser = JsonXContent.JSON_XCONTENT.createParser(
                 NamedXContentRegistry.EMPTY, LoggingDeprecationHandler.INSTANCE, stream)) {
            parser.nextToken(); // start object
            parser.nextToken(); // field name
            parser.nextToken(); // field value
            return parseGeoPoint(parser, new GeoPoint(), ignoreZValue);
        }

    } catch (IOException ex) {
        throw new ElasticsearchParseException("error parsing geopoint", ex);
    }
}
 
源代码3 项目: anomaly-detection   文件: ParseUtils.java
public static SearchSourceBuilder generatePreviewQuery(
    AnomalyDetector detector,
    List<Entry<Long, Long>> ranges,
    NamedXContentRegistry xContentRegistry
) throws IOException {

    DateRangeAggregationBuilder dateRangeBuilder = dateRange("date_range").field(detector.getTimeField()).format("epoch_millis");
    for (Entry<Long, Long> range : ranges) {
        dateRangeBuilder.addRange(range.getKey(), range.getValue());
    }

    if (detector.getFeatureAttributes() != null) {
        for (Feature feature : detector.getFeatureAttributes()) {
            AggregatorFactories.Builder internalAgg = parseAggregators(
                feature.getAggregation().toString(),
                xContentRegistry,
                feature.getId()
            );
            dateRangeBuilder.subAggregation(internalAgg.getAggregatorFactories().iterator().next());
        }
    }

    return new SearchSourceBuilder().query(detector.getFilterQuery()).size(0).aggregation(dateRangeBuilder);
}
 
源代码4 项目: anomaly-detection   文件: ParseUtils.java
public static String generateInternalFeatureQueryTemplate(AnomalyDetector detector, NamedXContentRegistry xContentRegistry)
    throws IOException {
    RangeQueryBuilder rangeQuery = new RangeQueryBuilder(detector.getTimeField())
        .from("{{" + QUERY_PARAM_PERIOD_START + "}}")
        .to("{{" + QUERY_PARAM_PERIOD_END + "}}");

    BoolQueryBuilder internalFilterQuery = QueryBuilders.boolQuery().must(rangeQuery).must(detector.getFilterQuery());

    SearchSourceBuilder internalSearchSourceBuilder = new SearchSourceBuilder().query(internalFilterQuery);
    if (detector.getFeatureAttributes() != null) {
        for (Feature feature : detector.getFeatureAttributes()) {
            AggregatorFactories.Builder internalAgg = parseAggregators(
                feature.getAggregation().toString(),
                xContentRegistry,
                feature.getId()
            );
            internalSearchSourceBuilder.aggregation(internalAgg.getAggregatorFactories().iterator().next());
        }
    }

    return internalSearchSourceBuilder.toString();
}
 
源代码5 项目: crate   文件: MetaDataIndexUpgradeService.java
public MetaDataIndexUpgradeService(Settings settings,
                                   NamedXContentRegistry xContentRegistry,
                                   MapperRegistry mapperRegistry,
                                   IndexScopedSettings indexScopedSettings,
                                   Collection<UnaryOperator<IndexMetaData>> indexMetaDataUpgraders) {
    this.settings = settings;
    this.xContentRegistry = xContentRegistry;
    this.mapperRegistry = mapperRegistry;
    this.indexScopedSettings = indexScopedSettings;
    this.upgraders = indexMetaData -> {
        IndexMetaData newIndexMetaData = indexMetaData;
        for (UnaryOperator<IndexMetaData> upgrader : indexMetaDataUpgraders) {
            newIndexMetaData = upgrader.apply(newIndexMetaData);
        }
        return newIndexMetaData;
    };
}
 
源代码6 项目: crate   文件: PartitionedTableIntegrationTest.java
@Test
@UseRandomizedSchema(random = false)
public void testAlterTableAddColumnOnPartitionedTableWithoutPartitions() throws Exception {
    execute("create table t (id int primary key, date timestamp with time zone primary key) " +
            "partitioned by (date) " +
            "clustered into 1 shards " +
            "with (number_of_replicas=0)");
    ensureYellow();

    execute("alter table t add column name string");
    execute("alter table t add column ft_name string index using fulltext");
    ensureYellow();

    execute("select * from t");
    assertThat(Arrays.asList(response.cols()), Matchers.containsInAnyOrder("date", "ft_name", "id", "name"));

    GetIndexTemplatesResponse templatesResponse = client().admin().indices().getTemplates(new GetIndexTemplatesRequest(".partitioned.t.")).actionGet();
    IndexTemplateMetaData metaData = templatesResponse.getIndexTemplates().get(0);
    String mappingSource = metaData.mappings().get(DEFAULT_MAPPING_TYPE).toString();
    Map mapping = (Map) XContentFactory.xContent(mappingSource)
        .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, mappingSource)
        .map()
        .get(DEFAULT_MAPPING_TYPE);
    assertNotNull(((Map) mapping.get("properties")).get("name"));
    assertNotNull(((Map) mapping.get("properties")).get("ft_name"));
}
 
源代码7 项目: crate   文件: Netty4Plugin.java
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays,
                                                                    CircuitBreakerService circuitBreakerService,
                                                                    NamedWriteableRegistry namedWriteableRegistry,
                                                                    NamedXContentRegistry xContentRegistry,
                                                                    NetworkService networkService,
                                                                    NodeClient nodeClient) {
    return Collections.singletonMap(
        NETTY_HTTP_TRANSPORT_NAME,
        () -> new Netty4HttpServerTransport(
            settings,
            networkService,
            bigArrays,
            threadPool,
            xContentRegistry,
            pipelineRegistry,
            nodeClient
        )
    );
}
 
@Override
public Collection<Object> createComponents(Client client,
                                           ClusterService clusterService,
                                           ThreadPool threadPool,
                                           ResourceWatcherService resourceWatcherService,
                                           ScriptService scriptService,
                                           NamedXContentRegistry xContentRegistry,
                                           Environment environment,
                                           NodeEnvironment nodeEnvironment,
                                           NamedWriteableRegistry namedWriteableRegistry,
                                           IndexNameExpressionResolver indexNameExpressionResolver) {
    clusterService.addListener(event -> {
        for (Index i : event.indicesDeleted()) {
            if (IndexFeatureStore.isIndexStore(i.getName())) {
                caches.evict(i.getName());
            }
        }
    });
    return asList(caches, parserFactory);
}
 
@Override
public NaiveAdditiveDecisionTree parse(FeatureSet set, String model) {
    XGBoostDefinition modelDefinition;
    try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
            LoggingDeprecationHandler.INSTANCE, model)
    ) {
        modelDefinition = XGBoostDefinition.parse(parser, set);
    } catch (IOException e) {
        throw new IllegalArgumentException("Cannot parse model", e);
    }

    Node[] trees = modelDefinition.getTrees(set);
    float[] weights = new float[trees.length];
    // Tree weights are already encoded in outputs
    Arrays.fill(weights, 1F);
    return new NaiveAdditiveDecisionTree(trees, weights, set.size(), modelDefinition.normalizer);
}
 
源代码10 项目: crate   文件: AzureRepository.java
public AzureRepository(RepositoryMetaData metadata,
                       Environment environment,
                       NamedXContentRegistry namedXContentRegistry,
                       AzureStorageService storageService,
                       ThreadPool threadPool) {
    super(metadata, environment.settings(), namedXContentRegistry, threadPool, buildBasePath(metadata));
    this.chunkSize = Repository.CHUNK_SIZE_SETTING.get(metadata.settings());
    this.storageService = storageService;

    // If the user explicitly did not define a readonly value, we set it by ourselves depending on the location mode setting.
    // For secondary_only setting, the repository should be read only
    final LocationMode locationMode = Repository.LOCATION_MODE_SETTING.get(metadata.settings());
    if (Repository.READONLY_SETTING.exists(metadata.settings())) {
        this.readonly = Repository.READONLY_SETTING.get(metadata.settings());
    } else {
        this.readonly = locationMode == LocationMode.SECONDARY_ONLY;
    }
}
 
源代码11 项目: crate   文件: MetaDataStateFormat.java
/**
 * Tries to load the latest state from the given data-locations.
 *
 * @param logger        a logger instance.
 * @param dataLocations the data-locations to try.
 * @return tuple of the latest state and generation. (-1, null) if no state is found.
 */
public Tuple<T, Long> loadLatestStateWithGeneration(Logger logger, NamedXContentRegistry namedXContentRegistry, Path... dataLocations)
        throws IOException {
    long generation = findMaxGenerationId(prefix, dataLocations);
    T state = loadGeneration(logger, namedXContentRegistry, generation, dataLocations);

    if (generation > -1 && state == null) {
        throw new IllegalStateException(
            "unable to find state files with generation id " + generation +
            " returned by findMaxGenerationId function, in data folders [" +
            Arrays.stream(dataLocations)
                .map(Path::toAbsolutePath)
                .map(Object::toString)
                .collect(Collectors.joining(", ")) + "], concurrent writes?");
    }
    return Tuple.tuple(state, generation);
}
 
/**
 * Roundtrip to/from JSON.
 */
protected static void checkJsonSerialization(ClusteringActionResponse result) throws IOException {
   XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
   builder.startObject();
   result.toXContent(builder, ToXContent.EMPTY_PARAMS);
   builder.endObject();
   String json = Strings.toString(builder);

   try (XContentParser parser = JsonXContent.jsonXContent.createParser(NamedXContentRegistry.EMPTY,
       DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json)) {
      Map<String, Object> mapAndClose = parser.map();
      Assertions.assertThat(mapAndClose)
          .as("json-result")
          .containsKey(Fields.CLUSTERS);
   }
}
 
@Inject
public TransportNodesListShardStoreMetaData(Settings settings,
                                            ThreadPool threadPool,
                                            ClusterService clusterService,
                                            TransportService transportService,
                                            IndicesService indicesService,
                                            NodeEnvironment nodeEnv,
                                            IndexNameExpressionResolver indexNameExpressionResolver,
                                            NamedXContentRegistry namedXContentRegistry) {
    super(ACTION_NAME, threadPool, clusterService, transportService, indexNameExpressionResolver,
        Request::new, NodeRequest::new, ThreadPool.Names.FETCH_SHARD_STORE, NodeStoreFilesMetaData.class);
    this.settings = settings;
    this.indicesService = indicesService;
    this.nodeEnv = nodeEnv;
    this.namedXContentRegistry = namedXContentRegistry;
}
 
源代码14 项目: crate   文件: JsonXContentGenerator.java
@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)
                // It's okay to pass the throwing deprecation handler
                // because we should not be writing raw fields when
                // generating JSON
                .createParser(NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, content)) {
            parser.nextToken();
            writeFieldName(name);
            copyCurrentStructure(parser);
        }
    } else {
        writeStartRaw(name);
        flush();
        copyStream(content, os);
        writeEndRaw();
    }
}
 
源代码15 项目: crate   文件: MapperTestUtils.java
public static MapperService newMapperService(NamedXContentRegistry xContentRegistry, Path tempDir, Settings settings,
                                             IndicesModule indicesModule, String indexName) throws IOException {
    Settings.Builder settingsBuilder = Settings.builder()
        .put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
        .put(settings);
    if (settings.get(IndexMetaData.SETTING_VERSION_CREATED) == null) {
        settingsBuilder.put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT);
    }
    Settings finalSettings = settingsBuilder.build();
    MapperRegistry mapperRegistry = indicesModule.getMapperRegistry();
    IndexSettings indexSettings = IndexSettingsModule.newIndexSettings(indexName, finalSettings);
    IndexAnalyzers indexAnalyzers = createTestAnalysis(indexSettings, finalSettings).indexAnalyzers;
    return new MapperService(indexSettings,
        indexAnalyzers,
        xContentRegistry,
        mapperRegistry,
        () -> null);
}
 
源代码16 项目: crate   文件: S3RepositoryPlugin.java
@Override
public Map<String, Repository.Factory> getRepositories(final Environment env, final NamedXContentRegistry registry, ThreadPool threadPool) {
    return Collections.singletonMap(
        S3Repository.TYPE,
        new Repository.Factory() {

            @Override
            public TypeSettings settings() {
                return new TypeSettings(List.of(), S3Repository.optionalSettings());
            }

            @Override
            public Repository create(RepositoryMetaData metadata) throws Exception {
                return new S3Repository(metadata, env.settings(), registry, service, threadPool);
            }
        }
    );
}
 
源代码17 项目: crate   文件: AzureDiscoveryPlugin.java
@Override
public Collection<Object> createComponents(Client client,
                                           ClusterService clusterService,
                                           ThreadPool threadPool,
                                           NamedXContentRegistry xContentRegistry,
                                           Environment environment,
                                           NodeEnvironment nodeEnvironment,
                                           NamedWriteableRegistry namedWriteableRegistry) {
    if (AzureConfiguration.isDiscoveryReady(settings, logger)) {
        return Collections.singletonList(azureComputeService());
    }
    return Collections.emptyList();
}
 
@Override
public void handleSearchContext(SearchContext context, ThreadPool threadPool, NamedXContentRegistry namedXContentRegistry) {
    try {
        final Map<String, Set<String>> queries = (Map<String, Set<String>>) HeaderHelper.deserializeSafeFromHeader(threadPool.getThreadContext(),
                ConfigConstants.OPENDISTRO_SECURITY_DLS_QUERY_HEADER);

        final String dlsEval = OpenDistroSecurityUtils.evalMap(queries, context.indexShard().indexSettings().getIndex().getName());

        if (dlsEval != null) {

            if(context.suggest() != null) {
                return;
            }

            assert context.parsedQuery() != null;

            final Set<String> unparsedDlsQueries = queries.get(dlsEval);
            if (unparsedDlsQueries != null && !unparsedDlsQueries.isEmpty()) {
                final ParsedQuery dlsQuery = DlsQueryParser.parse(unparsedDlsQueries, context.parsedQuery(), context.getQueryShardContext(), namedXContentRegistry);
                context.parsedQuery(dlsQuery);
                context.preProcess(true);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException("Error evaluating dls for a search query: " + e, e);
    }

}
 
源代码19 项目: crate   文件: S3RepositoryTests.java
private S3Repository createS3Repo(RepositoryMetaData metadata) {
    return new S3Repository(metadata, Settings.EMPTY, NamedXContentRegistry.EMPTY, new DummyS3Service(), mock(ThreadPool.class)) {
        @Override
        protected void assertSnapshotOrGenericThread() {
            // eliminate thread name check as we create repo manually on test/main threads
        }
    };
}
 
源代码20 项目: crate   文件: Netty4Plugin.java
@Override
public Collection<Object> createComponents(Client client,
                                           ClusterService clusterService,
                                           ThreadPool threadPool,
                                           NamedXContentRegistry xContentRegistry,
                                           Environment environment,
                                           NodeEnvironment nodeEnvironment,
                                           NamedWriteableRegistry namedWriteableRegistry) {
    // pipelineRegistry is returned here so that it's bound in guice and can be injected in other places
    return Collections.singletonList(pipelineRegistry);
}
 
public AnomalyDetectorProfileRunner(
    Client client,
    NamedXContentRegistry xContentRegistry,
    DiscoveryNodeFilterer nodeFilter,
    IndexNameExpressionResolver indexNameExpressionResolver,
    ClusterService clusterService,
    Calendar calendar
) {
    this.client = client;
    this.xContentRegistry = xContentRegistry;
    this.nodeFilter = nodeFilter;
    this.indexNameExpressionResolver = indexNameExpressionResolver;
    this.clusterService = clusterService;
    this.calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
}
 
源代码22 项目: anomaly-detection   文件: ParseUtils.java
public static SearchSourceBuilder generateInternalFeatureQuery(
    AnomalyDetector detector,
    long startTime,
    long endTime,
    NamedXContentRegistry xContentRegistry
) throws IOException {
    RangeQueryBuilder rangeQuery = new RangeQueryBuilder(detector.getTimeField())
        .from(startTime)
        .to(endTime)
        .format("epoch_millis")
        .includeLower(true)
        .includeUpper(false);

    BoolQueryBuilder internalFilterQuery = QueryBuilders.boolQuery().must(rangeQuery).must(detector.getFilterQuery());

    SearchSourceBuilder internalSearchSourceBuilder = new SearchSourceBuilder().query(internalFilterQuery);
    if (detector.getFeatureAttributes() != null) {
        for (Feature feature : detector.getFeatureAttributes()) {
            AggregatorFactories.Builder internalAgg = parseAggregators(
                feature.getAggregation().toString(),
                xContentRegistry,
                feature.getId()
            );
            internalSearchSourceBuilder.aggregation(internalAgg.getAggregatorFactories().iterator().next());
        }
    }

    return internalSearchSourceBuilder;
}
 
@Override
protected NamedXContentRegistry xContentRegistry() {
    SearchModule searchModule = new SearchModule(Settings.EMPTY, false, Collections.emptyList());
    List<NamedXContentRegistry.Entry> entries = searchModule.getNamedXContents();
    entries.addAll(Arrays.asList(AnomalyDetector.XCONTENT_REGISTRY, AnomalyResult.XCONTENT_REGISTRY));
    return new NamedXContentRegistry(entries);
}
 
源代码24 项目: crate   文件: MetaDataStateFormat.java
/**
 * Reads the state from a given file and compares the expected version against the actual version of
 * the state.
 */
public final T read(NamedXContentRegistry namedXContentRegistry, Path file) throws IOException {
    try (Directory dir = newDirectory(file.getParent())) {
        try (IndexInput indexInput = dir.openInput(file.getFileName().toString(), IOContext.DEFAULT)) {
            // We checksum the entire file before we even go and parse it. If it's corrupted we barf right here.
            CodecUtil.checksumEntireFile(indexInput);
            CodecUtil.checkHeader(indexInput, STATE_FILE_CODEC, MIN_COMPATIBLE_STATE_FILE_VERSION, STATE_FILE_VERSION);
            final XContentType xContentType = XContentType.values()[indexInput.readInt()];
            if (xContentType != FORMAT) {
                throw new IllegalStateException("expected state in " + file + " to be " + FORMAT + " format but was " + xContentType);
            }
            long filePointer = indexInput.getFilePointer();
            long contentSize = indexInput.length() - CodecUtil.footerLength() - filePointer;
            try (IndexInput slice = indexInput.slice("state_xcontent", filePointer, contentSize)) {
                try (InputStreamIndexInput in = new InputStreamIndexInput(slice, contentSize)) {
                    try (XContentParser parser = XContentFactory.xContent(FORMAT)
                            .createParser(namedXContentRegistry, LoggingDeprecationHandler.INSTANCE,
                                in)) {
                        return fromXContent(parser);
                    }
                }
            }
        } catch (CorruptIndexException | IndexFormatTooOldException | IndexFormatTooNewException ex) {
            // we trick this into a dedicated exception with the original stacktrace
            throw new CorruptStateException(ex);
        }
    }
}
 
源代码25 项目: crate   文件: EnterpriseUsersExtension.java
@Override
public List<NamedXContentRegistry.Entry> getNamedXContent() {
    List<NamedXContentRegistry.Entry> entries = new ArrayList<>(2);
    entries.add(new NamedXContentRegistry.Entry(
        MetaData.Custom.class,
        new ParseField(UsersMetaData.TYPE),
        UsersMetaData::fromXContent
    ));
    entries.add(new NamedXContentRegistry.Entry(
        MetaData.Custom.class,
        new ParseField(UsersPrivilegesMetaData.TYPE),
        UsersPrivilegesMetaData::fromXContent
    ));
    return entries;
}
 
源代码26 项目: crate   文件: TransportCreatePartitionsAction.java
@Inject
public TransportCreatePartitionsAction(TransportService transportService,
                                       ClusterService clusterService,
                                       ThreadPool threadPool,
                                       IndicesService indicesService,
                                       AllocationService allocationService,
                                       NamedXContentRegistry xContentRegistry,
                                       IndexNameExpressionResolver indexNameExpressionResolver) {
    super(NAME, transportService, clusterService, threadPool, CreatePartitionsRequest::new, indexNameExpressionResolver);
    this.indicesService = indicesService;
    this.allocationService = allocationService;
    this.xContentRegistry = xContentRegistry;
    this.activeShardsObserver = new ActiveShardsObserver(clusterService, threadPool);
}
 
源代码27 项目: crate   文件: ShardPath.java
/**
 * This method walks through the nodes shard paths to find the data and state path for the given shard. If multiple
 * directories with a valid shard state exist the one with the highest version will be used.
 * <b>Note:</b> this method resolves custom data locations for the shard.
 */
public static ShardPath loadShardPath(Logger logger, ShardId shardId, IndexSettings indexSettings, Path[] availableShardPaths,
                                       int nodeLockId, Path sharedDataPath) throws IOException {
    final String indexUUID = indexSettings.getUUID();
    Path loadedPath = null;
    for (Path path : availableShardPaths) {
        // EMPTY is safe here because we never call namedObject
        ShardStateMetaData load = ShardStateMetaData.FORMAT.loadLatestState(logger, NamedXContentRegistry.EMPTY, path);
        if (load != null) {
            if (load.indexUUID.equals(indexUUID) == false && IndexMetaData.INDEX_UUID_NA_VALUE.equals(load.indexUUID) == false) {
                logger.warn("{} found shard on path: [{}] with a different index UUID - this "
                    + "shard seems to be leftover from a different index with the same name. "
                    + "Remove the leftover shard in order to reuse the path with the current index", shardId, path);
                throw new IllegalStateException(shardId + " index UUID in shard state was: " + load.indexUUID
                    + " expected: " + indexUUID + " on shard path: " + path);
            }
            if (loadedPath == null) {
                loadedPath = path;
            } else {
                throw new IllegalStateException(shardId + " more than one shard state found");
            }
        }

    }
    if (loadedPath == null) {
        return null;
    } else {
        final Path dataPath;
        final Path statePath = loadedPath;
        if (indexSettings.hasCustomDataPath()) {
            dataPath = NodeEnvironment.resolveCustomLocation(indexSettings, shardId, sharedDataPath, nodeLockId);
        } else {
            dataPath = statePath;
        }
        logger.debug("{} loaded data path [{}], state path [{}]", shardId, dataPath, statePath);
        return new ShardPath(indexSettings.hasCustomDataPath(), dataPath, statePath, shardId);
    }
}
 
源代码28 项目: crate   文件: TestingHelpers.java
public static Map<String, Object> jsonMap(String json) {
    try {
        return JsonXContent.JSON_XCONTENT.createParser(
            NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, json).map();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
源代码29 项目: crate   文件: TranslogHandler.java
public TranslogHandler(NamedXContentRegistry xContentRegistry, IndexSettings indexSettings) {
    NamedAnalyzer defaultAnalyzer = new NamedAnalyzer("default", AnalyzerScope.INDEX, new StandardAnalyzer());
    IndexAnalyzers indexAnalyzers =
            new IndexAnalyzers(indexSettings, defaultAnalyzer, defaultAnalyzer, defaultAnalyzer, emptyMap(), emptyMap(), emptyMap());
    MapperRegistry mapperRegistry = new IndicesModule(emptyList()).getMapperRegistry();
    mapperService = new MapperService(indexSettings, indexAnalyzers, xContentRegistry, mapperRegistry,
            () -> null);
}
 
源代码30 项目: crate   文件: DocumentMapperParser.java
public DocumentMapperParser(IndexSettings indexSettings, MapperService mapperService, IndexAnalyzers indexAnalyzers,
                            NamedXContentRegistry xContentRegistry, MapperRegistry mapperRegistry,
                            Supplier<QueryShardContext> queryShardContextSupplier) {
    this.mapperService = mapperService;
    this.indexAnalyzers = indexAnalyzers;
    this.xContentRegistry = xContentRegistry;
    this.queryShardContextSupplier = queryShardContextSupplier;
    this.typeParsers = mapperRegistry.getMapperParsers();
    this.rootTypeParsers = mapperRegistry.getMetadataMapperParsers();
    indexVersionCreated = indexSettings.getIndexVersionCreated();
}