Skip to content

Commit f741c54

Browse files
committed
[XEN-3146] clarify progress tracker logic, swap to unboxed types and add override annotation
1 parent 8919691 commit f741c54

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

solr-backup/src/main/java/eu/xenit/solr/backup/s3/S3BackupRepositoryConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public class S3BackupRepositoryConfig {
5353

5454
private final String endpoint;
5555

56-
private final Boolean pathStyleAccessEnabled;
56+
private final boolean pathStyleAccessEnabled;
5757

58-
private final Boolean checksumValidationEnabled;
58+
private final boolean checksumValidationEnabled;
5959

60-
private final Integer progressLogByteInterval;
60+
private final int progressLogByteInterval;
6161

6262

6363
public S3BackupRepositoryConfig(NamedList<?> config) {

solr-backup/src/main/java/eu/xenit/solr/backup/s3/S3OutputStream.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,13 @@ void uploadPart(ByteArrayInputStream inputStream, int partSize) {
221221
* - Wrap the input stream into a progress listening input stream.
222222
*/
223223
Consumer<Long> progressListener = new Consumer<>() {
224-
private Long bytesSinceLastCheckpoint = 0L;
225-
226-
public void accept(Long bytesTransferred) {
227-
// Only log every interval of bytes, instead of each event
228-
bytesSinceLastCheckpoint += bytesTransferred;
229-
if (bytesSinceLastCheckpoint > configuration.getProgressLogByteInterval()) {
230-
log.debug("Progress: {} bytes", bytesTransferred);
231-
bytesSinceLastCheckpoint = 0L;
224+
private Long lastCheckpointBytes = 0L;
225+
226+
@Override
227+
public void accept(Long totalBytesTransferred) {
228+
if (totalBytesTransferred - lastCheckpointBytes >= configuration.getProgressLogByteInterval()) {
229+
log.debug("Progress: {} bytes", totalBytesTransferred);
230+
lastCheckpointBytes = totalBytesTransferred;
232231
}
233232
}
234233
};

0 commit comments

Comments
 (0)