org.elasticsearch.Version Java Examples

The following examples show how to use org.elasticsearch.Version. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LicenseServiceTest.java    From crate with Apache License 2.0 6 votes vote down vote up
@Test
public void testThatMaxNumberOfNodesIsExceeded() {
    final ClusterState state = ClusterState.builder(ClusterName.DEFAULT)
        .nodes(DiscoveryNodes.builder()
            .add(new DiscoveryNode("n1", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .add(new DiscoveryNode("n2", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .add(new DiscoveryNode("n3", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .add(new DiscoveryNode("n4", buildNewFakeTransportAddress(),
                Version.CURRENT))
            .localNodeId("n1")
        )
        .build();
    LicenseData licenseData = new LicenseData(UNLIMITED_EXPIRY_DATE_IN_MS, "test", 3);

    licenseService.onUpdatedLicense(state, licenseData);
    assertThat(licenseService.isMaxNumberOfNodesExceeded(), is(true));
}
 
Example #2
Source File: TransportUpgradeStatusAction.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
protected ShardUpgradeStatus shardOperation(UpgradeStatusRequest request, ShardRouting shardRouting) {
    IndexService indexService = indicesService.indexServiceSafe(shardRouting.shardId().getIndex());
    IndexShard indexShard = indexService.shardSafe(shardRouting.shardId().id());
    List<Segment> segments = indexShard.engine().segments(false);
    long total_bytes = 0;
    long to_upgrade_bytes = 0;
    long to_upgrade_bytes_ancient = 0;
    for (Segment seg : segments) {
        total_bytes += seg.sizeInBytes;
        if (seg.version.major != Version.CURRENT.luceneVersion.major) {
            to_upgrade_bytes_ancient += seg.sizeInBytes;
            to_upgrade_bytes += seg.sizeInBytes;
        } else if (seg.version.minor != Version.CURRENT.luceneVersion.minor) {
            // TODO: this comparison is bogus! it would cause us to upgrade even with the same format
            // instead, we should check if the codec has changed
            to_upgrade_bytes += seg.sizeInBytes;
        }
    }

    return new ShardUpgradeStatus(indexShard.routingEntry(), total_bytes, to_upgrade_bytes, to_upgrade_bytes_ancient);
}
 
Example #3
Source File: IkESPluginTest.java    From es-ik with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefaultsIcuAnalysis() {
    Index index = new Index("test");

    Settings settings = ImmutableSettings.settingsBuilder()
            .put("path.home", "none")
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .build();

    Injector parentInjector = new ModulesBuilder().add(new SettingsModule(ImmutableSettings.EMPTY), new EnvironmentModule(new Environment(settings)), new IndicesAnalysisModule()).createInjector();
    Injector injector = new ModulesBuilder().add(
            new IndexSettingsModule(index, settings),
            new IndexNameModule(index),
            new AnalysisModule(ImmutableSettings.EMPTY, parentInjector.getInstance(IndicesAnalysisService.class)).addProcessor(new IKAnalysisBinderProcessor()))
            .createChildInjector(parentInjector);

    AnalysisService analysisService = injector.getInstance(AnalysisService.class);

    TokenizerFactory tokenizerFactory = analysisService.tokenizer("ik_tokenizer");
    MatcherAssert.assertThat(tokenizerFactory, instanceOf(IKTokenizerFactory.class));


}
 
Example #4
Source File: MapperTestUtils.java    From crate with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: FieldStatsRequest.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeStringArrayNullable(fields);
    out.writeVInt(indexConstraints.length);
    for (IndexConstraint indexConstraint : indexConstraints) {
        out.writeString(indexConstraint.getField());
        out.writeByte(indexConstraint.getProperty().getId());
        out.writeByte(indexConstraint.getComparison().getId());
        out.writeString(indexConstraint.getValue());
        if (out.getVersion().onOrAfter(Version.V_2_0_1)) {
            out.writeOptionalString(indexConstraint.getOptionalFormat());
        }
    }
    out.writeString(level);
}
 
Example #6
Source File: OsStats.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeVLong(timestamp);
    if (out.getVersion().onOrAfter(Version.V_2_2_0)) {
        out.writeBoolean(cpuPercent != null);
        if (cpuPercent != null) {
            out.writeShort(cpuPercent);
        }
    }
    out.writeDouble(loadAverage);
    if (mem == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        mem.writeTo(out);
    }
    if (swap == null) {
        out.writeBoolean(false);
    } else {
        out.writeBoolean(true);
        swap.writeTo(out);
    }
}
 
Example #7
Source File: MasterServiceTests.java    From crate with Apache License 2.0 6 votes vote down vote up
private TimedMasterService createTimedMasterService(boolean makeMaster) throws InterruptedException {
    DiscoveryNode localNode = new DiscoveryNode("node1", buildNewFakeTransportAddress(), emptyMap(),
        emptySet(), Version.CURRENT);
    TimedMasterService timedMasterService = new TimedMasterService(Settings.builder().put("cluster.name",
        MasterServiceTests.class.getSimpleName()).build(), threadPool);
    ClusterState initialClusterState = ClusterState.builder(new ClusterName(MasterServiceTests.class.getSimpleName()))
        .nodes(DiscoveryNodes.builder()
            .add(localNode)
            .localNodeId(localNode.getId())
            .masterNodeId(makeMaster ? localNode.getId() : null))
        .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).build();
    AtomicReference<ClusterState> clusterStateRef = new AtomicReference<>(initialClusterState);
    timedMasterService.setClusterStatePublisher((event, publishListener, ackListener) -> {
        clusterStateRef.set(event.state());
        publishListener.onResponse(null);
    });
    timedMasterService.setClusterStateSupplier(clusterStateRef::get);
    timedMasterService.start();
    return timedMasterService;
}
 
Example #8
Source File: Optimizer.java    From crate with Apache License 2.0 6 votes vote down vote up
public Optimizer(Functions functions,
                 CoordinatorTxnCtx coordinatorTxnCtx,
                 Supplier<Version> minNodeVersionInCluster,
                 List<Function<FunctionSymbolResolver, Rule<?>>> rules) {
    FunctionSymbolResolver functionResolver =
        (f, args) -> {
            try {
                return ExpressionAnalyzer.allocateFunction(
                    f,
                    args,
                    null,
                    null,
                    functions,
                    coordinatorTxnCtx
                );
            } catch (ConversionException e) {
                return null;
            }
        };

    this.rules = Lists2.map(rules, r -> r.apply(functionResolver));
    this.minNodeVersionInCluster = minNodeVersionInCluster;
    this.functions = functions;
}
 
Example #9
Source File: GeoShapeFieldMapper.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public GeoShapeFieldMapper build(BuilderContext context) {
    GeoShapeFieldType geoShapeFieldType = (GeoShapeFieldType)fieldType;

    if (geoShapeFieldType.tree.equals(Names.TREE_QUADTREE) && context.indexCreatedVersion().before(Version.V_2_0_0_beta1)) {
        geoShapeFieldType.setTree("legacyquadtree");
    }

    if (context.indexCreatedVersion().before(Version.V_2_0_0_beta1) ||
        (geoShapeFieldType.treeLevels() == 0 && geoShapeFieldType.precisionInMeters() < 0)) {
        geoShapeFieldType.setDefaultDistanceErrorPct(Defaults.LEGACY_DISTANCE_ERROR_PCT);
    }
    setupFieldType(context);

    return new GeoShapeFieldMapper(name, fieldType, coerce(context), context.indexSettings(), multiFieldsBuilder.build(this,
            context), copyTo);
}
 
Example #10
Source File: RecoverySourceHandler.java    From crate with Apache License 2.0 6 votes vote down vote up
public RecoverySourceHandler(final IndexShard shard,
                             RecoveryTargetHandler recoveryTarget,
                             final StartRecoveryRequest request,
                             final int fileChunkSizeInBytes,
                             final int maxConcurrentFileChunks) {
    this.shard = shard;
    this.recoveryTarget = recoveryTarget;
    this.request = request;
    this.shardId = this.request.shardId().id();
    this.logger = Loggers.getLogger(getClass(), request.shardId(), "recover to " + request.targetNode().getName());
    this.chunkSizeInBytes = fileChunkSizeInBytes;
    // if the target is on an old version, it won't be able to handle out-of-order file chunks.
    this.maxConcurrentFileChunks =
        request.targetNode().getVersion().onOrAfter(Version.V_4_0_0)
        ? maxConcurrentFileChunks : 1;
}
 
Example #11
Source File: TransportCreatePartitionsAction.java    From crate with Apache License 2.0 6 votes vote down vote up
private Settings createIndexSettings(ClusterState currentState, List<IndexTemplateMetaData> templates) {
    Settings.Builder indexSettingsBuilder = Settings.builder();
    // apply templates, here, in reverse order, since first ones are better matching
    for (int i = templates.size() - 1; i >= 0; i--) {
        indexSettingsBuilder.put(templates.get(i).settings());
    }
    if (indexSettingsBuilder.get(IndexMetaData.SETTING_VERSION_CREATED) == null) {
        DiscoveryNodes nodes = currentState.nodes();
        final Version createdVersion = Version.min(Version.CURRENT, nodes.getSmallestNonClientNodeVersion());
        indexSettingsBuilder.put(IndexMetaData.SETTING_VERSION_CREATED, createdVersion);
    }
    if (indexSettingsBuilder.get(IndexMetaData.SETTING_CREATION_DATE) == null) {
        indexSettingsBuilder.put(IndexMetaData.SETTING_CREATION_DATE, new DateTime(DateTimeZone.UTC).getMillis());
    }
    indexSettingsBuilder.put(IndexMetaData.SETTING_INDEX_UUID, UUIDs.randomBase64UUID());

    return indexSettingsBuilder.build();
}
 
Example #12
Source File: LuceneQueryBuilderTest.java    From crate with Apache License 2.0 6 votes vote down vote up
private Version indexVersion() {
    try {
        Class<?> clazz = this.getClass();
        Method method = clazz.getMethod(testName.getMethodName());
        IndexVersionCreated annotation = method.getAnnotation(IndexVersionCreated.class);
        if (annotation == null) {
            annotation = clazz.getAnnotation(IndexVersionCreated.class);
            if (annotation == null) {
                return Version.CURRENT;
            }
        }
        int value = annotation.value();
        if (value == -1) {
            return Version.CURRENT;
        }
        return Version.fromId(value);
    } catch (NoSuchMethodException ignored) {
        return Version.CURRENT;
    }
}
 
Example #13
Source File: VersionUtils.java    From crate with Apache License 2.0 6 votes vote down vote up
/** Returns a random {@link Version} between <code>minVersion</code> and <code>maxVersion</code> (inclusive). */
public static Version randomVersionBetween(Random random, @Nullable Version minVersion, @Nullable Version maxVersion) {
    int minVersionIndex = 0;
    if (minVersion != null) {
        minVersionIndex = ALL_VERSIONS.indexOf(minVersion);
    }
    int maxVersionIndex = ALL_VERSIONS.size() - 1;
    if (maxVersion != null) {
        maxVersionIndex = ALL_VERSIONS.indexOf(maxVersion);
    }
    if (minVersionIndex == -1) {
        throw new IllegalArgumentException("minVersion [" + minVersion + "] does not exist.");
    } else if (maxVersionIndex == -1) {
        throw new IllegalArgumentException("maxVersion [" + maxVersion + "] does not exist.");
    } else if (minVersionIndex > maxVersionIndex) {
        throw new IllegalArgumentException("maxVersion [" + maxVersion + "] cannot be less than minVersion [" + minVersion + "]");
    } else {
        // minVersionIndex is inclusive so need to add 1 to this index
        int range = maxVersionIndex + 1 - minVersionIndex;
        return ALL_VERSIONS.get(minVersionIndex + random.nextInt(range));
    }
}
 
Example #14
Source File: RoutingFieldMapper.java    From Elasticsearch with Apache License 2.0 6 votes vote down vote up
@Override
public MetadataFieldMapper.Builder parse(String name, Map<String, Object> node, ParserContext parserContext) throws MapperParsingException {
    Builder builder = new Builder(parserContext.mapperService().fullName(NAME));
    if (parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
        parseField(builder, builder.name, node, parserContext);
    }
    for (Iterator<Map.Entry<String, Object>> iterator = node.entrySet().iterator(); iterator.hasNext();) {
        Map.Entry<String, Object> entry = iterator.next();
        String fieldName = Strings.toUnderscoreCase(entry.getKey());
        Object fieldNode = entry.getValue();
        if (fieldName.equals("required")) {
            builder.required(nodeBooleanValue(fieldNode));
            iterator.remove();
        } else if (fieldName.equals("path") && parserContext.indexVersionCreated().before(Version.V_2_0_0_beta1)) {
            builder.path(fieldNode.toString());
            iterator.remove();
        }
    }
    return builder;
}
 
Example #15
Source File: FieldMapper.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
protected String buildIndexName(BuilderContext context) {
    if (context.indexCreatedVersion().onOrAfter(Version.V_2_0_0_beta1)) {
        return buildFullName(context);
    }
    String actualIndexName = indexName == null ? name : indexName;
    return context.path().pathAsText(actualIndexName);
}
 
Example #16
Source File: PublicationTransportHandler.java    From crate with Apache License 2.0 5 votes vote down vote up
public static BytesReference serializeDiffClusterState(Diff diff, Version nodeVersion) throws IOException {
    final BytesStreamOutput bStream = new BytesStreamOutput();
    try (StreamOutput stream = CompressorFactory.COMPRESSOR.streamOutput(bStream)) {
        stream.setVersion(nodeVersion);
        stream.writeBoolean(false);
        diff.writeTo(stream);
    }
    return bStream.bytes();
}
 
Example #17
Source File: BaseNodesRequest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    if (out.getVersion().before(Version.V_4_1_0)) {
        out.writeStringArrayNullable(null);
    }
    out.writeOptionalArray(concreteNodes);
    out.writeOptionalTimeValue(timeout);
}
 
Example #18
Source File: ClusterHealthResponse.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeString(clusterName);
    out.writeVInt(clusterStateHealth.getActivePrimaryShards());
    out.writeVInt(clusterStateHealth.getActiveShards());
    out.writeVInt(clusterStateHealth.getRelocatingShards());
    out.writeVInt(clusterStateHealth.getInitializingShards());
    out.writeVInt(clusterStateHealth.getUnassignedShards());
    out.writeVInt(clusterStateHealth.getNumberOfNodes());
    out.writeVInt(clusterStateHealth.getNumberOfDataNodes());
    out.writeInt(numberOfPendingTasks);
    out.writeByte(clusterStateHealth.getStatus().value());
    out.writeVInt(clusterStateHealth.getIndices().size());
    for (ClusterIndexHealth indexHealth : clusterStateHealth) {
        indexHealth.writeTo(out);
    }
    out.writeBoolean(timedOut);

    out.writeVInt(clusterStateHealth.getValidationFailures().size());
    for (String failure : clusterStateHealth.getValidationFailures()) {
        out.writeString(failure);
    }

    out.writeInt(numberOfInFlightFetch);
    if (out.getVersion().onOrAfter(Version.V_1_7_0)) {
        out.writeInt(delayedUnassignedShards);
    }
    out.writeDouble(clusterStateHealth.getActiveShardsPercent());
    taskMaxWaitingTime.writeTo(out);
}
 
Example #19
Source File: GroupingCollector.java    From crate with Apache License 2.0 5 votes vote down vote up
static GroupingCollector<List<Object>> manyKeys(CollectExpression<Row, ?>[] expressions,
                                                AggregateMode mode,
                                                AggregationFunction[] aggregations,
                                                Input[][] inputs,
                                                Input<Boolean>[] filters,
                                                RamAccounting ramAccountingContext,
                                                MemoryManager memoryManager,
                                                Version minNodeVersion,
                                                List<Input<?>> keyInputs,
                                                List<? extends DataType> keyTypes,
                                                Version indexVersionCreated) {
    return new GroupingCollector<>(
        expressions,
        aggregations,
        mode,
        inputs,
        filters,
        ramAccountingContext,
        memoryManager,
        minNodeVersion,
        GroupingCollector::applyKeysToCells,
        keyInputs.size(),
        GroupByMaps.accountForNewEntry(
            ramAccountingContext,
            new MultiSizeEstimator(keyTypes),
            null
        ),
        row -> evalKeyInputs(keyInputs),
        indexVersionCreated,
        HashMap::new
    );
}
 
Example #20
Source File: GetSnapshotsRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    super.writeTo(out);
    out.writeString(repository);
    out.writeStringArray(snapshots);
    if (out.getVersion().onOrAfter(Version.V_2_2_0)) {
        out.writeBoolean(ignoreUnavailable);
    }
}
 
