public void execute()

in src/main/java/co/elastic/support/diagnostics/commands/CheckElasticsearchVersion.java [38:81]


    public void execute(DiagnosticContext context) throws DiagnosticException {

        // Get the version number from the JSON returned
        // by just submitting the host/port combo
        logger.info(Constants.CONSOLE, "Getting Elasticsearch Version.");
        DiagnosticInputs inputs = context.diagnosticInputs;
        DiagConfig config = context.diagsConfig;

        try {
            RestClient restClient = RestClient.getClient(
                    inputs.host,
                    inputs.port,
                    inputs.scheme,
                    inputs.user,
                    inputs.password,
                    inputs.proxyHost,
                    inputs.proxyPort,
                    inputs.proxyUser,
                    inputs.proxyPassword,
                    inputs.pkiKeystore,
                    inputs.pkiKeystorePass,
                    inputs.skipVerification,
                    config.extraHeaders,
                    config.connectionTimeout,
                    config.connectionRequestTimeout,
                    config.socketTimeout);

            // Add it to the global cache - automatically closed on exit.
            context.resourceCache.addRestClient(Constants.restInputHost, restClient);
            context.version = getElasticsearchVersion(restClient);
            String version = context.version.getVersion();
            RestEntryConfig builder = new RestEntryConfig(version, inputs.mode);
            Map restCalls = JsonYamlUtils.readYamlFromClasspath(Constants.ES_REST, true);

            context.elasticRestCalls = builder.buildEntryMap(restCalls);
            // For Elasticsearch, we use some API calls based
            context.fullElasticRestCalls = new RestEntryConfig(version).buildEntryMap(restCalls);
        } catch (Exception e) {
            logger.error("Unanticipated error:", e);
            throw new DiagnosticException(String.format(
                    "Could not retrieve the Elasticsearch version due to a system or network error - unable to continue. %s%s%s",
                    e.getMessage(), SystemProperties.lineSeparator, Constants.CHECK_LOG));
        }
    }