Class BuildVersion

java.lang.Object
org.elasticsearch.env.BuildVersion
All Implemented Interfaces:
Writeable, ToXContent, ToXContentFragment

public abstract class BuildVersion extends Object implements ToXContentFragment, Writeable
A version representing the code of Elasticsearch

This class allows us to check whether an Elasticsearch release is "too old" or "too new," using an intentionally minimal API for comparisons. The static current() method returns the current release version, and fromVersionId(int) returns a version based on some identifier. By default, this identifier matches what the Version class uses, but the implementation is pluggable. If a module provides a BuildExtension service via Java SPI, this class's static methods will return a different implementation of BuildVersion, potentially with different behavior. This allows downstream projects to provide versions that accommodate different release models or versioning schemes.

  • Constructor Details

    • BuildVersion

      public BuildVersion()
  • Method Details

    • canRemoveAssumedFeatures

      public abstract boolean canRemoveAssumedFeatures()
      Checks if this version can operate properly in a cluster without features that are assumed in the currently running Elasticsearch.
    • onOrAfterMinimumCompatible

      public abstract boolean onOrAfterMinimumCompatible()
      Check whether this version is on or after a minimum threshold.

      In some cases, the only thing we need to know about a version is whether it's compatible with the currently-running Elasticsearch. This method checks the lower bound, and returns false if the version is "too old."

      By default, the minimum compatible version is derived from Version.CURRENT.minimumCompatibilityVersion(), but this behavior is pluggable.

      Returns:
      True if this version is on or after the minimum compatible version for the currently running Elasticsearch, false otherwise.
    • isFutureVersion

      public abstract boolean isFutureVersion()
      Check whether this version comes from a release later than the currently running Elasticsearch.

      This is useful for checking whether a node would be downgraded.

      Returns:
      True if this version represents a release of Elasticsearch later than the one that's running.
    • toNodeMetadata

      public abstract String toNodeMetadata()
      Returns this build version in a form suitable for storing in node metadata
    • minimumCompatibilityVersion

      public abstract BuildVersion minimumCompatibilityVersion()
      Returns the minimum compatible build version based on the current version. Ie a node needs to have at least the return version in order to communicate with a node running the current version.
    • fromVersionId

      public static BuildVersion fromVersionId(int versionId)
      Create a BuildVersion from a version ID number.

      By default, this identifier should match the integer ID of a Version; see that class for details on the default semantic versioning scheme. This behavior is, of course, pluggable.

      Parameters:
      versionId - An integer identifier for a version
      Returns:
      a version representing a build or release of Elasticsearch
    • fromNodeMetadata

      public static BuildVersion fromNodeMetadata(String version)
      Create a BuildVersion from a version in node metadata
      Parameters:
      version - The string stored in node metadata
      Returns:
      a version representing a build or release of Elasticsearch
    • fromString

      public static BuildVersion fromString(String version)
      Create a BuildVersion from a version string.
      Parameters:
      version - A string representation of a version
      Returns:
      a version representing a build or release of Elasticsearch
    • fromStream

      public static BuildVersion fromStream(StreamInput input) throws IOException
      Read a BuildVersion from an input stream
      Parameters:
      input - The stream to read
      Returns:
      a version representing a build or release of Elasticsearch
      Throws:
      IOException
    • current

      public static BuildVersion current()
      Get the current build version.

      By default, this value will be different for every public release of Elasticsearch, but downstream implementations aren't restricted by this condition.

      Returns:
      The BuildVersion for Elasticsearch