Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
0f1af25
Introduce IndexFormatVersion class
thecoop Mar 28, 2023
63042b7
Test fixes
thecoop Mar 28, 2023
36b29ad
splotless
thecoop Mar 28, 2023
ba29004
Changes to IndexVersion
thecoop Mar 30, 2023
1ac3fab
Move lucene version to IndexVersion
thecoop Mar 30, 2023
0a40ea6
Update some tests
thecoop Mar 31, 2023
a27bbf1
Only use ES version to determine index compatibility
thecoop Mar 31, 2023
8191ab3
Merge remote-tracking branch 'upstream/main' into indexversion-version
thecoop Mar 31, 2023
fa3ef89
Add new index version
thecoop Mar 31, 2023
5d20069
Fix class constructor
thecoop Mar 31, 2023
6f4a398
Merge branch 'main' into indexversion-version
thecoop Apr 18, 2023
a482e9f
Use natural order comparator
thecoop Apr 19, 2023
6d7a216
Merge branch 'main' into indexversion-version
thecoop May 4, 2023
204a892
exclude IndexVersion from spotless
thecoop May 4, 2023
32fcb3c
Add deprecation notices on Version members
thecoop May 4, 2023
6c1fa70
Merge remote-tracking branch 'upstream/main' into indexversion-version
thecoop May 5, 2023
efaf40a
Convert IndexVersion to a record
thecoop May 5, 2023
eba108b
Merge remote-tracking branch 'upstream/main' into indexversion-version
thecoop May 5, 2023
04593d6
Add tests for IndexVersion methods
thecoop May 9, 2023
56553a1
Merge branch 'main' into indexversion-version
thecoop May 12, 2023
3031ffa
Copy across updates between Index/TransportVersion
thecoop May 12, 2023
7f2e657
Rename method to match class
thecoop May 12, 2023
ccbba69
Merge branch 'main' into indexversion-version
elasticmachine May 16, 2023
e690dea
Merge branch 'main' into indexversion-version
elasticmachine May 16, 2023
3e4e39e
Merge branch 'main' into indexversion-version
thecoop May 22, 2023
75c3cbd
We don't need all these changes now
thecoop May 22, 2023
b65f71d
Add between method
thecoop May 22, 2023
e2b5862
Migrate some uses of Version.luceneVersion to IndexVersion
thecoop May 23, 2023
bb83ea8
Merge branch 'main' into indexversion-version
thecoop Jun 1, 2023
706c1ea
Merge remote-tracking branch 'origin/indexversion-version' into index…
thecoop Jun 1, 2023
96a2499
Merge branch 'main' into indexversion-luceneversion
thecoop Jun 1, 2023
4d67687
Remove superfluous full names
thecoop Jun 8, 2023
8edc511
Merge branch 'main' into indexversion-luceneversion
thecoop Jun 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.elasticsearch.core.Booleans;
import org.elasticsearch.core.CheckedFunction;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.mapper.DateFieldMapper;
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
import org.elasticsearch.test.NotEqualMessageBuilder;
Expand Down Expand Up @@ -958,7 +959,7 @@ public void testRecovery() throws Exception {
assertTrue("expected to find a primary but didn't\n" + recoveryResponse, foundPrimary);
assertEquals("mismatch while checking for translog recovery\n" + recoveryResponse, shouldHaveTranslog, restoredFromTranslog);

String currentLuceneVersion = Version.CURRENT.luceneVersion().toString();
String currentLuceneVersion = IndexVersion.CURRENT.luceneVersion().toString();
String bwcLuceneVersion = getOldClusterVersion().luceneVersion().toString();
String minCompatibleBWCVersion = Version.CURRENT.minimumCompatibilityVersion().luceneVersion().toString();
if (shouldHaveTranslog && false == currentLuceneVersion.equals(bwcLuceneVersion)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshots;
Expand Down Expand Up @@ -192,7 +193,7 @@ public void testOnlyFetchesSnapshotFromEnabledRepositories() throws Exception {
assertThat(commitVersion, is(equalTo(Version.CURRENT)));
final org.apache.lucene.util.Version commitLuceneVersion = shardSnapshotData.getCommitLuceneVersion();
assertThat(commitLuceneVersion, is(notNullValue()));
assertThat(commitLuceneVersion, is(equalTo(Version.CURRENT.luceneVersion())));
assertThat(commitLuceneVersion, is(equalTo(IndexVersion.CURRENT.luceneVersion())));

assertThat(shardSnapshotInfo.getShardId(), is(equalTo(shardId)));
assertThat(shardSnapshotInfo.getSnapshot().getSnapshotId().getName(), is(equalTo(snapshotName)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.core.SuppressForbidden;
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.jdk.JarHell;
import org.elasticsearch.monitor.jvm.HotThreads;
import org.elasticsearch.monitor.jvm.JvmInfo;
Expand Down Expand Up @@ -336,10 +337,10 @@ static void initializeProbes() {
}

static void checkLucene() {
if (Version.CURRENT.luceneVersion().equals(org.apache.lucene.util.Version.LATEST) == false) {
if (IndexVersion.CURRENT.luceneVersion().equals(org.apache.lucene.util.Version.LATEST) == false) {
throw new AssertionError(
"Lucene version mismatch this version of Elasticsearch requires lucene version ["
+ Version.CURRENT.luceneVersion()
+ IndexVersion.CURRENT.luceneVersion()
+ "] but the current lucene version is ["
+ org.apache.lucene.util.Version.LATEST
+ "]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
import org.elasticsearch.env.ShardLock;
import org.elasticsearch.env.ShardLockObtainFailedException;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.engine.CombinedDeletionPolicy;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.seqno.SequenceNumbers;
Expand Down Expand Up @@ -817,7 +818,7 @@ static MetadataSnapshot loadFromIndexCommit(IndexCommit commit, Directory direct
}
}
if (maxVersion == null) {
maxVersion = org.elasticsearch.Version.CURRENT.minimumIndexCompatibilityVersion().luceneVersion();
maxVersion = IndexVersion.MINIMUM_COMPATIBLE.luceneVersion();
}
final String segmentsFile = segmentCommitInfos.getSegmentsFileName();
checksumFromLuceneFile(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.seqno.ReplicationTracker;
import org.elasticsearch.index.seqno.RetentionLease;
Expand Down Expand Up @@ -66,9 +67,7 @@
import static org.hamcrest.Matchers.hasSize;

public class ReplicaShardAllocatorTests extends ESAllocationTestCase {
private static final String MIN_SUPPORTED_LUCENE_VERSION = Version.CURRENT.minimumIndexCompatibilityVersion()
.luceneVersion()
.toString();
private static final String MIN_SUPPORTED_LUCENE_VERSION = IndexVersion.MINIMUM_COMPATIBLE.luceneVersion().toString();

private final ShardId shardId = new ShardId("test", "_na_", 0);
private final DiscoveryNode node1 = newNode("node1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.IndexModule;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.VersionType;
import org.elasticsearch.index.codec.CodecService;
import org.elasticsearch.index.fieldvisitor.FieldsVisitor;
Expand Down Expand Up @@ -6725,7 +6726,7 @@ public long softUpdateDocuments(Term term, Iterable<? extends Iterable<? extends
Map<String, String> userData = new HashMap<>(store.readLastCommittedSegmentsInfo().userData);
userData.remove(Engine.MIN_RETAINED_SEQNO);
IndexWriterConfig indexWriterConfig = new IndexWriterConfig(null).setOpenMode(IndexWriterConfig.OpenMode.APPEND)
.setIndexCreatedVersionMajor(Version.CURRENT.luceneVersion().major)
.setIndexCreatedVersionMajor(IndexVersion.CURRENT.luceneVersion().major)
.setSoftDeletesField(Lucene.SOFT_DELETES_FIELD)
.setCommitOnClose(false)
.setMergePolicy(NoMergePolicy.INSTANCE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot.FileInfo;
import org.elasticsearch.index.store.StoreFileMetadata;
import org.elasticsearch.test.ESTestCase;
Expand All @@ -31,8 +32,7 @@
import static org.hamcrest.Matchers.is;

public class FileInfoTests extends ESTestCase {
private static final Version MIN_SUPPORTED_LUCENE_VERSION = org.elasticsearch.Version.CURRENT.minimumIndexCompatibilityVersion()
.luceneVersion();
private static final Version MIN_SUPPORTED_LUCENE_VERSION = IndexVersion.MINIMUM_COMPATIBLE.luceneVersion();

public void testToFromXContent() throws IOException {
final int iters = scaledRandomIntBetween(1, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import org.elasticsearch.env.ShardLock;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.seqno.ReplicationTracker;
import org.elasticsearch.index.seqno.RetentionLease;
Expand Down Expand Up @@ -105,8 +106,7 @@ public class StoreTests extends ESTestCase {
"index",
Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, org.elasticsearch.Version.CURRENT).build()
);
private static final Version MIN_SUPPORTED_LUCENE_VERSION = org.elasticsearch.Version.CURRENT.minimumIndexCompatibilityVersion()
.luceneVersion();
private static final Version MIN_SUPPORTED_LUCENE_VERSION = IndexVersion.MINIMUM_COMPATIBLE.luceneVersion();

public void testRefCount() {
final ShardId shardId = new ShardId("index", "_na_", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.apache.lucene.util.Version;
import org.elasticsearch.common.util.set.Sets;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.index.store.StoreFileMetadata;
import org.elasticsearch.test.ESSingleNodeTestCase;
Expand All @@ -22,8 +23,7 @@
import java.util.regex.Pattern;

public class RecoveryStatusTests extends ESSingleNodeTestCase {
private static final Version MIN_SUPPORTED_LUCENE_VERSION = org.elasticsearch.Version.CURRENT.minimumIndexCompatibilityVersion()
.luceneVersion();
private static final Version MIN_SUPPORTED_LUCENE_VERSION = IndexVersion.MINIMUM_COMPATIBLE.luceneVersion();

public void testRenameTempFiles() throws IOException {
IndexService service = createIndex("foo");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.elasticsearch.common.UUIDs;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.snapshots.IndexShardSnapshotStatus;
Expand Down Expand Up @@ -101,7 +102,7 @@ public int finishedShardSnapshotTasks() {

public static BlobStoreIndexShardSnapshot.FileInfo dummyFileInfo() {
String filename = randomAlphaOfLength(10);
StoreFileMetadata metadata = new StoreFileMetadata(filename, 10, "CHECKSUM", Version.CURRENT.luceneVersion().toString());
StoreFileMetadata metadata = new StoreFileMetadata(filename, 10, "CHECKSUM", IndexVersion.CURRENT.luceneVersion().toString());
return new BlobStoreIndexShardSnapshot.FileInfo(filename, metadata, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.analysis.AnalysisRegistry;
import org.elasticsearch.index.analysis.CharFilterFactory;
import org.elasticsearch.index.analysis.IndexAnalyzers;
Expand Down Expand Up @@ -1896,7 +1897,7 @@ public String toString() {
* @param message an additional message or link with information on the fix
*/
protected void skipTestWaitingForLuceneFix(org.apache.lucene.util.Version luceneVersionWithFix, String message) {
final boolean currentVersionHasFix = Version.CURRENT.luceneVersion().onOrAfter(luceneVersionWithFix);
final boolean currentVersionHasFix = IndexVersion.CURRENT.luceneVersion().onOrAfter(luceneVersionWithFix);
assumeTrue("Skipping test as it is waiting on a Lucene fix: " + message, currentVersionHasFix);
fail("Remove call of skipTestWaitingForLuceneFix in " + RandomizedTest.getContext().getTargetMethod());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.elasticsearch.common.unit.ByteSizeUnit;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
Expand Down Expand Up @@ -641,7 +642,7 @@ private void executeTestCase(
fileName,
fileContent.length,
fileChecksum,
Version.CURRENT.luceneVersion().toString()
IndexVersion.CURRENT.luceneVersion().toString()
);
final List<FileInfo> files = List.of(new FileInfo(blobName, metadata, ByteSizeValue.ofBytes(fileContent.length)));
final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(snapshotId.getName(), files, 0L, 0L, 0, 0L);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
import org.elasticsearch.env.Environment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.engine.Engine;
import org.elasticsearch.index.seqno.SequenceNumbers;
import org.elasticsearch.index.shard.ShardId;
Expand Down Expand Up @@ -734,7 +735,7 @@ public void testClearCache() throws Exception {
randomFiles.add(
new BlobStoreIndexShardSnapshot.FileInfo(
blobName,
new StoreFileMetadata(fileName, input.length, checksum, Version.CURRENT.luceneVersion().toString()),
new StoreFileMetadata(fileName, input.length, checksum, IndexVersion.CURRENT.luceneVersion().toString()),
ByteSizeValue.ofBytes(input.length)
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import org.apache.lucene.store.IndexInput;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.Version;
import org.elasticsearch.action.support.PlainActionFuture;
import org.elasticsearch.blobcache.BlobCacheTestUtils;
import org.elasticsearch.blobcache.shared.SharedBlobCacheService;
Expand All @@ -17,6 +16,7 @@
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.core.Tuple;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
Expand Down Expand Up @@ -75,7 +75,7 @@ public void testRandomReads() throws Exception {
fileName,
input.length,
checksum,
Version.CURRENT.luceneVersion().toString()
IndexVersion.CURRENT.luceneVersion().toString()
);

final int partSize = randomBoolean() ? input.length : randomIntBetween(1, input.length);
Expand Down Expand Up @@ -194,7 +194,7 @@ public void testThrowsEOFException() throws Exception {
fileName,
input.length,
checksum,
Version.CURRENT.luceneVersion().toString()
IndexVersion.CURRENT.luceneVersion().toString()
);

final BlobStoreIndexShardSnapshot snapshot = new BlobStoreIndexShardSnapshot(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
package org.elasticsearch.xpack.searchablesnapshots.store.input;

import org.apache.lucene.store.IndexInput;
import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.blobcache.shared.SharedBlobCacheService;
import org.elasticsearch.blobcache.shared.SharedBytes;
Expand All @@ -19,6 +18,7 @@
import org.elasticsearch.env.NodeEnvironment;
import org.elasticsearch.env.TestEnvironment;
import org.elasticsearch.index.Index;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.shard.ShardPath;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
Expand Down Expand Up @@ -55,7 +55,7 @@ public void testRandomReads() throws IOException {

final FileInfo fileInfo = new FileInfo(
randomAlphaOfLength(10),
new StoreFileMetadata(fileName, fileData.length, checksum, Version.CURRENT.luceneVersion().toString()),
new StoreFileMetadata(fileName, fileData.length, checksum, IndexVersion.CURRENT.luceneVersion().toString()),
ByteSizeValue.ofBytes(fileData.length)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.common.Strings;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
import org.elasticsearch.index.store.Store;
Expand Down Expand Up @@ -188,7 +189,7 @@ private boolean isSnapshotVersionCompatible(ShardSnapshot snapshot) {
// same version.
if (commitVersion == null) {
assert SEQ_NO_SNAPSHOT_RECOVERIES_SUPPORTED_VERSION.luceneVersion().onOrAfter(snapshot.getCommitLuceneVersion());
return Version.CURRENT.luceneVersion().onOrAfter(snapshot.getCommitLuceneVersion());
return IndexVersion.CURRENT.luceneVersion().onOrAfter(snapshot.getCommitLuceneVersion());
}
return commitVersion.onOrBefore(Version.CURRENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.elasticsearch.core.CheckedConsumer;
import org.elasticsearch.core.IOUtils;
import org.elasticsearch.index.IndexSettings;
import org.elasticsearch.index.IndexVersion;
import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshot;
import org.elasticsearch.index.store.Store;
Expand Down Expand Up @@ -600,7 +601,7 @@ private void writeRandomDocs(Store store, int numDocs) throws IOException {
}

private ShardSnapshot createShardSnapshotThatDoNotShareSegmentFiles(String repoName) {
return createShardSnapshotThatDoNotShareSegmentFiles(repoName, Version.CURRENT, Version.CURRENT.luceneVersion());
return createShardSnapshotThatDoNotShareSegmentFiles(repoName, Version.CURRENT, IndexVersion.CURRENT.luceneVersion());
}

private ShardSnapshot createShardSnapshotThatDoNotShareSegmentFiles(
Expand Down Expand Up @@ -629,7 +630,7 @@ private ShardSnapshot createShardSnapshotThatSharesSegmentFiles(Store store, Str
);
snapshotFiles.add(fileInfo);
}
return createShardSnapshot(repository, snapshotFiles, Version.CURRENT, Version.CURRENT.luceneVersion());
return createShardSnapshot(repository, snapshotFiles, Version.CURRENT, IndexVersion.CURRENT.luceneVersion());
}

private ShardSnapshot createShardSnapshot(
Expand Down