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: 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 #2
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 #3
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 #4
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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 #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: ClusterFormationFailureHelperTests.java    From crate with Apache License 2.0 5 votes vote down vote up
public void testDescriptionAfterDetachCluster() {
    final DiscoveryNode localNode = new DiscoveryNode("local", buildNewFakeTransportAddress(), Version.CURRENT);

    final ClusterState clusterState = state(localNode,
            VotingConfiguration.MUST_JOIN_ELECTED_MASTER.getNodeIds().toArray(new String[0]));

    assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), emptyList(), 0L).getDescription(),
            is("master not discovered yet and this node was detached from its previous cluster, " +
                    "have discovered []; " +
                    "discovery will continue using [] from hosts providers and [" + localNode +
                    "] from last-known cluster state; node term 0, last-accepted version 0 in term 0"));

    final TransportAddress otherAddress = buildNewFakeTransportAddress();
    assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, singletonList(otherAddress), emptyList(), 0L).getDescription(),
            is("master not discovered yet and this node was detached from its previous cluster, " +
                    "have discovered []; " +
                    "discovery will continue using [" + otherAddress + "] from hosts providers and [" + localNode +
                    "] from last-known cluster state; node term 0, last-accepted version 0 in term 0"));

    final DiscoveryNode otherNode = new DiscoveryNode("otherNode", buildNewFakeTransportAddress(), Version.CURRENT);
    assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), singletonList(otherNode), 0L).getDescription(),
            is("master not discovered yet and this node was detached from its previous cluster, " +
                    "have discovered [" + otherNode + "]; " +
                    "discovery will continue using [] from hosts providers and [" + localNode +
                    "] from last-known cluster state; node term 0, last-accepted version 0 in term 0"));

    final DiscoveryNode yetAnotherNode = new DiscoveryNode("yetAnotherNode", buildNewFakeTransportAddress(), Version.CURRENT);
    assertThat(new ClusterFormationState(Settings.EMPTY, clusterState, emptyList(), singletonList(yetAnotherNode), 0L).getDescription(),
            is("master not discovered yet and this node was detached from its previous cluster, " +
                    "have discovered [" + yetAnotherNode + "]; " +
                    "discovery will continue using [] from hosts providers and [" + localNode +
                    "] from last-known cluster state; node term 0, last-accepted version 0 in term 0"));

}
 
Example #16
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 #17
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 #18
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));
    }
}
 
Example #19
Source File: ElectMasterService.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Inject
public ElectMasterService(Settings settings, Version version) {
    super(settings);
    this.minMasterVersion = version.minimumCompatibilityVersion();
    this.minimumMasterNodes = settings.getAsInt(DISCOVERY_ZEN_MINIMUM_MASTER_NODES,
            DEFAULT_DISCOVERY_ZEN_MINIMUM_MASTER_NODES);
    logger.debug("using minimum_master_nodes [{}]", minimumMasterNodes);
}
 
Example #20
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 #21
Source File: OsInfo.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(StreamOutput out) throws IOException {
    out.writeLong(refreshInterval);
    out.writeInt(availableProcessors);
    if (out.getVersion().onOrAfter(Version.V_2_1_0)) {
        out.writeInt(allocatedProcessors);
    }
    if (out.getVersion().onOrAfter(Version.V_2_2_0)) {
        out.writeOptionalString(name);
        out.writeOptionalString(arch);
        out.writeOptionalString(version);
    }
}
 
Example #22
Source File: SrvUnicastHostsProvider.java    From elasticsearch-srv-discovery with MIT License 5 votes vote down vote up
@Inject
public SrvUnicastHostsProvider(Settings settings, TransportService transportService, Version version) {
    super(settings);
    this.transportService = transportService;
    this.version = version;

    this.query = settings.get(DISCOVERY_SRV_QUERY);
    logger.debug("Using query {}", this.query);
    this.resolver = buildResolver(settings);
}
 
Example #23
Source File: CoordinationStateTests.java    From crate with Apache License 2.0 5 votes vote down vote up
Cluster(int numNodes) {
    messages = new ArrayList<>();

    clusterNodes = IntStream.range(0, numNodes)
        .mapToObj(i -> new DiscoveryNode("node_" + i, buildNewFakeTransportAddress(), Version.CURRENT))
        .map(ClusterNode::new)
        .collect(Collectors.toList());

    initialConfiguration = randomVotingConfig();
    initialValue = randomLong();
}
 