Example #21
Source File: IndexRequest.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);
    if (in.getVersion().before(Version.V_2_3_0)) {
        type = in.readString();
    } else {
        type = in.readOptionalString();
    }
    id = in.readOptionalString();
    routing = in.readOptionalString();
    parent = in.readOptionalString();
    timestamp = in.readOptionalString();
    if (in.getVersion().before(Version.V_2_2_0)) {
        long ttl = in.readLong();
        if (ttl == -1) {
            this.ttl = null;
        } else {
            ttl(ttl);
        }
    } else {
        ttl = in.readBoolean() ? TimeValue.readTimeValue(in) : null;
    }
    source = in.readBytesReference();

    opType = OpType.fromId(in.readByte());
    refresh = in.readBoolean();
    version = in.readLong();
    versionType = VersionType.fromValue(in.readByte());
    autoGeneratedId = in.readBoolean();
}
 
Example #22
Source File: GroupingStringCollectorBenchmark.java    From crate with Apache License 2.0 5 votes vote down vote up
private GroupingCollector createGroupByMinBytesRefCollector(Functions functions) {
    InputCollectExpression keyInput = new InputCollectExpression(0);
    List<Input<?>> keyInputs = Collections.singletonList(keyInput);
    CollectExpression[] collectExpressions = new CollectExpression[]{keyInput};

    MinimumAggregation minAgg = (MinimumAggregation) functions.getQualified(
        Signature.aggregate(
            MinimumAggregation.NAME,
            DataTypes.STRING.getTypeSignature(),
            DataTypes.STRING.getTypeSignature()
        ),
        List.of(DataTypes.STRING),
        DataTypes.STRING
    );

    return GroupingCollector.singleKey(
        collectExpressions,
        AggregateMode.ITER_FINAL,
        new AggregationFunction[] { minAgg },
        new Input[][] { new Input[] { keyInput }},
        new Input[] { Literal.BOOLEAN_TRUE },
        RamAccounting.NO_ACCOUNTING,
        memoryManager,
        Version.CURRENT,
        keyInputs.get(0),
        DataTypes.STRING,
        Version.CURRENT
    );
}
 
