Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/95731.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 95731
summary: Implement `StartRecoveryRequest#getDescription`
area: Recovery
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
package org.elasticsearch.indices.recovery;

import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.index.seqno.SequenceNumbers;
Expand Down Expand Up @@ -123,6 +124,22 @@ public boolean canDownloadSnapshotFiles() {
return canDownloadSnapshotFiles;
}

@Override
public String getDescription() {
return Strings.format(
"""
recovery of %s to %s \
[recoveryId=%d, targetAllocationId=%s, startingSeqNo=%d, primaryRelocation=%s, canDownloadSnapshotFiles=%s]""",
shardId,
targetNode.descriptionWithoutAttributes(),
recoveryId,
targetAllocationId,
startingSeqNo,
primaryRelocation,
canDownloadSnapshotFiles
);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,25 @@ public void testSerialization() throws Exception {
assertThat(outRequest.startingSeqNo(), equalTo(inRequest.startingSeqNo()));
}

public void testDescription() {
final var node = new DiscoveryNode("a", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT);
assertEquals(
"recovery of [index][0] to "
+ node.descriptionWithoutAttributes()
+ " [recoveryId=1, targetAllocationId=allocationId, startingSeqNo=-2, "
+ "primaryRelocation=false, canDownloadSnapshotFiles=true]",
new StartRecoveryRequest(
new ShardId("index", "uuid", 0),
"allocationId",
null,
node,
Store.MetadataSnapshot.EMPTY,
false,
1,
SequenceNumbers.UNASSIGNED_SEQ_NO,
true
).getDescription()
);
}

}