Skip to content

Commit

Permalink
Make transport and index versions easier to extend
Browse files Browse the repository at this point in the history
When overriding transport and index versions, it is difficult to decide
whether a version constant in serverless should be returned, or the
latest version constant from serverless should be used, since the latest
from serverless is not available. This commit adjust the version
extension methods to pass in the latest serverless version constants. It
also tweaks module and method visibility for a helper method needed.
  • Loading branch information
rjernst committed Sep 20, 2023
1 parent 5b17f1b commit 47d0b4a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
6 changes: 5 additions & 1 deletion server/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@
exports org.elasticsearch.indices.recovery.plan;
exports org.elasticsearch.indices.store;
exports org.elasticsearch.ingest;
exports org.elasticsearch.internal to org.elasticsearch.serverless.version, org.elasticsearch.serverless.buildinfo;
exports org.elasticsearch.internal
to
org.elasticsearch.serverless.version,
org.elasticsearch.serverless.buildinfo,
org.elasticsearch.serverless.constants;
exports org.elasticsearch.lucene.analysis.miscellaneous;
exports org.elasticsearch.lucene.grouping;
exports org.elasticsearch.lucene.queries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static TransportVersion findCurrent() {
if (versionExtension == null) {
return TransportVersions.LATEST_DEFINED;
}
var version = versionExtension.getCurrentTransportVersion();
var version = versionExtension.getCurrentTransportVersion(TransportVersions.LATEST_DEFINED);
assert version.onOrAfter(TransportVersions.LATEST_DEFINED);
return version;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static TransportVersion def(int id) {
IDS = null;
}

static NavigableMap<Integer, TransportVersion> getAllVersionIds(Class<?> cls) {
public static NavigableMap<Integer, TransportVersion> getAllVersionIds(Class<?> cls) {
Map<Integer, String> versionIdFields = new HashMap<>();
NavigableMap<Integer, TransportVersion> builder = new TreeMap<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ private static IndexVersion findCurrent() {
if (versionExtension == null) {
return LATEST_DEFINED;
}
var version = versionExtension.getCurrentIndexVersion();
var version = versionExtension.getCurrentIndexVersion(LATEST_DEFINED);

assert version.onOrAfter(LATEST_DEFINED);
assert version.luceneVersion.equals(Version.LATEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ public interface VersionExtension {
/**
* Returns the {@link TransportVersion} that Elasticsearch should use.
* <p>
* This must be at least equal to the latest version found in {@link TransportVersion} V_* constants.
* This must be at least as high as the given fallback.
* @param fallback The latest transport version from server
*/
TransportVersion getCurrentTransportVersion();
TransportVersion getCurrentTransportVersion(TransportVersion fallback);

/**
* Returns the {@link IndexVersion} that Elasticsearch should use.
* <p>
* This must be at least equal to the latest version found in {@link IndexVersion} V_* constants.
* This must be at least as high as the given fallback.
* @param fallback The latest index version from server
*/
IndexVersion getCurrentIndexVersion();
IndexVersion getCurrentIndexVersion(IndexVersion fallback);
}

0 comments on commit 47d0b4a

Please sign in to comment.