Example #23
Source File: SnapshotInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
private SnapshotInfo(SnapshotId snapshotId, List<String> indices, SnapshotState state, String reason, Version version,
                     long startTime, long endTime, int totalShards, int successfulShards, List<SnapshotShardFailure> shardFailures,
                     Boolean includeGlobalState) {
    this.snapshotId = Objects.requireNonNull(snapshotId);
    this.indices = Collections.unmodifiableList(Objects.requireNonNull(indices));
    this.state = state;
    this.reason = reason;
    this.version = version;
    this.startTime = startTime;
    this.endTime = endTime;
    this.totalShards = totalShards;
    this.successfulShards = successfulShards;
    this.shardFailures = Objects.requireNonNull(shardFailures);
    this.includeGlobalState = includeGlobalState;
}
 
Example #24
Source File: ClusterStatsNodes.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    counts.writeTo(out);
    out.writeVInt(versions.size());
    for (Version v : versions) Version.writeVersion(v, out);
    os.writeTo(out);
    process.writeTo(out);
    jvm.writeTo(out);
    fs.writeTo(out);
    out.writeVInt(plugins.size());
    for (PluginInfo p : plugins) {
        p.writeTo(out);
    }
}
 
Example #25
Source File: StoredLtrModel.java    From elasticsearch-learning-to-rank with Apache License 2.0 5 votes vote down vote up
public StoredLtrModel(StreamInput input) throws IOException {
    name = input.readString();
    featureSet = new StoredFeatureSet(input);
    rankingModelType = input.readString();
    rankingModel = input.readString();
    modelAsString = input.readBoolean();
    if (input.getVersion().onOrAfter(Version.V_7_7_0)) {
        this.parsedFtrNorms = new StoredFeatureNormalizers(input);
    } else {
        this.parsedFtrNorms = new StoredFeatureNormalizers();
    }
}
 
