-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a shard snapshot current status debug string #118198
Changes from 2 commits
08e0a46
4ed1d23
a6fa81f
ef6ee7d
836953a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ public enum AbortStatus { | |
private long processedSize; | ||
private String failure; | ||
private final SubscribableListener<AbortStatus> abortListeners = new SubscribableListener<>(); | ||
private String debugStatusString; | ||
|
||
private IndexShardSnapshotStatus( | ||
final Stage stage, | ||
|
@@ -110,7 +111,8 @@ private IndexShardSnapshotStatus( | |
final long totalSize, | ||
final long processedSize, | ||
final String failure, | ||
final ShardGeneration generation | ||
final ShardGeneration generation, | ||
final String debugStatusString | ||
) { | ||
this.stage = new AtomicReference<>(Objects.requireNonNull(stage)); | ||
this.generation = new AtomicReference<>(generation); | ||
|
@@ -124,6 +126,7 @@ private IndexShardSnapshotStatus( | |
this.processedSize = processedSize; | ||
this.incrementalSize = incrementalSize; | ||
this.failure = failure; | ||
this.debugStatusString = debugStatusString; | ||
} | ||
|
||
public synchronized Copy moveToStarted( | ||
|
@@ -272,6 +275,13 @@ public synchronized void addProcessedFiles(int count, long totalSize) { | |
processedSize += totalSize; | ||
} | ||
|
||
/** | ||
* Updates the string explanation for what the snapshot is actively doing right now. | ||
*/ | ||
public synchronized void updateDebugStatusString(String statusString) { | ||
this.debugStatusString = statusString; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we at least assert that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, added 👍 |
||
} | ||
|
||
/** | ||
* Returns a copy of the current {@link IndexShardSnapshotStatus}. This method is | ||
* intended to be used when a coherent state of {@link IndexShardSnapshotStatus} is needed. | ||
|
@@ -289,20 +299,21 @@ public synchronized IndexShardSnapshotStatus.Copy asCopy() { | |
incrementalSize, | ||
totalSize, | ||
processedSize, | ||
failure | ||
failure, | ||
debugStatusString | ||
); | ||
} | ||
|
||
public static IndexShardSnapshotStatus newInitializing(ShardGeneration generation) { | ||
return new IndexShardSnapshotStatus(Stage.INIT, 0L, 0L, 0, 0, 0, 0, 0, 0, null, generation); | ||
return new IndexShardSnapshotStatus(Stage.INIT, 0L, 0L, 0, 0, 0, 0, 0, 0, null, generation, "initializing"); | ||
} | ||
|
||
public static IndexShardSnapshotStatus.Copy newFailed(final String failure) { | ||
assert failure != null : "expecting non null failure for a failed IndexShardSnapshotStatus"; | ||
if (failure == null) { | ||
throw new IllegalArgumentException("A failure description is required for a failed IndexShardSnapshotStatus"); | ||
} | ||
return new IndexShardSnapshotStatus(Stage.FAILURE, 0L, 0L, 0, 0, 0, 0, 0, 0, failure, null).asCopy(); | ||
return new IndexShardSnapshotStatus(Stage.FAILURE, 0L, 0L, 0, 0, 0, 0, 0, 0, failure, null, "instantiated as failed").asCopy(); | ||
} | ||
|
||
public static IndexShardSnapshotStatus.Copy newDone( | ||
|
@@ -326,7 +337,8 @@ public static IndexShardSnapshotStatus.Copy newDone( | |
size, | ||
incrementalSize, | ||
null, | ||
generation | ||
generation, | ||
"instantiated as done" | ||
).asCopy(); | ||
} | ||
|
||
|
@@ -345,6 +357,7 @@ public static class Copy { | |
private final long processedSize; | ||
private final long incrementalSize; | ||
private final String failure; | ||
private final String debugStatusString; | ||
|
||
public Copy( | ||
final Stage stage, | ||
|
@@ -356,7 +369,8 @@ public Copy( | |
final long incrementalSize, | ||
final long totalSize, | ||
final long processedSize, | ||
final String failure | ||
final String failure, | ||
final String debugStatusString | ||
) { | ||
this.stage = stage; | ||
this.startTime = startTime; | ||
|
@@ -368,6 +382,7 @@ public Copy( | |
this.processedSize = processedSize; | ||
this.incrementalSize = incrementalSize; | ||
this.failure = failure; | ||
this.debugStatusString = debugStatusString; | ||
} | ||
|
||
public Stage getStage() { | ||
|
@@ -410,6 +425,10 @@ public String getFailure() { | |
return failure; | ||
} | ||
|
||
public String getDebugStatusString() { | ||
return debugStatusString; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "index shard snapshot status (" | ||
|
@@ -433,6 +452,8 @@ public String toString() { | |
+ processedSize | ||
+ ", failure='" | ||
+ failure | ||
+ "', debugStatusString='" | ||
+ debugStatusString | ||
+ '\'' | ||
+ ')'; | ||
} | ||
|
@@ -461,6 +482,8 @@ public String toString() { | |
+ processedSize | ||
+ ", failure='" | ||
+ failure | ||
+ "', debugStatusString='" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure about exposing this to users as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. updated to statusDescription 👍 |
||
+ debugStatusString | ||
+ '\'' | ||
+ ')'; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs to be
volatile
so thattoString()
and friends all see the latest value. And in that case there's no need to make the update methodsynchronized
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, the toString(). Changed 👍 .