Search in sources :

Example 11 with SearchVersion

use of org.graylog2.storage.SearchVersion in project graylog2-server by Graylog2.

the class IndexMappingTest method createsValidMappingTemplates.

@ParameterizedTest
@ValueSource(strings = { "5.0.0", "6.0.0", "7.0.0" })
void createsValidMappingTemplates(String versionString) throws Exception {
    final SearchVersion version = SearchVersion.elasticsearch(versionString);
    final IndexMappingTemplate mapping = new MessageIndexTemplateProvider().create(version, null);
    final Map<String, Object> template = mapping.toTemplate(indexSetConfig, "sampleIndexTemplate");
    final String fixture = fixtureFor(version);
    JSONAssert.assertEquals(json(template), fixture, true);
}
Also used : SearchVersion(org.graylog2.storage.SearchVersion) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with SearchVersion

use of org.graylog2.storage.SearchVersion in project graylog2-server by Graylog2.

the class MajorVersionConverterTest method convertEncodedValue.

@Test
void convertEncodedValue() {
    final SearchVersion version = converter.convertFrom("OPENSEARCH:1.2.0");
    assertThat(version).isEqualTo(SearchVersion.create(SearchVersion.Distribution.OPENSEARCH, Version.valueOf("1.2.0")));
}
Also used : SearchVersion(org.graylog2.storage.SearchVersion) Test(org.junit.jupiter.api.Test)

Example 13 with SearchVersion

use of org.graylog2.storage.SearchVersion in project graylog2-server by Graylog2.

the class IndexMappingFactory method createIndexMapping.

@Nonnull
public IndexMappingTemplate createIndexMapping(@Nonnull IndexSetConfig indexSetConfig) throws IgnoreIndexTemplate {
    final SearchVersion elasticsearchVersion = node.getVersion().orElseThrow(() -> new ElasticsearchException("Unable to retrieve Elasticsearch version."));
    final String templateType = indexSetConfig.indexTemplateType().orElse(IndexSetConfig.DEFAULT_INDEX_TEMPLATE_TYPE);
    return resolveIndexMappingTemplateProvider(templateType).create(elasticsearchVersion, indexSetConfig);
}
Also used : SearchVersion(org.graylog2.storage.SearchVersion) Nonnull(javax.annotation.Nonnull)

Example 14 with SearchVersion

use of org.graylog2.storage.SearchVersion in project graylog2-server by Graylog2.

the class ESVersionCheckPeriodical method doRun.

@Override
public void doRun() {
    if (versionOverride.isPresent()) {
        LOG.debug("Elasticsearch version is set manually. Not running check.");
        return;
    }
    final Optional<SearchVersion> probedVersion = this.versionProbe.probe(this.elasticsearchHosts);
    probedVersion.ifPresent(version -> {
        if (compatible(this.initialElasticsearchVersion, version)) {
            notificationService.fixed(Notification.Type.ES_VERSION_MISMATCH);
        } else {
            LOG.warn("Elasticsearch version currently running ({}) is incompatible with the one Graylog was started " + "with ({}) - a restart is required!", version, initialElasticsearchVersion);
            final Notification notification = notificationService.buildNow().addType(Notification.Type.ES_VERSION_MISMATCH).addSeverity(Notification.Severity.URGENT).addDetail("initial_version", initialElasticsearchVersion.toString()).addDetail("current_version", version.toString());
            notificationService.publishIfFirst(notification);
        }
    });
}
Also used : SearchVersion(org.graylog2.storage.SearchVersion) DetectedSearchVersion(org.graylog2.storage.DetectedSearchVersion) Notification(org.graylog2.notifications.Notification)

Example 15 with SearchVersion

use of org.graylog2.storage.SearchVersion in project graylog2-server by Graylog2.

the class NodeAdapterES6 method version.

@Override
public Optional<SearchVersion> version() {
    final Ping request = new Ping.Builder().build();
    final JestResult jestResult = JestUtils.execute(jestClient, request, () -> "Unable to retrieve Elasticsearch version");
    return Optional.ofNullable(jestResult.getJsonObject().path("version").path("number").asText(null)).map(this::parseVersion).map(SearchVersion::elasticsearch);
}
Also used : Ping(io.searchbox.core.Ping) SearchVersion(org.graylog2.storage.SearchVersion) JestResult(io.searchbox.client.JestResult)

Aggregations

SearchVersion (org.graylog2.storage.SearchVersion)16 Optional (java.util.Optional)3 Inject (javax.inject.Inject)3 ElasticsearchProbeException (org.graylog2.storage.versionprobe.ElasticsearchProbeException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 JestResult (io.searchbox.client.JestResult)2 Ping (io.searchbox.core.Ping)2 URI (java.net.URI)2 List (java.util.List)2 ExecutionException (java.util.concurrent.ExecutionException)2 Named (javax.inject.Named)2 MongodbServer (org.graylog.testing.containermatrix.MongodbServer)2 ContainerMatrixTestClassDescriptor (org.junit.jupiter.engine.descriptor.ContainerMatrixTestClassDescriptor)2 ContainerMatrixTestsDescriptor (org.junit.jupiter.engine.descriptor.ContainerMatrixTestsDescriptor)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Duration (com.github.joschi.jadconfig.util.Duration)1 Attempt (com.github.rholder.retry.Attempt)1 RetryException (com.github.rholder.retry.RetryException)1