Skip to content

Commit

Permalink
Re-factor
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Oct 4, 2023
1 parent 7df38c8 commit 1f8e6aa
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions server/src/main/java/org/opensearch/index/store/Store.java
Original file line number Diff line number Diff line change
Expand Up @@ -971,9 +971,7 @@ public void copyFrom(Directory from, String src, String dest, IOContext context)
long startTime = System.currentTimeMillis();
try {
if (from instanceof RemoteSegmentStoreDirectory) {
try (IndexInput is = from.openInput(src, context); IndexOutput os = createOutput(dest, context)) {
copyFileAndValidateChecksum(from, is, os, dest, fileSize);
}
copyFileAndValidateChecksum(from, src, dest, context, fileSize);
} else {
super.copyFrom(from, src, dest, context);
}
Expand All @@ -986,18 +984,18 @@ public void copyFrom(Directory from, String src, String dest, IOContext context)
}
}

private void copyFileAndValidateChecksum(Directory from, IndexInput is, IndexOutput os, String dest, long fileSize)
private void copyFileAndValidateChecksum(Directory from, String src, String dest, IOContext context, long fileSize)
throws IOException {
RemoteSegmentStoreDirectory.UploadedSegmentMetadata metadata = ((RemoteSegmentStoreDirectory) from)
.getSegmentsUploadedToRemoteStore()
.get(dest);
boolean success = false;
try {
try (IndexInput is = from.openInput(src, context); IndexOutput os = createOutput(dest, context)) {
// Here, we don't need the exact version as LuceneVerifyingIndexOutput does not verify version
// It is just used to emit logs when the entire metadata object is provided as parameter. Also,
// we can't provide null version as StoreFileMetadata has non-null check on writtenBy field.
Version luceneMajorVersion = Version.parse(metadata.getWrittenByMajor() + ".0.0");
Long checksum = Long.parseLong(metadata.getChecksum());
long checksum = Long.parseLong(metadata.getChecksum());
StoreFileMetadata storeFileMetadata = new StoreFileMetadata(
dest,
fileSize,
Expand Down

0 comments on commit 1f8e6aa

Please sign in to comment.