Search in sources :

Example 1 with ElasticsearchProbeException

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

the class CmdLineTool method annotateInjectorExceptions.

protected void annotateInjectorExceptions(Collection<Message> messages) {
    for (Message message : messages) {
        // noinspection ThrowableResultOfMethodCallIgnored
        final Throwable rootCause = ExceptionUtils.getRootCause(message.getCause());
        if (rootCause instanceof NodeIdPersistenceException) {
            LOG.error(UI.wallString("Unable to read or persist your NodeId file. This means your node id file (" + configuration.getNodeIdFile() + ") is not readable or writable by the current user. The following exception might give more information: " + message));
            System.exit(-1);
        } else if (rootCause instanceof AccessDeniedException) {
            LOG.error(UI.wallString("Unable to access file " + rootCause.getMessage()));
            System.exit(-2);
        } else if (rootCause instanceof UnsupportedSearchException) {
            final SearchVersion search = ((UnsupportedSearchException) rootCause).getSearchMajorVersion();
            LOG.error(UI.wallString("Unsupported search version: " + search, DocsHelper.PAGE_ES_VERSIONS.toString()));
            System.exit(-3);
        } else if (rootCause instanceof ElasticsearchProbeException) {
            LOG.error(UI.wallString(rootCause.getMessage(), DocsHelper.PAGE_ES_CONFIGURATION.toString()));
            System.exit(-4);
        } else {
            // other guice error, still print the raw messages
            // TODO this could potentially print duplicate messages depending on what a subclass does...
            LOG.error("Guice error (more detail on log level debug): {}", message.getMessage());
            if (rootCause != null) {
                LOG.debug("Stacktrace:", rootCause);
            }
        }
    }
}
Also used : ElasticsearchProbeException(org.graylog2.storage.versionprobe.ElasticsearchProbeException) AccessDeniedException(java.nio.file.AccessDeniedException) Message(com.google.inject.spi.Message) UnsupportedSearchException(org.graylog2.storage.UnsupportedSearchException) SearchVersion(org.graylog2.storage.SearchVersion) NodeIdPersistenceException(org.graylog2.plugin.system.NodeIdPersistenceException)

Example 2 with ElasticsearchProbeException

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

the class SearchDbPreflightCheck method runCheck.

@Override
public void runCheck() throws PreflightCheckException {
    try {
        final SearchVersion searchVersion = elasticVersionProbe.probe(elasticsearchHosts).orElseThrow(() -> new PreflightCheckException("Could not get Elasticsearch version"));
        if (SUPPORTED_ES_VERSIONS.stream().noneMatch(searchVersion::satisfies)) {
            throw new PreflightCheckException(StringUtils.f("Unsupported (Elastic/Open)Search version <%s>. Supported versions: <%s>", searchVersion, SUPPORTED_ES_VERSIONS));
        }
        LOG.info("Connected to (Elastic/Open)Search version <{}>", searchVersion);
    } catch (ElasticsearchProbeException e) {
        throw new PreflightCheckException(e);
    }
}
Also used : ElasticsearchProbeException(org.graylog2.storage.versionprobe.ElasticsearchProbeException) SearchVersion(org.graylog2.storage.SearchVersion)

Example 3 with ElasticsearchProbeException

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

the class ElasticsearchVersionProvider method get.

@Override
public SearchVersion get() {
    if (this.versionOverride.isPresent()) {
        final SearchVersion explicitVersion = versionOverride.get();
        LOG.info("Elasticsearch version set to " + explicitVersion + " - disabling version probe.");
        return explicitVersion;
    }
    try {
        return this.cachedVersion.get(() -> {
            final Optional<SearchVersion> probedVersion = this.versionProbe.probe(this.elasticsearchHosts);
            probedVersion.ifPresent(version -> LOG.info("Elasticsearch cluster is running " + version));
            return probedVersion;
        }).orElseThrow(() -> new ElasticsearchProbeException(NO_HOST_REACHABLE_ERROR + "!"));
    } catch (ExecutionException | InterruptedException e) {
        throw new ElasticsearchProbeException(NO_HOST_REACHABLE_ERROR + ": ", e);
    }
}
Also used : Logger(org.slf4j.Logger) Provider(javax.inject.Provider) LoggerFactory(org.slf4j.LoggerFactory) SearchVersion(org.graylog2.storage.SearchVersion) Singleton(javax.inject.Singleton) VersionProbe(org.graylog2.storage.versionprobe.VersionProbe) Inject(javax.inject.Inject) ExecutionException(java.util.concurrent.ExecutionException) List(java.util.List) ElasticsearchProbeException(org.graylog2.storage.versionprobe.ElasticsearchProbeException) Optional(java.util.Optional) Named(javax.inject.Named) URI(java.net.URI) Nullable(javax.annotation.Nullable) ElasticsearchProbeException(org.graylog2.storage.versionprobe.ElasticsearchProbeException) Optional(java.util.Optional) SearchVersion(org.graylog2.storage.SearchVersion) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

SearchVersion (org.graylog2.storage.SearchVersion)3 ElasticsearchProbeException (org.graylog2.storage.versionprobe.ElasticsearchProbeException)3 Message (com.google.inject.spi.Message)1 URI (java.net.URI)1 AccessDeniedException (java.nio.file.AccessDeniedException)1 List (java.util.List)1 Optional (java.util.Optional)1 ExecutionException (java.util.concurrent.ExecutionException)1 Nullable (javax.annotation.Nullable)1 Inject (javax.inject.Inject)1 Named (javax.inject.Named)1 Provider (javax.inject.Provider)1 Singleton (javax.inject.Singleton)1 NodeIdPersistenceException (org.graylog2.plugin.system.NodeIdPersistenceException)1 UnsupportedSearchException (org.graylog2.storage.UnsupportedSearchException)1 VersionProbe (org.graylog2.storage.versionprobe.VersionProbe)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1