mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-02 17:09:18 +00:00
Fix blob size in writeBlob() method
This commit is contained in:
parent
a3abfab865
commit
d715dfd16c
@ -624,13 +624,14 @@ public class BlobStoreIndexShardRepository extends AbstractComponent implements
|
||||
*/
|
||||
private void snapshotFile(final BlobStoreIndexShardSnapshot.FileInfo fileInfo) throws IOException {
|
||||
final String file = fileInfo.physicalName();
|
||||
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||
try (IndexInput indexInput = store.openVerifyingInput(file, IOContext.READONCE, fileInfo.metadata())) {
|
||||
for (int i = 0; i < fileInfo.numberOfParts(); i++) {
|
||||
final InputStreamIndexInput inputStreamIndexInput = new InputStreamIndexInput(indexInput, fileInfo.partBytes());
|
||||
final long partBytes = fileInfo.partBytes(i);
|
||||
|
||||
final InputStreamIndexInput inputStreamIndexInput = new InputStreamIndexInput(indexInput, partBytes);
|
||||
InputStream inputStream = snapshotRateLimiter == null ? inputStreamIndexInput : new RateLimitingInputStream(inputStreamIndexInput, snapshotRateLimiter, snapshotThrottleListener);
|
||||
inputStream = new AbortableInputStream(inputStream, fileInfo.physicalName());
|
||||
blobContainer.writeBlob(fileInfo.partName(i), inputStream, fileInfo.partBytes());
|
||||
blobContainer.writeBlob(fileInfo.partName(i), inputStream, partBytes);
|
||||
}
|
||||
Store.verify(indexInput);
|
||||
snapshotStatus.addProcessedFile(fileInfo.length());
|
||||
|
@ -150,12 +150,20 @@ public class BlobStoreIndexShardSnapshot implements ToXContent, FromXContentBuil
|
||||
}
|
||||
|
||||
/**
|
||||
* Return maximum number of bytes in a part
|
||||
* Returns the size (in bytes) of a given part
|
||||
*
|
||||
* @return maximum number of bytes in a part
|
||||
* @return the size (in bytes) of a given part
|
||||
*/
|
||||
public long partBytes() {
|
||||
return partBytes;
|
||||
public long partBytes(int part) {
|
||||
if (numberOfParts == 1) {
|
||||
return length();
|
||||
}
|
||||
// First and last-but-one parts have a size equal to partBytes
|
||||
if (part < (numberOfParts - 1)) {
|
||||
return partBytes;
|
||||
}
|
||||
// Last part size is deducted from the length and the number of parts
|
||||
return length() % partBytes;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +63,7 @@ public class FileInfoTests extends ESTestCase {
|
||||
assertThat(info.physicalName(), equalTo(parsedInfo.physicalName()));
|
||||
assertThat(info.length(), equalTo(parsedInfo.length()));
|
||||
assertThat(info.checksum(), equalTo(parsedInfo.checksum()));
|
||||
assertThat(info.partBytes(), equalTo(parsedInfo.partBytes()));
|
||||
assertThat(info.partSize(), equalTo(parsedInfo.partSize()));
|
||||
assertThat(parsedInfo.metadata().hash().length, equalTo(hash.length));
|
||||
assertThat(parsedInfo.metadata().hash(), equalTo(hash));
|
||||
assertThat(parsedInfo.metadata().writtenBy(), equalTo(Version.LATEST));
|
||||
|
Loading…
x
Reference in New Issue
Block a user