- All Implemented Interfaces:
Writeable,ToXContent,ToXContentFragment
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
Fields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract booleanChecks if this version can operate properly in a cluster without features that are assumed in the currently running Elasticsearch.static BuildVersioncurrent()Get the current build version.static BuildVersionfromNodeMetadata(String version) Create aBuildVersionfrom a version in node metadatastatic BuildVersionfromStream(StreamInput input) Read aBuildVersionfrom an input streamstatic BuildVersionfromString(String version) Create aBuildVersionfrom a version string.static BuildVersionfromVersionId(int versionId) Create aBuildVersionfrom a version ID number.abstract booleanCheck whether this version comes from a release later than the currently running Elasticsearch.abstract BuildVersionReturns the minimum compatible build version based on the current version.abstract booleanCheck whether this version is on or after a minimum threshold.abstract StringReturns this build version in a form suitable for storing in node metadataMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContent
toXContentMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
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
Returns this build version in a form suitable for storing in node metadata -
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
Create aBuildVersionfrom 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
Create aBuildVersionfrom a version in node metadata- Parameters:
version- The string stored in node metadata- Returns:
- a version representing a build or release of Elasticsearch
-
fromString
Create aBuildVersionfrom a version string.- Parameters:
version- A string representation of a version- Returns:
- a version representing a build or release of Elasticsearch
-
fromStream
Read aBuildVersionfrom an input stream- Parameters:
input- The stream to read- Returns:
- a version representing a build or release of Elasticsearch
- Throws:
IOException
-
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
-