Skip to content

Commit 4a8fb9d

Browse files
committed
Include unit in IndexShardSnapshotStatus#(startTime|totalTime)
1 parent 02d11fd commit 4a8fb9d

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

server/src/main/java/org/elasticsearch/index/snapshots/IndexShardSnapshotStatus.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public enum AbortStatus {
8888
private final AtomicReference<Stage> stage;
8989
private final AtomicReference<ShardGeneration> generation;
9090
private final AtomicReference<ShardSnapshotResult> shardSnapshotResult; // only set in stage DONE
91-
private long startTime;
92-
private long totalTime;
91+
private long startTimeMillis;
92+
private long totalTimeMillis;
9393
private int incrementalFileCount;
9494
private int totalFileCount;
9595
private int processedFileCount;
@@ -102,8 +102,8 @@ public enum AbortStatus {
102102

103103
private IndexShardSnapshotStatus(
104104
final Stage stage,
105-
final long startTime,
106-
final long totalTime,
105+
final long startTimeMillis,
106+
final long totalTimeMillis,
107107
final int incrementalFileCount,
108108
final int totalFileCount,
109109
final int processedFileCount,
@@ -117,8 +117,8 @@ private IndexShardSnapshotStatus(
117117
this.stage = new AtomicReference<>(Objects.requireNonNull(stage));
118118
this.generation = new AtomicReference<>(generation);
119119
this.shardSnapshotResult = new AtomicReference<>();
120-
this.startTime = startTime;
121-
this.totalTime = totalTime;
120+
this.startTimeMillis = startTimeMillis;
121+
this.totalTimeMillis = totalTimeMillis;
122122
this.incrementalFileCount = incrementalFileCount;
123123
this.totalFileCount = totalFileCount;
124124
this.processedFileCount = processedFileCount;
@@ -130,14 +130,14 @@ private IndexShardSnapshotStatus(
130130
}
131131

132132
public synchronized Copy moveToStarted(
133-
final long startTime,
133+
final long startTimeMillis,
134134
final int incrementalFileCount,
135135
final int totalFileCount,
136136
final long incrementalSize,
137137
final long totalSize
138138
) {
139139
if (stage.compareAndSet(Stage.INIT, Stage.STARTED)) {
140-
this.startTime = startTime;
140+
this.startTimeMillis = startTimeMillis;
141141
this.incrementalFileCount = incrementalFileCount;
142142
this.totalFileCount = totalFileCount;
143143
this.incrementalSize = incrementalSize;
@@ -172,11 +172,11 @@ public synchronized Copy moveToFinalize() {
172172
};
173173
}
174174

175-
public synchronized void moveToDone(final long endTime, final ShardSnapshotResult shardSnapshotResult) {
175+
public synchronized void moveToDone(final long endTimeMillis, final ShardSnapshotResult shardSnapshotResult) {
176176
assert shardSnapshotResult != null;
177177
assert shardSnapshotResult.getGeneration() != null;
178178
if (stage.compareAndSet(Stage.FINALIZE, Stage.DONE)) {
179-
this.totalTime = Math.max(0L, endTime - startTime);
179+
this.totalTimeMillis = Math.max(0L, endTimeMillis - startTimeMillis);
180180
this.shardSnapshotResult.set(shardSnapshotResult);
181181
this.generation.set(shardSnapshotResult.getGeneration());
182182
} else {
@@ -191,8 +191,8 @@ public Stage getStage() {
191191
return stage.get();
192192
}
193193

194-
public long getTotalTime() {
195-
return totalTime;
194+
public long getTotalTimeMillis() {
195+
return totalTimeMillis;
196196
}
197197

198198
public void addAbortListener(ActionListener<AbortStatus> listener) {
@@ -225,7 +225,7 @@ private synchronized void abortAndMoveToStageIfNotCompleted(
225225
public synchronized SnapshotsInProgress.ShardState moveToUnsuccessful(final Stage newStage, final String failure, final long endTime) {
226226
assert newStage == Stage.PAUSED || newStage == Stage.FAILURE : newStage;
227227
if (newStage == Stage.PAUSED && stage.compareAndSet(Stage.PAUSING, Stage.PAUSED)) {
228-
this.totalTime = Math.max(0L, endTime - startTime);
228+
this.totalTimeMillis = Math.max(0L, endTime - startTimeMillis);
229229
this.failure = failure;
230230
return SnapshotsInProgress.ShardState.PAUSED_FOR_NODE_REMOVAL;
231231
}
@@ -237,7 +237,7 @@ public synchronized SnapshotsInProgress.ShardState moveToUnsuccessful(final Stag
237237
public synchronized void moveToFailed(final long endTime, final String failure) {
238238
if (stage.getAndSet(Stage.FAILURE) != Stage.FAILURE) {
239239
abortListeners.onResponse(AbortStatus.NO_ABORT);
240-
this.totalTime = Math.max(0L, endTime - startTime);
240+
this.totalTimeMillis = Math.max(0L, endTime - startTimeMillis);
241241
this.failure = failure;
242242
}
243243
}
@@ -297,8 +297,8 @@ public void updateStatusDescription(String statusString) {
297297
public synchronized IndexShardSnapshotStatus.Copy asCopy() {
298298
return new IndexShardSnapshotStatus.Copy(
299299
stage.get(),
300-
startTime,
301-
totalTime,
300+
startTimeMillis,
301+
totalTimeMillis,
302302
incrementalFileCount,
303303
totalFileCount,
304304
processedFileCount,
@@ -471,9 +471,9 @@ public String toString() {
471471
+ "stage="
472472
+ stage
473473
+ ", startTime="
474-
+ startTime
474+
+ startTimeMillis
475475
+ ", totalTime="
476-
+ totalTime
476+
+ totalTimeMillis
477477
+ ", incrementalFileCount="
478478
+ incrementalFileCount
479479
+ ", totalFileCount="

server/src/main/java/org/elasticsearch/repositories/blobstore/BlobStoreSnapshotMetrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void shardSnapshotStarted() {
8585
public void shardSnapshotCompleted(IndexShardSnapshotStatus status) {
8686
final Map<String, Object> attrsWithStage = Maps.copyMapWithAddedEntry(metricAttributes, "stage", status.getStage().name());
8787
snapshotMetrics.shardsCompletedCounter().incrementBy(1, attrsWithStage);
88-
snapshotMetrics.shardsDurationHistogram().record(status.getTotalTime() / 1_000f, attrsWithStage);
88+
snapshotMetrics.shardsDurationHistogram().record(status.getTotalTimeMillis() / 1_000d, attrsWithStage);
8989
numberOfShardSnapshotsCompleted.inc();
9090
shardSnapshotsInProgress.dec();
9191
}

0 commit comments

Comments
 (0)