Example #26
Source File: IndexMetaData.java    From crate with Apache License 2.0 5 votes vote down vote up
private IndexMetaData(Index index, long version, long mappingVersion, long settingsVersion, long[] primaryTerms, State state, int numberOfShards, int numberOfReplicas, Settings settings,
                      ImmutableOpenMap<String, MappingMetaData> mappings, ImmutableOpenMap<String, AliasMetaData> aliases,
                      ImmutableOpenMap<String, DiffableStringMap> customData, ImmutableOpenIntMap<Set<String>> inSyncAllocationIds,
                      DiscoveryNodeFilters requireFilters, DiscoveryNodeFilters initialRecoveryFilters, DiscoveryNodeFilters includeFilters, DiscoveryNodeFilters excludeFilters,
                      Version indexCreatedVersion, Version indexUpgradedVersion,
                      int routingNumShards, int routingPartitionSize, ActiveShardCount waitForActiveShards) {

    this.index = index;
    this.version = version;
    assert mappingVersion >= 0 : mappingVersion;
    this.mappingVersion = mappingVersion;
    assert settingsVersion >= 0 : settingsVersion;
    this.settingsVersion = settingsVersion;
    this.primaryTerms = primaryTerms;
    assert primaryTerms.length == numberOfShards;
    this.state = state;
    this.numberOfShards = numberOfShards;
    this.numberOfReplicas = numberOfReplicas;
    this.totalNumberOfShards = numberOfShards * (numberOfReplicas + 1);
    this.settings = settings;
    this.mappings = mappings;
    this.customData = customData;
    this.aliases = aliases;
    this.inSyncAllocationIds = inSyncAllocationIds;
    this.requireFilters = requireFilters;
    this.includeFilters = includeFilters;
    this.excludeFilters = excludeFilters;
    this.initialRecoveryFilters = initialRecoveryFilters;
    this.indexCreatedVersion = indexCreatedVersion;
    this.indexUpgradedVersion = indexUpgradedVersion;
    this.routingNumShards = routingNumShards;
    this.routingFactor = routingNumShards / numberOfShards;
    this.routingPartitionSize = routingPartitionSize;
    this.waitForActiveShards = waitForActiveShards;
    assert numberOfShards * routingFactor == routingNumShards : routingNumShards + " must be a multiple of " + numberOfShards;
}
 
