8
8
9
9
package org .opensearch .index .translog .transfer ;
10
10
11
+ import org .apache .logging .log4j .Logger ;
12
+ import org .opensearch .common .logging .Loggers ;
11
13
import org .opensearch .core .index .shard .ShardId ;
12
14
import org .opensearch .index .remote .RemoteTranslogTransferTracker ;
13
15
import org .opensearch .index .translog .transfer .FileSnapshot .TransferFileSnapshot ;
@@ -33,11 +35,13 @@ public class FileTransferTracker implements FileTransferListener {
33
35
private final RemoteTranslogTransferTracker remoteTranslogTransferTracker ;
34
36
private Map <String , Long > bytesForTlogCkpFileToUpload ;
35
37
private long fileTransferStartTime = -1 ;
38
+ private final Logger logger ;
36
39
37
40
public FileTransferTracker (ShardId shardId , RemoteTranslogTransferTracker remoteTranslogTransferTracker ) {
38
41
this .shardId = shardId ;
39
42
this .fileTransferTracker = new ConcurrentHashMap <>();
40
43
this .remoteTranslogTransferTracker = remoteTranslogTransferTracker ;
44
+ this .logger = Loggers .getLogger (getClass (), shardId );
41
45
}
42
46
43
47
void recordFileTransferStartTime (long uploadStartTime ) {
@@ -64,9 +68,14 @@ long getTotalBytesToUpload() {
64
68
65
69
@ Override
66
70
public void onSuccess (TransferFileSnapshot fileSnapshot ) {
67
- long durationInMillis = (System .nanoTime () - fileTransferStartTime ) / 1_000_000L ;
68
- remoteTranslogTransferTracker .addUploadTimeInMillis (durationInMillis );
69
- remoteTranslogTransferTracker .addUploadBytesSucceeded (bytesForTlogCkpFileToUpload .get (fileSnapshot .getName ()));
71
+ try {
72
+ long durationInMillis = (System .nanoTime () - fileTransferStartTime ) / 1_000_000L ;
73
+ remoteTranslogTransferTracker .addUploadTimeInMillis (durationInMillis );
74
+ remoteTranslogTransferTracker .addUploadBytesSucceeded (bytesForTlogCkpFileToUpload .get (fileSnapshot .getName ()));
75
+ } catch (Exception ex ) {
76
+ logger .error ("Failure to update translog upload success stats" , ex );
77
+ }
78
+
70
79
add (fileSnapshot .getName (), TransferState .SUCCESS );
71
80
}
72
81
0 commit comments