Example #24
Source File: SnapshotInfo.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public void writeTo(final StreamOutput out) throws IOException {
    snapshotId.writeTo(out);
    out.writeVInt(indices.size());
    for (String index : indices) {
        out.writeString(index);
    }
    if (state != null) {
        out.writeBoolean(true);
        out.writeByte(state.value());
    } else {
        out.writeBoolean(false);
    }
    out.writeOptionalString(reason);
    out.writeVLong(startTime);
    out.writeVLong(endTime);
    out.writeVInt(totalShards);
    out.writeVInt(successfulShards);
    out.writeVInt(shardFailures.size());
    for (SnapshotShardFailure failure : shardFailures) {
        failure.writeTo(out);
    }
    if (version != null) {
        out.writeBoolean(true);
        Version.writeVersion(version, out);
    } else {
        out.writeBoolean(false);
    }
    out.writeOptionalBoolean(includeGlobalState);
}
 
Example #25
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 #26
Source File: PublicationTransportHandler.java    From crate with Apache License 2.0 5 votes vote down vote up
public static BytesReference serializeFullClusterState(ClusterState clusterState, Version nodeVersion) throws IOException {
    final BytesStreamOutput bStream = new BytesStreamOutput();
    try (StreamOutput stream = CompressorFactory.COMPRESSOR.streamOutput(bStream)) {
        stream.setVersion(nodeVersion);
        stream.writeBoolean(true);
        clusterState.writeTo(stream);
    }
    return bStream.bytes();
}
 
Example #27
Source File: DocumentMapperParser.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private void parseTransform(DocumentMapper.Builder docBuilder, Map<String, Object> transformConfig, Version indexVersionCreated) {
    Script script = Script.parse(transformConfig, true, parseFieldMatcher);
    if (script != null) {
        docBuilder.transform(scriptService, script);
    }
    checkNoRemainingFields(transformConfig, indexVersionCreated, "Transform config has unsupported parameters: ");
}
 
Example #28
Source File: PostgresWireProtocolTest.java    From crate with Apache License 2.0 5 votes vote down vote up
@Test
public void testCrateServerVersionIsReceivedOnStartup() throws Exception {
    PostgresWireProtocol ctx = new PostgresWireProtocol(
        sqlOperations, sessionContext -> AccessControl.DISABLED, new AlwaysOKNullAuthentication(), null);
    channel = new EmbeddedChannel(ctx.decoder, ctx.handler);

    ByteBuf buf = Unpooled.buffer();
    ClientMessages.sendStartupMessage(buf, "doc");
    channel.writeInbound(buf);
    channel.releaseInbound();

    ByteBuf respBuf;
    respBuf = channel.readOutbound();
    try {
        assertThat((char) respBuf.readByte(), is('R')); // Auth OK
    } finally {
        respBuf.release();
    }

    respBuf = channel.readOutbound();
    try {
        assertThat((char) respBuf.readByte(), is('S')); // ParameterStatus
        respBuf.readInt(); // length
        String key = PostgresWireProtocol.readCString(respBuf);
        String value = PostgresWireProtocol.readCString(respBuf);

        assertThat(key, is("crate_version"));
        assertThat(value, is(Version.CURRENT.externalNumber()));
    } finally {
        respBuf.release();
    }
}
 
Example #29
Source File: TransportUpgradeAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
protected ShardUpgradeResult shardOperation(UpgradeRequest request, ShardRouting shardRouting) throws IOException {
    IndexShard indexShard = indicesService.indexServiceSafe(shardRouting.shardId().getIndex()).shardSafe(shardRouting.shardId().id());
    org.apache.lucene.util.Version oldestLuceneSegment = indexShard.upgrade(request);
    // We are using the current version of Elasticsearch as upgrade version since we update mapping to match the current version
    return new ShardUpgradeResult(shardRouting.shardId(), indexShard.routingEntry().primary(), Version.CURRENT, oldestLuceneSegment);
}
 
Example #30
Source File: ChildTaskActionRequest.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);
    if (out.getVersion().onOrAfter(Version.V_2_3_0)) {
        parentTaskId.writeTo(out);
    }
}