- All Implemented Interfaces:
Comparable<TransportVersion>
,VersionId<TransportVersion>
Prior to 8.8.0, the release Version
was used everywhere. This class separates the wire protocol version from the release version.
Each transport version constant has an id number, which for versions prior to 8.9.0 is the same as the release version for backwards compatibility. In 8.9.0 this is changed to an incrementing number, disconnected from the release version.
Each version constant has a unique id string. This is not actually used in the binary protocol, but is there to ensure each protocol version is only added to the source file once. This string needs to be unique (normally a UUID, but can be any other unique nonempty string). If two concurrent PRs add the same transport version, the different unique ids cause a git conflict, ensuring that the second PR to be merged must be updated with the next free version first. Without the unique id string, git will happily merge the two versions together, resulting in the same transport version being used across multiple commits, causing problems when you try to upgrade between those two merged commits.
Version compatibility
The earliest compatible version is hardcoded in theTransportVersions.MINIMUM_COMPATIBLE
field. Previously, this was dynamically
calculated from the major/minor versions of Version
, but TransportVersion
does not have separate major/minor version
numbers. So the minimum compatible version is hard-coded as the transport version used by the highest minor release of the previous
major version. TransportVersions.MINIMUM_COMPATIBLE
should be updated appropriately whenever a major release happens.
The earliest CCS compatible version is hardcoded at TransportVersions.MINIMUM_CCS_VERSION
, as the transport version used by the
previous minor release. This should be updated appropriately whenever a minor release happens.
Scope of usefulness of TransportVersion
TransportVersion
is a property of the transport connection between a pair of nodes, and should not be used as an indication of
the version of any single node. The TransportVersion
of a connection is negotiated between the nodes via some logic that is not
totally trivial, and may change in future. Any other places that might make decisions based on this version effectively have to reproduce
this negotiation logic, which would be fragile. If you need to make decisions based on the version of a single node, do so using a
different version value. If you need to know whether the cluster as a whole speaks a new enough TransportVersion
to understand a
newly-added feature, use ClusterState.getMinTransportVersion()
.-
Constructor Summary
ConstructorsConstructorDescriptionTransportVersion
(int id) Creates an instance of aTransportVersion
record class. -
Method Summary
Modifier and TypeMethodDescriptionstatic TransportVersion
current()
Reference to the most recent transport version.final boolean
Indicates whether some other object is "equal to" this one.static TransportVersion
fromId
(int id) static TransportVersion
fromString
(String str) final int
hashCode()
Returns a hash code value for this object.int
id()
Returns the value of theid
record component.static boolean
isCompatible
(TransportVersion version) Returnstrue
if the specified version is compatible with this running version of Elasticsearch.boolean
isPatchFrom
(TransportVersion version) Returnstrue
if this version is a patch version at or afterversion
.static TransportVersion
max
(TransportVersion version1, TransportVersion version2) Returns the maximum version ofversion1
andversion2
static TransportVersion
min
(TransportVersion version1, TransportVersion version2) Returns the minimum version ofversion1
andversion2
static TransportVersion
Returns a string representing the Elasticsearch release version of this transport version, if applicable for this deployment, otherwise the raw version number.toString()
Returns a string representation of this record class.static void
writeVersion
(TransportVersion version, StreamOutput out)
-
Constructor Details
-
TransportVersion
public TransportVersion(int id) Creates an instance of aTransportVersion
record class.- Parameters:
id
- the value for theid
record component
-
-
Method Details
-
readVersion
- Throws:
IOException
-
fromId
-
writeVersion
- Throws:
IOException
-
min
Returns the minimum version ofversion1
andversion2
-
max
Returns the maximum version ofversion1
andversion2
-
isCompatible
Returnstrue
if the specified version is compatible with this running version of Elasticsearch. -
current
Reference to the most recent transport version. This should be the transport version with the highest id. -
fromString
-
isPatchFrom
Returnstrue
if this version is a patch version at or afterversion
.This should not be used normally. It is used for matching patch versions of the same base version, using the standard version number format specified in
TransportVersions
. When a patch version of an existing transport version is created,transportVersion.isPatchFrom(patchVersion)
will match any transport version at or abovepatchVersion
that is also of the same base version.For example,
version.isPatchFrom(8_800_00_4)
will return the following for the givenversion
:8_799_00_0.isPatchFrom(8_800_00_4)
:false
8_799_00_9.isPatchFrom(8_800_00_4)
:false
8_800_00_0.isPatchFrom(8_800_00_4)
:false
8_800_00_3.isPatchFrom(8_800_00_4)
:false
8_800_00_4.isPatchFrom(8_800_00_4)
:true
8_800_00_9.isPatchFrom(8_800_00_4)
:true
8_800_01_0.isPatchFrom(8_800_00_4)
:false
8_801_00_0.isPatchFrom(8_800_00_4)
:false
-
toReleaseVersion
Returns a string representing the Elasticsearch release version of this transport version, if applicable for this deployment, otherwise the raw version number. -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
id
public int id()Returns the value of theid
record component.- Specified by:
id
in interfaceVersionId<TransportVersion>
- Returns:
- the value of the
id
record component
-