Example #27
Source File: SimplePhoneticAnalysisTests.java    From crate with Apache License 2.0 5 votes vote down vote up
@Before
public void setup() throws IOException {
    String yaml = "/org/elasticsearch/index/analysis/phonetic-1.yml";
    Settings settings = Settings.builder().loadFromStream(yaml, getClass().getResourceAsStream(yaml), false)
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .build();
    this.analysis = createTestAnalysis(new Index("test", "_na_"), settings, new AnalysisPhoneticPlugin());
}
 
Example #28
Source File: RestoreService.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Checks that snapshots can be restored and have compatible version
 *
 * @param repository      repository name
 * @param snapshotInfo    snapshot metadata
 */
private void validateSnapshotRestorable(final String repository, final SnapshotInfo snapshotInfo) {
    if (!snapshotInfo.state().restorable()) {
        throw new SnapshotRestoreException(new Snapshot(repository, snapshotInfo.snapshotId()),
                                           "unsupported snapshot state [" + snapshotInfo.state() + "]");
    }
    if (Version.CURRENT.before(snapshotInfo.version())) {
        throw new SnapshotRestoreException(new Snapshot(repository, snapshotInfo.snapshotId()),
                                           "the snapshot was created with CrateDB version [" + snapshotInfo.version() +
                                               "] which is higher than the version of this node [" + Version.CURRENT + "]");
    }
}
 
