-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce a unified download manager for remote store operations
Signed-off-by: Kunal Kotwani <[email protected]>
- Loading branch information
1 parent
16c5257
commit 5b9ad7d
Showing
19 changed files
with
398 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...c/main/java/org/opensearch/index/remote/transfermanager/StatsTrackingDownloadManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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.remote.transfermanager; | ||
|
||
import org.opensearch.common.blobstore.BlobContainer; | ||
import org.opensearch.index.remote.RemoteTranslogTransferTracker; | ||
import org.opensearch.indices.recovery.RecoverySettings; | ||
import org.opensearch.threadpool.ThreadPool; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class StatsTrackingDownloadManager extends DownloadManager { | ||
|
||
private final RemoteTranslogTransferTracker remoteTranslogTransferTracker; | ||
|
||
public StatsTrackingDownloadManager( | ||
ThreadPool threadPool, | ||
RecoverySettings recoverySettings, | ||
RemoteTranslogTransferTracker remoteTranslogTransferTracker | ||
) { | ||
super(threadPool, recoverySettings); | ||
this.remoteTranslogTransferTracker = remoteTranslogTransferTracker; | ||
} | ||
|
||
public StatsTrackingDownloadManager(DownloadManager downloadManager, RemoteTranslogTransferTracker remoteTranslogTransferTracker) { | ||
super(downloadManager); | ||
this.remoteTranslogTransferTracker = remoteTranslogTransferTracker; | ||
} | ||
|
||
@Override | ||
public byte[] downloadFileFromRemoteStoreToMemory(BlobContainer blobContainer, String fileName) throws IOException { | ||
// TODO: Rewrite stats logic to remove hard-wiring to translog transfer tracker | ||
// (maybe make RemoteTranslogTransferTracker methods interface dependent?) | ||
long downloadStartTime = System.nanoTime(); | ||
byte[] data = null; | ||
try { | ||
data = super.downloadFileFromRemoteStoreToMemory(blobContainer, fileName); | ||
} finally { | ||
remoteTranslogTransferTracker.addDownloadTimeInMillis((System.nanoTime() - downloadStartTime) / 1_000_000L); | ||
if (data != null) { | ||
remoteTranslogTransferTracker.addDownloadBytesSucceeded(data.length); | ||
} | ||
} | ||
return data; | ||
} | ||
|
||
@Override | ||
public void downloadFileFromRemoteStore(BlobContainer blobContainer, String fileName, Path location) throws IOException { | ||
// TODO: Rewrite stats logic to remove hard-wiring to translog transfer tracker | ||
boolean downloadStatus = false; | ||
long bytesToRead = 0, downloadStartTime = System.nanoTime(); | ||
try { | ||
super.downloadFileFromRemoteStore(blobContainer, fileName, location); | ||
bytesToRead = Files.size(location.resolve(fileName)); | ||
downloadStatus = true; | ||
} finally { | ||
remoteTranslogTransferTracker.addDownloadTimeInMillis((System.nanoTime() - downloadStartTime) / 1_000_000L); | ||
if (downloadStatus) { | ||
remoteTranslogTransferTracker.addDownloadBytesSucceeded(bytesToRead); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.