From 7df38c85a55f4a70c8341043a30fc024963d0936 Mon Sep 17 00:00:00 2001 From: Sachin Kale Date: Wed, 20 Sep 2023 15:55:48 +0530 Subject: [PATCH] Remove un-necessary changes Signed-off-by: Sachin Kale --- .../store/LuceneVerifyingIndexOutput.java | 113 -------- .../org/opensearch/index/store/Store.java | 268 ++++++++++++++++-- .../index/store/VerifyingIndexInput.java | 159 ----------- .../indices/recovery/MultiFileWriter.java | 2 +- .../blobstore/BlobStoreRepository.java | 14 +- .../opensearch/index/store/StoreTests.java | 12 +- ...alStorePeerRecoverySourceHandlerTests.java | 6 +- 7 files changed, 259 insertions(+), 315 deletions(-) delete mode 100644 server/src/main/java/org/opensearch/index/store/LuceneVerifyingIndexOutput.java delete mode 100644 server/src/main/java/org/opensearch/index/store/VerifyingIndexInput.java diff --git a/server/src/main/java/org/opensearch/index/store/LuceneVerifyingIndexOutput.java b/server/src/main/java/org/opensearch/index/store/LuceneVerifyingIndexOutput.java deleted file mode 100644 index 5403c33547531..0000000000000 --- a/server/src/main/java/org/opensearch/index/store/LuceneVerifyingIndexOutput.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.index.store; - -import org.apache.lucene.codecs.CodecUtil; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.store.IndexOutput; -import org.opensearch.common.lucene.store.ByteArrayIndexInput; - -import java.io.IOException; - -/** - * Class to verify the lucene index output - * - * @opensearch.internal - */ -public class LuceneVerifyingIndexOutput extends VerifyingIndexOutput { - - private final StoreFileMetadata metadata; - private long writtenBytes; - private final long checksumPosition; - private String actualChecksum; - private final byte[] footerChecksum = new byte[8]; // this holds the actual footer checksum data written by to this output - - public LuceneVerifyingIndexOutput(StoreFileMetadata metadata, IndexOutput out) { - super(out); - this.metadata = metadata; - checksumPosition = metadata.length() - 8; // the last 8 bytes are the checksum - we store it in footerChecksum - } - - @Override - public void verify() throws IOException { - String footerDigest = null; - if (metadata.checksum().equals(actualChecksum) && writtenBytes == metadata.length()) { - ByteArrayIndexInput indexInput = new ByteArrayIndexInput("checksum", this.footerChecksum); - footerDigest = Store.digestToString(CodecUtil.readBELong(indexInput)); - if (metadata.checksum().equals(footerDigest)) { - return; - } - } - throw new CorruptIndexException( - "verification failed (hardware problem?) : expected=" - + metadata.checksum() - + " actual=" - + actualChecksum - + " footer=" - + footerDigest - + " writtenLength=" - + writtenBytes - + " expectedLength=" - + metadata.length() - + " (resource=" - + metadata - + ")", - "VerifyingIndexOutput(" + metadata.name() + ")" - ); - } - - @Override - public void writeByte(byte b) throws IOException { - final long writtenBytes = this.writtenBytes++; - if (writtenBytes >= checksumPosition) { // we are writing parts of the checksum.... - if (writtenBytes == checksumPosition) { - readAndCompareChecksum(); - } - final int index = Math.toIntExact(writtenBytes - checksumPosition); - if (index < footerChecksum.length) { - footerChecksum[index] = b; - if (index == footerChecksum.length - 1) { - verify(); // we have recorded the entire checksum - } - } else { - verify(); // fail if we write more than expected - throw new AssertionError("write past EOF expected length: " + metadata.length() + " writtenBytes: " + writtenBytes); - } - } - out.writeByte(b); - } - - private void readAndCompareChecksum() throws IOException { - actualChecksum = Store.digestToString(getChecksum()); - if (!metadata.checksum().equals(actualChecksum)) { - throw new CorruptIndexException( - "checksum failed (hardware problem?) : expected=" - + metadata.checksum() - + " actual=" - + actualChecksum - + " (resource=" - + metadata.toString() - + ")", - "VerifyingIndexOutput(" + metadata.name() + ")" - ); - } - } - - @Override - public void writeBytes(byte[] b, int offset, int length) throws IOException { - if (writtenBytes + length > checksumPosition) { - for (int i = 0; i < length; i++) { // don't optimze writing the last block of bytes - writeByte(b[offset + i]); - } - } else { - out.writeBytes(b, offset, length); - writtenBytes += length; - } - } -} diff --git a/server/src/main/java/org/opensearch/index/store/Store.java b/server/src/main/java/org/opensearch/index/store/Store.java index 2350bc9eda4ba..9d3bfb5b58c22 100644 --- a/server/src/main/java/org/opensearch/index/store/Store.java +++ b/server/src/main/java/org/opensearch/index/store/Store.java @@ -49,7 +49,9 @@ import org.apache.lucene.index.SegmentCommitInfo; import org.apache.lucene.index.SegmentInfos; import org.apache.lucene.store.AlreadyClosedException; +import org.apache.lucene.store.BufferedChecksum; import org.apache.lucene.store.BufferedChecksumIndexInput; +import org.apache.lucene.store.ByteArrayDataInput; import org.apache.lucene.store.ChecksumIndexInput; import org.apache.lucene.store.Directory; import org.apache.lucene.store.FilterDirectory; @@ -65,7 +67,6 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.common.UUIDs; import org.opensearch.common.annotation.InternalApi; -import org.opensearch.common.inject.Provider; import org.opensearch.common.io.stream.BytesStreamOutput; import org.opensearch.common.logging.Loggers; import org.opensearch.common.lucene.Lucene; @@ -117,6 +118,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.locks.ReentrantReadWriteLock; import java.util.function.Consumer; +import java.util.zip.CRC32; +import java.util.zip.Checksum; import static java.lang.Character.MAX_RADIX; import static java.util.Collections.emptyMap; @@ -619,13 +622,9 @@ public static void tryOpenIndex(Path indexLocation, ShardId shardId, NodeEnviron * Note: Checksums are calculated by default since version 4.8.0. This method only adds the * verification against the checksum in the given metadata and does not add any significant overhead. */ - public static IndexOutput createVerifyingOutput( - Directory directory, - String fileName, - final StoreFileMetadata metadata, - final IOContext context - ) throws IOException { - IndexOutput output = directory.createOutput(fileName, context); + public IndexOutput createVerifyingOutput(String fileName, final StoreFileMetadata metadata, final IOContext context) + throws IOException { + IndexOutput output = directory().createOutput(fileName, context); boolean success = false; try { assert metadata.writtenBy() != null; @@ -645,10 +644,9 @@ public static void verify(IndexOutput output) throws IOException { } } - public static IndexInput openVerifyingInput(Directory directory, String filename, IOContext context, StoreFileMetadata metadata) - throws IOException { + public IndexInput openVerifyingInput(String filename, IOContext context, StoreFileMetadata metadata) throws IOException { assert metadata.writtenBy() != null; - return new VerifyingIndexInput(directory.openInput(filename, context)); + return new VerifyingIndexInput(directory().openInput(filename, context)); } public static void verify(IndexInput input) throws IOException { @@ -920,15 +918,6 @@ static final class StoreDirectory extends FilterDirectory { public final DirectoryFileTransferTracker directoryFileTransferTracker; StoreDirectory(ByteSizeCachingDirectory delegateDirectory, Logger deletesLogger) { - this(delegateDirectory, deletesLogger, null, null); - } - - StoreDirectory( - ByteSizeCachingDirectory delegateDirectory, - Logger deletesLogger, - Provider checksumProvider, - Provider versionProvider - ) { super(delegateDirectory); this.deletesLogger = deletesLogger; this.directoryFileTransferTracker = new DirectoryFileTransferTracker(); @@ -1528,6 +1517,245 @@ public static String digestToString(long digest) { return Long.toString(digest, MAX_RADIX); } + /** + * Class to verify the lucene index output + * + * @opensearch.internal + */ + public static class LuceneVerifyingIndexOutput extends VerifyingIndexOutput { + + private final StoreFileMetadata metadata; + private long writtenBytes; + private final long checksumPosition; + private String actualChecksum; + private final byte[] footerChecksum = new byte[8]; // this holds the actual footer checksum data written by to this output + + public LuceneVerifyingIndexOutput(StoreFileMetadata metadata, IndexOutput out) { + super(out); + this.metadata = metadata; + checksumPosition = metadata.length() - 8; // the last 8 bytes are the checksum - we store it in footerChecksum + } + + @Override + public void verify() throws IOException { + String footerDigest = null; + if (metadata.checksum().equals(actualChecksum) && writtenBytes == metadata.length()) { + ByteArrayIndexInput indexInput = new ByteArrayIndexInput("checksum", this.footerChecksum); + footerDigest = digestToString(CodecUtil.readBELong(indexInput)); + if (metadata.checksum().equals(footerDigest)) { + return; + } + } + throw new CorruptIndexException( + "verification failed (hardware problem?) : expected=" + + metadata.checksum() + + " actual=" + + actualChecksum + + " footer=" + + footerDigest + + " writtenLength=" + + writtenBytes + + " expectedLength=" + + metadata.length() + + " (resource=" + + metadata.toString() + + ")", + "VerifyingIndexOutput(" + metadata.name() + ")" + ); + } + + @Override + public void writeByte(byte b) throws IOException { + final long writtenBytes = this.writtenBytes++; + if (writtenBytes >= checksumPosition) { // we are writing parts of the checksum.... + if (writtenBytes == checksumPosition) { + readAndCompareChecksum(); + } + final int index = Math.toIntExact(writtenBytes - checksumPosition); + if (index < footerChecksum.length) { + footerChecksum[index] = b; + if (index == footerChecksum.length - 1) { + verify(); // we have recorded the entire checksum + } + } else { + verify(); // fail if we write more than expected + throw new AssertionError("write past EOF expected length: " + metadata.length() + " writtenBytes: " + writtenBytes); + } + } + out.writeByte(b); + } + + private void readAndCompareChecksum() throws IOException { + actualChecksum = digestToString(getChecksum()); + if (!metadata.checksum().equals(actualChecksum)) { + throw new CorruptIndexException( + "checksum failed (hardware problem?) : expected=" + + metadata.checksum() + + " actual=" + + actualChecksum + + " (resource=" + + metadata.toString() + + ")", + "VerifyingIndexOutput(" + metadata.name() + ")" + ); + } + } + + @Override + public void writeBytes(byte[] b, int offset, int length) throws IOException { + if (writtenBytes + length > checksumPosition) { + for (int i = 0; i < length; i++) { // don't optimze writing the last block of bytes + writeByte(b[offset + i]); + } + } else { + out.writeBytes(b, offset, length); + writtenBytes += length; + } + } + } + + /** + * Index input that calculates checksum as data is read from the input. + *

+ * This class supports random access (it is possible to seek backward and forward) in order to accommodate retry + * mechanism that is used in some repository plugins (S3 for example). However, the checksum is only calculated on + * the first read. All consecutive reads of the same data are not used to calculate the checksum. + * + * @opensearch.internal + */ + static class VerifyingIndexInput extends ChecksumIndexInput { + private final IndexInput input; + private final Checksum digest; + private final long checksumPosition; + private final byte[] checksum = new byte[8]; + private long verifiedPosition = 0; + + VerifyingIndexInput(IndexInput input) { + this(input, new BufferedChecksum(new CRC32())); + } + + VerifyingIndexInput(IndexInput input, Checksum digest) { + super("VerifyingIndexInput(" + input + ")"); + this.input = input; + this.digest = digest; + checksumPosition = input.length() - 8; + } + + @Override + public byte readByte() throws IOException { + long pos = input.getFilePointer(); + final byte b = input.readByte(); + pos++; + if (pos > verifiedPosition) { + if (pos <= checksumPosition) { + digest.update(b); + } else { + checksum[(int) (pos - checksumPosition - 1)] = b; + } + verifiedPosition = pos; + } + return b; + } + + @Override + public void readBytes(byte[] b, int offset, int len) throws IOException { + long pos = input.getFilePointer(); + input.readBytes(b, offset, len); + if (pos + len > verifiedPosition) { + // Conversion to int is safe here because (verifiedPosition - pos) can be at most len, which is integer + int alreadyVerified = (int) Math.max(0, verifiedPosition - pos); + if (pos < checksumPosition) { + if (pos + len < checksumPosition) { + digest.update(b, offset + alreadyVerified, len - alreadyVerified); + } else { + int checksumOffset = (int) (checksumPosition - pos); + if (checksumOffset - alreadyVerified > 0) { + digest.update(b, offset + alreadyVerified, checksumOffset - alreadyVerified); + } + System.arraycopy(b, offset + checksumOffset, checksum, 0, len - checksumOffset); + } + } else { + // Conversion to int is safe here because checksumPosition is (file length - 8) so + // (pos - checksumPosition) cannot be bigger than 8 unless we are reading after the end of file + assert pos - checksumPosition < 8; + System.arraycopy(b, offset, checksum, (int) (pos - checksumPosition), len); + } + verifiedPosition = pos + len; + } + } + + @Override + public long getChecksum() { + return digest.getValue(); + } + + @Override + public void seek(long pos) throws IOException { + if (pos < verifiedPosition) { + // going within verified region - just seek there + input.seek(pos); + } else { + if (verifiedPosition > getFilePointer()) { + // portion of the skip region is verified and portion is not + // skipping the verified portion + input.seek(verifiedPosition); + // and checking unverified + super.seek(pos); + } else { + super.seek(pos); + } + } + } + + @Override + public void close() throws IOException { + input.close(); + } + + @Override + public long getFilePointer() { + return input.getFilePointer(); + } + + @Override + public long length() { + return input.length(); + } + + @Override + public IndexInput clone() { + throw new UnsupportedOperationException(); + } + + @Override + public IndexInput slice(String sliceDescription, long offset, long length) throws IOException { + throw new UnsupportedOperationException(); + } + + public long getStoredChecksum() { + try { + return CodecUtil.readBELong(new ByteArrayDataInput(checksum)); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + public long verify() throws CorruptIndexException, IOException { + long storedChecksum = getStoredChecksum(); + if (getChecksum() == storedChecksum) { + return storedChecksum; + } + throw new CorruptIndexException( + "verification failed : calculated=" + + Store.digestToString(getChecksum()) + + " stored=" + + Store.digestToString(storedChecksum), + this + ); + } + + } + public void deleteQuiet(String... files) { ensureOpen(); StoreDirectory directory = this.directory; diff --git a/server/src/main/java/org/opensearch/index/store/VerifyingIndexInput.java b/server/src/main/java/org/opensearch/index/store/VerifyingIndexInput.java deleted file mode 100644 index 947b026637f13..0000000000000 --- a/server/src/main/java/org/opensearch/index/store/VerifyingIndexInput.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - * - * The OpenSearch Contributors require contributions made to - * this file be licensed under the Apache-2.0 license or a - * compatible open source license. - */ - -package org.opensearch.index.store; - -import org.apache.lucene.codecs.CodecUtil; -import org.apache.lucene.index.CorruptIndexException; -import org.apache.lucene.store.BufferedChecksum; -import org.apache.lucene.store.ByteArrayDataInput; -import org.apache.lucene.store.ChecksumIndexInput; -import org.apache.lucene.store.IndexInput; - -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.zip.CRC32; -import java.util.zip.Checksum; - -/** - * Index input that calculates checksum as data is read from the input. - *

- * This class supports random access (it is possible to seek backward and forward) in order to accommodate retry - * mechanism that is used in some repository plugins (S3 for example). However, the checksum is only calculated on - * the first read. All consecutive reads of the same data are not used to calculate the checksum. - * - * @opensearch.internal - */ -public class VerifyingIndexInput extends ChecksumIndexInput { - private final IndexInput input; - private final Checksum digest; - private final long checksumPosition; - private final byte[] checksum = new byte[8]; - private long verifiedPosition = 0; - - VerifyingIndexInput(IndexInput input) { - this(input, new BufferedChecksum(new CRC32())); - } - - VerifyingIndexInput(IndexInput input, Checksum digest) { - super("VerifyingIndexInput(" + input + ")"); - this.input = input; - this.digest = digest; - checksumPosition = input.length() - 8; - } - - @Override - public byte readByte() throws IOException { - long pos = input.getFilePointer(); - final byte b = input.readByte(); - pos++; - if (pos > verifiedPosition) { - if (pos <= checksumPosition) { - digest.update(b); - } else { - checksum[(int) (pos - checksumPosition - 1)] = b; - } - verifiedPosition = pos; - } - return b; - } - - @Override - public void readBytes(byte[] b, int offset, int len) throws IOException { - long pos = input.getFilePointer(); - input.readBytes(b, offset, len); - if (pos + len > verifiedPosition) { - // Conversion to int is safe here because (verifiedPosition - pos) can be at most len, which is integer - int alreadyVerified = (int) Math.max(0, verifiedPosition - pos); - if (pos < checksumPosition) { - if (pos + len < checksumPosition) { - digest.update(b, offset + alreadyVerified, len - alreadyVerified); - } else { - int checksumOffset = (int) (checksumPosition - pos); - if (checksumOffset - alreadyVerified > 0) { - digest.update(b, offset + alreadyVerified, checksumOffset - alreadyVerified); - } - System.arraycopy(b, offset + checksumOffset, checksum, 0, len - checksumOffset); - } - } else { - // Conversion to int is safe here because checksumPosition is (file length - 8) so - // (pos - checksumPosition) cannot be bigger than 8 unless we are reading after the end of file - assert pos - checksumPosition < 8; - System.arraycopy(b, offset, checksum, (int) (pos - checksumPosition), len); - } - verifiedPosition = pos + len; - } - } - - @Override - public long getChecksum() { - return digest.getValue(); - } - - @Override - public void seek(long pos) throws IOException { - if (pos < verifiedPosition) { - // going within verified region - just seek there - input.seek(pos); - } else { - if (verifiedPosition > getFilePointer()) { - // portion of the skip region is verified and portion is not - // skipping the verified portion - input.seek(verifiedPosition); - // and checking unverified - super.seek(pos); - } else { - super.seek(pos); - } - } - } - - @Override - public void close() throws IOException { - input.close(); - } - - @Override - public long getFilePointer() { - return input.getFilePointer(); - } - - @Override - public long length() { - return input.length(); - } - - @Override - public IndexInput clone() { - throw new UnsupportedOperationException(); - } - - @Override - public IndexInput slice(String sliceDescription, long offset, long length) throws IOException { - throw new UnsupportedOperationException(); - } - - public long getStoredChecksum() { - try { - return CodecUtil.readBELong(new ByteArrayDataInput(checksum)); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - public long verify() throws CorruptIndexException, IOException { - long storedChecksum = getStoredChecksum(); - if (getChecksum() == storedChecksum) { - return storedChecksum; - } - throw new CorruptIndexException( - "verification failed : calculated=" + Store.digestToString(getChecksum()) + " stored=" + Store.digestToString(storedChecksum), - this - ); - } -} diff --git a/server/src/main/java/org/opensearch/indices/recovery/MultiFileWriter.java b/server/src/main/java/org/opensearch/indices/recovery/MultiFileWriter.java index 47a1f010684d5..29ee097d36cac 100644 --- a/server/src/main/java/org/opensearch/indices/recovery/MultiFileWriter.java +++ b/server/src/main/java/org/opensearch/indices/recovery/MultiFileWriter.java @@ -127,7 +127,7 @@ public IndexOutput openAndPutIndexOutput(String fileName, StoreFileMetadata meta } // add first, before it's created tempFileNames.put(tempFileName, fileName); - IndexOutput indexOutput = Store.createVerifyingOutput(store.directory(), tempFileName, metadata, IOContext.DEFAULT); + IndexOutput indexOutput = store.createVerifyingOutput(tempFileName, metadata, IOContext.DEFAULT); openIndexOutputs.put(fileName, indexOutput); return indexOutput; } diff --git a/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java b/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java index 3b71809df3909..490ebda24bf60 100644 --- a/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java +++ b/server/src/main/java/org/opensearch/repositories/blobstore/BlobStoreRepository.java @@ -2911,14 +2911,7 @@ private static Releasable incrementStoreRef(Store store, IndexShardSnapshotStatu } private static boolean assertFileContentsMatchHash(BlobStoreIndexShardSnapshot.FileInfo fileInfo, Store store) { - try ( - IndexInput indexInput = Store.openVerifyingInput( - store.directory(), - fileInfo.physicalName(), - IOContext.READONCE, - fileInfo.metadata() - ) - ) { + try (IndexInput indexInput = store.openVerifyingInput(fileInfo.physicalName(), IOContext.READONCE, fileInfo.metadata())) { final byte[] tmp = new byte[Math.toIntExact(fileInfo.metadata().length())]; indexInput.readBytes(tmp, 0, tmp.length); assert fileInfo.metadata().hash().bytesEquals(new BytesRef(tmp)); @@ -3007,8 +3000,7 @@ private void restoreFile(BlobStoreIndexShardSnapshot.FileInfo fileInfo, Store st logger.trace(() -> new ParameterizedMessage("[{}] restoring [{}] to [{}]", metadata.name(), fileInfo, store)); boolean success = false; try ( - IndexOutput indexOutput = Store.createVerifyingOutput( - store.directory(), + IndexOutput indexOutput = store.createVerifyingOutput( fileInfo.physicalName(), fileInfo.metadata(), IOContext.DEFAULT @@ -3434,7 +3426,7 @@ private void snapshotFile( ) throws IOException { final BlobContainer shardContainer = shardContainer(indexId, shardId); final String file = fileInfo.physicalName(); - try (IndexInput indexInput = Store.openVerifyingInput(store.directory(), file, IOContext.READONCE, fileInfo.metadata())) { + try (IndexInput indexInput = store.openVerifyingInput(file, IOContext.READONCE, fileInfo.metadata())) { for (int i = 0; i < fileInfo.numberOfParts(); i++) { final long partBytes = fileInfo.partBytes(i); diff --git a/server/src/test/java/org/opensearch/index/store/StoreTests.java b/server/src/test/java/org/opensearch/index/store/StoreTests.java index e03af71042f78..d7d326b325cc6 100644 --- a/server/src/test/java/org/opensearch/index/store/StoreTests.java +++ b/server/src/test/java/org/opensearch/index/store/StoreTests.java @@ -199,7 +199,7 @@ public void testVerifyingIndexOutput() throws IOException { indexInput.seek(0); BytesRef ref = new BytesRef(scaledRandomIntBetween(1, 1024)); long length = indexInput.length(); - IndexOutput verifyingOutput = new LuceneVerifyingIndexOutput( + IndexOutput verifyingOutput = new Store.LuceneVerifyingIndexOutput( new StoreFileMetadata("foo1.bar", length, checksum, MIN_SUPPORTED_LUCENE_VERSION), dir.createOutput("foo1.bar", IOContext.DEFAULT) ); @@ -233,7 +233,7 @@ public void testVerifyingIndexOutput() throws IOException { public void testVerifyingIndexOutputOnEmptyFile() throws IOException { Directory dir = newDirectory(); - IndexOutput verifyingOutput = new LuceneVerifyingIndexOutput( + IndexOutput verifyingOutput = new Store.LuceneVerifyingIndexOutput( new StoreFileMetadata("foo.bar", 0, Store.digestToString(0), MIN_SUPPORTED_LUCENE_VERSION), dir.createOutput("foo1.bar", IOContext.DEFAULT) ); @@ -264,7 +264,7 @@ public void testChecksumCorrupted() throws IOException { indexInput.seek(0); BytesRef ref = new BytesRef(scaledRandomIntBetween(1, 1024)); long length = indexInput.length(); - IndexOutput verifyingOutput = new LuceneVerifyingIndexOutput( + IndexOutput verifyingOutput = new Store.LuceneVerifyingIndexOutput( new StoreFileMetadata("foo1.bar", length, checksum, MIN_SUPPORTED_LUCENE_VERSION), dir.createOutput("foo1.bar", IOContext.DEFAULT) ); @@ -321,7 +321,7 @@ private void appendRandomData(IndexOutput output) throws IOException { public void testVerifyingIndexOutputWithBogusInput() throws IOException { Directory dir = newDirectory(); int length = scaledRandomIntBetween(10, 1024); - IndexOutput verifyingOutput = new LuceneVerifyingIndexOutput( + IndexOutput verifyingOutput = new Store.LuceneVerifyingIndexOutput( new StoreFileMetadata("foo1.bar", length, "", MIN_SUPPORTED_LUCENE_VERSION), dir.createOutput("foo1.bar", IOContext.DEFAULT) ); @@ -447,7 +447,7 @@ public void testVerifyingIndexInput() throws IOException { IndexInput indexInput = dir.openInput("foo.bar", IOContext.DEFAULT); long checksum = CodecUtil.retrieveChecksum(indexInput); indexInput.seek(0); - IndexInput verifyingIndexInput = new VerifyingIndexInput(dir.openInput("foo.bar", IOContext.DEFAULT)); + IndexInput verifyingIndexInput = new Store.VerifyingIndexInput(dir.openInput("foo.bar", IOContext.DEFAULT)); readIndexInputFullyWithRandomSeeks(verifyingIndexInput); Store.verify(verifyingIndexInput); assertThat(checksum, equalTo(((ChecksumIndexInput) verifyingIndexInput).getChecksum())); @@ -455,7 +455,7 @@ public void testVerifyingIndexInput() throws IOException { // Corrupt file and check again corruptFile(dir, "foo.bar", "foo1.bar"); - verifyingIndexInput = new VerifyingIndexInput(dir.openInput("foo1.bar", IOContext.DEFAULT)); + verifyingIndexInput = new Store.VerifyingIndexInput(dir.openInput("foo1.bar", IOContext.DEFAULT)); readIndexInputFullyWithRandomSeeks(verifyingIndexInput); try { Store.verify(verifyingIndexInput); diff --git a/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java b/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java index 9305fd2ab1778..4685a7196b85a 100644 --- a/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java +++ b/server/src/test/java/org/opensearch/indices/recovery/LocalStorePeerRecoverySourceHandlerTests.java @@ -1099,11 +1099,7 @@ private List generateFiles(Store store, int numFiles, IntSupp Store.digestToString(digest.getValue()), org.apache.lucene.util.Version.LATEST ); - try ( - OutputStream out = new IndexOutputOutputStream( - Store.createVerifyingOutput(store.directory(), md.name(), md, IOContext.DEFAULT) - ) - ) { + try (OutputStream out = new IndexOutputOutputStream(store.createVerifyingOutput(md.name(), md, IOContext.DEFAULT))) { out.write(buffer); out.write(Numbers.longToBytes(digest.getValue())); }