Example #29
Source File: GermanNormalizationTests.java    From elasticsearch-plugin-bundle with GNU Affero General Public License v3.0 5 votes vote down vote up
public void testGerman1() throws IOException {

        String source = "Ein schöner Tag in Köln im Café an der Straßenecke";

        String[] expected = {
            "Ein",
            "schoner",
            "Tag",
            "in",
            "Koln",
            "im",
            "Café",
            "an",
            "der",
            "Strassenecke"
        };
        String resource = "german_normalization_analysis.json";
        Settings settings = Settings.builder()
                .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
                .put("path.home", System.getProperty("path.home"))
                .loadFromStream(resource, getClass().getResourceAsStream(resource), true)
                .build();
        ESTestCase.TestAnalysis analysis = ESTestCase.createTestAnalysis(new Index("test", "_na_"),
                settings,
                new BundlePlugin(Settings.EMPTY));

        TokenFilterFactory tokenFilter = analysis.tokenFilter.get("umlaut");
        Tokenizer tokenizer = analysis.tokenizer.get("standard").create();
        tokenizer.setReader(new StringReader(source));
        assertTokenStreamContents(tokenFilter.create(tokenizer), expected);
    }
 
Example #30
Source File: UpgradeSettingsRequest.java    From crate with Apache License 2.0 5 votes vote down vote up
public UpgradeSettingsRequest(StreamInput in) throws IOException {
    super(in);
    int size = in.readVInt();
    versions = new HashMap<>();
    for (int i = 0; i < size; i++) {
        String index = in.readString();
        Version upgradeVersion = Version.readVersion(in);
        String oldestLuceneSegment = in.readString();
        versions.put(index, new Tuple<>(upgradeVersion, oldestLuceneSegment));
    }
}