Skip to content

Commit

Permalink
Add missing javadocs
Browse files Browse the repository at this point in the history
Signed-off-by: Bhumika Saini <sabhumik@amazon.com>
  • Loading branch information
Bhumika Saini committed Jul 31, 2023
1 parent 4949001 commit 08b051b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@
* @opensearch.internal
*/
public class RemoteStoreStats implements Writeable, ToXContentFragment {

/**
* Stats related to Remote Segment Store operations
*/
private final RemoteRefreshSegmentTracker.Stats remoteSegmentUploadShardStats;

/**
* Stats related to Remote Translog Store operations
*/
private final RemoteTranslogTracker.Stats remoteTranslogShardStats;

public RemoteStoreStats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
* Stores Remote Translog Store-related stats for a given IndexShard.
*/
public class RemoteTranslogTracker {
/**
* The shard that this tracker is associated with
*/
public final ShardId shardId;

/**
Expand Down Expand Up @@ -267,6 +270,10 @@ void updateUploadTimeMsMovingAverageWindowSize(int updatedSize) {
}
}

/**
* Gets the tracker's state as seen in the stats API
* @return Stats object with the tracker's stats
*/
public RemoteTranslogTracker.Stats stats() {
return new RemoteTranslogTracker.Stats(
shardId,
Expand All @@ -284,6 +291,13 @@ public RemoteTranslogTracker.Stats stats() {
);
}

/**
* Validates that the sum of successful operations, failed operations, and the number of operations to add (irrespective of failed/successful) does not exceed the number of operations originally started
* @param startedCount Number of operations started
* @param failedCount Number of operations failed
* @param succeededCount Number of operations successful
* @param countToAdd Number of operations to add
*/
private void checkTotal(long startedCount, long failedCount, long succeededCount, long countToAdd) {
long delta = startedCount - (failedCount + succeededCount + countToAdd);
assert delta >= 0 : "Sum of failure count ("
Expand Down Expand Up @@ -445,6 +459,11 @@ public boolean equals(Object obj) {
}
}

/**
* Validates if the stats in this tracker and the stats contained in the given stats object are same or not
* @param other Stats object to compare this tracker against
* @return true if stats are same and false otherwise
*/
boolean hasSameStatsAs(RemoteTranslogTracker.Stats other) {
return this.getShardId().toString().equals(other.shardId.toString())
&& this.getLastUploadTimestamp() == other.lastUploadTimestamp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,35 +273,30 @@ private boolean upload(Long primaryTerm, Long generation) throws IOException {
Releasable transferReleasable = Releasables.wrap(deletionPolicy.acquireTranslogGen(getMinFileGeneration()));
return translogTransferManager.transferSnapshot(transferSnapshotProvider, new TranslogTransferListener() {
/**
*
* Tracker holding stats related to Remote Translog Store operations
*/
final RemoteTranslogTracker remoteTranslogTracker = RemoteFsTranslog.this.remoteTranslogTracker;

/**
*
* Files (.tlog, .ckp, metadata) to upload to Remote Translog Store
*/
Set<FileSnapshot.TransferFileSnapshot> toUpload;

/**
*
* Total bytes to be uploaded to Remote Translog Store
*/
long uploadBytes;

/**
*
* System nano time when the Remote Translog Store upload is started
*/
long uploadStartTime;

/**
*
* System nano time when the Remote Translog Store upload is completed
*/
long uploadEndTime;

/**
*
* @param transferSnapshot the transfer snapshot
* @throws IOException
*/
@Override
public void beforeUpload(TransferSnapshot transferSnapshot) throws IOException {
toUpload = RemoteStoreUtils.getUploadBlobsFromSnapshot(transferSnapshot, fileTransferTracker);
Expand All @@ -311,11 +306,6 @@ public void beforeUpload(TransferSnapshot transferSnapshot) throws IOException {
captureStatsBeforeUpload();
}

/**
*
* @param transferSnapshot the transfer snapshot
* @throws IOException
*/
@Override
public void onUploadComplete(TransferSnapshot transferSnapshot) throws IOException {
uploadEndTime = RemoteStoreUtils.getCurrentSystemNanoTime();
Expand All @@ -328,12 +318,6 @@ public void onUploadComplete(TransferSnapshot transferSnapshot) throws IOExcepti
logger.trace("uploaded translog for {} {} ", primaryTerm, generation);
}

/**
*
* @param transferSnapshot the transfer snapshot
* @param ex the exception while processing the {@link TransferSnapshot}
* @throws IOException
*/
@Override
public void onUploadFailed(TransferSnapshot transferSnapshot, Exception ex) throws IOException {
uploadEndTime = RemoteStoreUtils.getCurrentSystemNanoTime();
Expand All @@ -349,11 +333,17 @@ public void onUploadFailed(TransferSnapshot transferSnapshot, Exception ex) thro
}
}

/**
* Adds relevant stats to the tracker when an upload is started
*/
private void captureStatsBeforeUpload() {
remoteTranslogTracker.incrementUploadsStarted();
remoteTranslogTracker.addUploadBytesStarted(uploadBytes);
}

/**
* Adds relevant stats to the tracker when an upload is successfully completed
*/
private void captureStatsOnUploadSuccess() {
long uploadDurationInMillis = (uploadEndTime - uploadStartTime) / 1_000_000L;
remoteTranslogTracker.incrementUploadsSucceeded();
Expand All @@ -369,6 +359,9 @@ private void captureStatsOnUploadSuccess() {
remoteTranslogTracker.updateUploadTimeMovingAverage(uploadDurationInMillis);
}

/**
* Adds relevant stats to the tracker when an upload has failed
*/
private void captureStatsOnUploadFailure() {
remoteTranslogTracker.incrementUploadsFailed();
remoteTranslogTracker.addUploadTimeInMillis((uploadEndTime - uploadStartTime) / 1_000_000L);
Expand Down

0 comments on commit 08b051b

Please sign in to comment.