- All Implemented Interfaces:
Comparable<MlConfigVersion>,VersionId<MlConfigVersion>,org.elasticsearch.xcontent.ToXContent,org.elasticsearch.xcontent.ToXContentFragment
Version class so that
in mixed version clusters during upgrades the old nodes won't throw exceptions when parsing these new versions.
Prior to 8.10.0, the release Version was used everywhere. This class separates the ML config format version
from the running node version.
Each ML config version constant has an id number, which for versions prior to 8.10.0 is the same as the release version for backwards compatibility. In 8.10.0 this is changed to an incrementing number, disconnected from the release version, starting at 10000099. This format is chosen for best compatibility with old node versions. *
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 ML config version, the different unique ids cause a git conflict, ensuring 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 ML config version being used across multiple commits, causing problems when you try to upgrade between those two merged commits.
Version compatibility
The earliest version is hardcoded in theFIRST_ML_VERSION field. This cannot be dynamically calculated
from the major/minor versions of Version, because MlConfigVersion does not have separate major/minor version numbers.
So the minimum version is simply hard-coded as the earliest version where ML existed (5.4.0).
Adding a new version
A new ML config version should be added every time a change is made to the serialization format of one or more ML config or state classes. Each ML config version should only be used in a single merged commit (apart from BwC versions copied fromVersion).
To add a new ML config version, add a new constant at the bottom of the list that is one million greater than the current highest
version, ensure it has a unique id, and update the CURRENT constant to point to the new version.
Reverting a ML config version
If you revert a commit with a ML config version change, you must ensure there is a new ML config version representing the reverted change. Do not let the ML config version go backwards, it must always be incremented.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
org.elasticsearch.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.xcontent.ToXContent.MapParams, org.elasticsearch.xcontent.ToXContent.Params -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final MlConfigVersionReference to the most recent Ml config version.static final MlConfigVersionReference to the earliest compatible ML config version to this version of the codebase.static final MlConfigVersionReference to the first MlConfigVersion that is detached from the stack (product) version.static final Stringstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionstatic final MlConfigVersionFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
ConstructorsConstructorDescriptionMlConfigVersion(int id) Creates an instance of aMlConfigVersionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static MlConfigVersionfromId(int id) static MlConfigVersionfromNode(DiscoveryNode node) static MlConfigVersionfromString(String str) static NavigableMap<Integer, MlConfigVersion> getAllVersionIds(Class<?> cls) Obtain a selection of (nearly) all registered versions.static MlConfigVersionstatic org.elasticsearch.core.Tuple<MlConfigVersion, MlConfigVersion> static MlConfigVersionstatic MlConfigVersionfinal inthashCode()Returns a hash code value for this object.intid()Returns the value of theidrecord component.static MlConfigVersionmax(MlConfigVersion version1, MlConfigVersion version2) Returns the maximum version ofversion1andversion2New, single number representations are treated as being after all legacy, semantic style representations.static MlConfigVersionmin(MlConfigVersion version1, MlConfigVersion version2) Returns the minimum version ofversion1andversion2Legacy, semantic style representations are treated as being before all new, single number representationsstatic MlConfigVersiontoString()Returns a string representation of this record class.org.elasticsearch.xcontent.XContentBuildertoXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) static voidwriteVersion(MlConfigVersion version, StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Field Details
-
ML_CONFIG_VERSION_NODE_ATTR
- See Also:
-
ZERO
-
V_5_4_0
-
V_6_0_0
-
V_7_0_0
-
V_7_0_1
-
V_7_1_0
-
V_7_2_0
-
V_7_2_1
-
V_7_3_0
-
V_7_3_2
-
V_7_4_0
-
V_7_5_0
-
V_7_6_0
-
V_7_7_0
-
V_7_8_0
-
V_7_8_1
-
V_7_9_0
-
V_7_9_1
-
V_7_9_2
-
V_7_9_3
-
V_7_10_0
-
V_7_10_1
-
V_7_11_0
-
V_7_12_0
-
V_7_13_0
-
V_7_14_0
-
V_7_15_0
-
V_7_15_1
-
V_7_16_0
-
V_7_17_0
-
V_7_17_1
-
V_7_17_8
-
V_8_0_0
-
V_8_1_0
-
V_8_2_0
-
V_8_3_0
-
V_8_4_0
-
V_8_5_0
-
V_8_6_0
-
V_8_6_1
-
V_8_7_0
-
V_8_7_1
-
V_8_8_0
-
V_8_8_1
-
V_8_9_0
-
V_10
-
V_11
-
V_12
-
CURRENT
Reference to the most recent Ml config version. This should be the Ml config version with the highest id. -
MINIMUM_DETACHED_ML_CONFIG_VERSION
Reference to the first MlConfigVersion that is detached from the stack (product) version. -
FIRST_ML_VERSION
Reference to the earliest compatible ML config version to this version of the codebase. This is hard-coded as the first version that included the ML plugin.
-
-
Constructor Details
-
MlConfigVersion
public MlConfigVersion(int id) Creates an instance of aMlConfigVersionrecord class.- Parameters:
id- the value for theidrecord component
-
-
Method Details
-
getAllVersionIds
Obtain a selection of (nearly) all registered versions. This method should only ever be used internally - to initialize VERSION_IDS, and in unit tests. It should never be called directly in production code. -
readVersion
- Throws:
IOException
-
fromId
-
fromNode
-
writeVersion
- Throws:
IOException
-
min
Returns the minimum version ofversion1andversion2Legacy, semantic style representations are treated as being before all new, single number representations -
max
Returns the maximum version ofversion1andversion2New, single number representations are treated as being after all legacy, semantic style representations. -
getMinMlConfigVersion
-
getMaxMlConfigVersion
-
getMinMaxMlConfigVersion
public static org.elasticsearch.core.Tuple<MlConfigVersion,MlConfigVersion> getMinMaxMlConfigVersion(DiscoveryNodes nodes) -
getMlConfigVersionForNode
-
fromString
-
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. -
toXContent
public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceorg.elasticsearch.xcontent.ToXContent- Throws:
IOException
-
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 theidrecord component.- Specified by:
idin interfaceVersionId<MlConfigVersion>- Returns:
- the value of the
idrecord component
-