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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ private ObjectNode getJsonObject(SnapshotDiffResponse diffResponse) {
if (StringUtils.isNotEmpty(diffResponse.getReason())) {
diffResponseNode.put("reason", diffResponse.getReason());
}
if (diffResponse.getSubStatus() != null) {
SnapshotDiffResponse.SubStatus sub = diffResponse.getSubStatus();
diffResponseNode.put("subStatus", sub.name());
if (sub.hasProgress()) {
diffResponseNode.put("progressPercent", diffResponse.getProgressPercent());
}
}
return diffResponseNode;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,7 @@ public String toString() {
}
if (status.equals(JobStatus.IN_PROGRESS) && subStatus != null) {
sb.append(", subStatus: ").append(subStatus);
if (subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_FSO) ||
subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_OBS)) {
if (subStatus.hasProgress()) {
sb.append(String.format(", keysProcessedPct: %.2f", keysProcessedPct));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1468,12 +1468,19 @@ private SnapshotDiffResponse snapshotDiffInternal(String volumeName,
OzoneManagerProtocolProtos.SnapshotDiffResponse diffResponse =
omResponse.getSnapshotDiffResponse();

return new SnapshotDiffResponse(SnapshotDiffReportOzone.fromProtobuf(
diffResponse.getSnapshotDiffReport()),
SnapshotDiffResponse result = new SnapshotDiffResponse(
SnapshotDiffReportOzone.fromProtobuf(diffResponse.getSnapshotDiffReport()),
JobStatus.fromProtobuf(diffResponse.getJobStatus()),
diffResponse.getWaitTimeInMs(),
diffResponse.getReason(),
reportOnly);
if (diffResponse.hasSubStatus()) {
result.setSubStatus(SnapshotDiffResponse.SubStatus.fromProtoBuf(diffResponse.getSubStatus()));
if (diffResponse.hasProgressPercent()) {
result.setProgressPercent(diffResponse.getProgressPercent());
}
}
return result;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,18 @@ public String getReason() {
return reason;
}

public SubStatus getSubStatus() {
return subStatus;
}

public void setSubStatus(SubStatus subStatus) {
this.subStatus = subStatus;
}

public double getProgressPercent() {
return progressPercent;
}

public void setProgressPercent(double progressPercent) {
this.progressPercent = progressPercent;
}
Expand Down Expand Up @@ -143,11 +151,10 @@ public String toString() {
str.append(".\n");
if (subStatus != null) {
str.append("SubStatus : ")
.append(subStatus);
if (subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_OBS) ||
subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_FSO)) {
str.append("Keys Processed Estimated Percentage : ")
.append(progressPercent);
.append(subStatus)
.append('\n');
if (subStatus.hasProgress()) {
str.append(String.format("Keys Processed Estimated Percentage : %.1f%n", progressPercent));
}
}
}
Expand Down Expand Up @@ -182,8 +189,17 @@ public enum SubStatus {
SST_FILE_DELTA_DAG_WALK,
SST_FILE_DELTA_FULL_DIFF,
OBJECT_ID_MAP_GEN_OBS,
@Deprecated
OBJECT_ID_MAP_GEN_FSO,
DIFF_REPORT_GEN;
DIFF_REPORT_GEN,
PATH_RESOLUTION_FSO,
OBJECT_ID_MAP_GEN_FSO_FILE,
OBJECT_ID_MAP_GEN_FSO_DIR;

public boolean hasProgress() {
return this == OBJECT_ID_MAP_GEN_OBS || this == OBJECT_ID_MAP_GEN_FSO || this == OBJECT_ID_MAP_GEN_FSO_FILE
|| this == OBJECT_ID_MAP_GEN_FSO_DIR;
}

public static SubStatus fromProtoBuf(OzoneManagerProtocolProtos.SnapshotDiffResponse.SubStatus subStatusProto) {
return SubStatus.valueOf(subStatusProto.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@

package org.apache.hadoop.ozone.snapshot;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Collections;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.EnumSource.Mode;

class TestSnapshotDiffResponse {

Expand Down Expand Up @@ -57,20 +61,48 @@ void testReportOnlyFailedMessageIncludesReason() {
assertTrue(message.contains("resubmit the job without using the --get-report option"));
}

@Test
void testReportOnlyInProgressIncludesSubStatusAndProgress() {
@ParameterizedTest
@EnumSource(value = SubStatus.class, names = {"OBJECT_ID_MAP_GEN_OBS", "OBJECT_ID_MAP_GEN_FSO",
"OBJECT_ID_MAP_GEN_FSO_FILE", "OBJECT_ID_MAP_GEN_FSO_DIR"})
void testInProgressWithMapGenSubStatusIncludesProgress(SubStatus subStatus) {
SnapshotDiffResponse response = new SnapshotDiffResponse(createReport(),
JobStatus.IN_PROGRESS, 1000L, true);
response.setSubStatus(SubStatus.OBJECT_ID_MAP_GEN_OBS);
response.setSubStatus(subStatus);
response.setProgressPercent(55.5);

String message = response.toString();
assertTrue(message.contains("IN_PROGRESS"));
assertTrue(message.contains("OBJECT_ID_MAP_GEN_OBS"));
assertTrue(message.contains(subStatus.name()));
assertTrue(message.contains("Keys Processed Estimated Percentage"));
assertTrue(message.contains("55.5"));
}

@ParameterizedTest
@EnumSource(value = SubStatus.class,
names = {"OBJECT_ID_MAP_GEN_OBS", "OBJECT_ID_MAP_GEN_FSO", "OBJECT_ID_MAP_GEN_FSO_FILE",
"OBJECT_ID_MAP_GEN_FSO_DIR"},
mode = Mode.EXCLUDE)
void testInProgressWithNonMapGenSubStatusRendersSubStatusButNotProgress(SubStatus subStatus) {
SnapshotDiffResponse response = new SnapshotDiffResponse(createReport(), JobStatus.IN_PROGRESS, 1000L, true);
response.setSubStatus(subStatus);
response.setProgressPercent(55.5);

String message = response.toString();
assertTrue(message.contains("IN_PROGRESS"));
assertTrue(message.contains(subStatus.name()));
assertFalse(message.contains("Keys Processed Estimated Percentage"));
assertFalse(message.contains("55.5"));
}

@Test
void testInProgressWithNullSubStatusOmitsSubStatusAndProgressLines() {
SnapshotDiffResponse response = new SnapshotDiffResponse(createReport(), JobStatus.IN_PROGRESS, 1000L, true);
String message = response.toString();
assertTrue(message.contains("IN_PROGRESS"));
assertFalse(message.contains("SubStatus"));
assertFalse(message.contains("Keys Processed Estimated Percentage"));
}

private SnapshotDiffReportOzone createReport() {
return new SnapshotDiffReportOzone("snapshotRoot", "vol", "bucket", "fromSnap",
"toSnap", Collections.emptyList(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2254,15 +2254,19 @@ message SnapshotDiffResponse {
SST_FILE_DELTA_DAG_WALK = 1;
SST_FILE_DELTA_FULL_DIFF = 2;
OBJECT_ID_MAP_GEN_OBS = 3;
OBJECT_ID_MAP_GEN_FSO = 4;
OBJECT_ID_MAP_GEN_FSO = 4 [deprecated = true];
DIFF_REPORT_GEN = 5;
PATH_RESOLUTION_FSO = 6;
Comment thread
smengcl marked this conversation as resolved.
OBJECT_ID_MAP_GEN_FSO_FILE = 7;
OBJECT_ID_MAP_GEN_FSO_DIR = 8;
}

optional SnapshotDiffReportProto snapshotDiffReport = 1;
optional JobStatusProto jobStatus = 2;
optional int64 waitTimeInMs = 3;
optional string reason = 4;
optional SubStatus subStatus = 5;
optional double progressPercent = 6;
}

message SubmitSnapshotDiffResponse {
Expand Down
18 changes: 18 additions & 0 deletions hadoop-ozone/interface-client/src/main/resources/proto.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,18 @@
{
"name": "DIFF_REPORT_GEN",
"integer": 5
},
{
"name": "PATH_RESOLUTION_FSO",
"integer": 6
},
{
"name": "OBJECT_ID_MAP_GEN_FSO_FILE",
"integer": 7
},
{
"name": "OBJECT_ID_MAP_GEN_FSO_DIR",
"integer": 8
}
]
},
Expand Down Expand Up @@ -8103,6 +8115,12 @@
"name": "subStatus",
"type": "SubStatus",
"optional": true
},
{
"id": 6,
"name": "progressPercent",
"type": "double",
"optional": true
}
]
},
Expand Down
Loading