Skip to content
Merged
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 @@ -26,6 +26,7 @@
import org.apache.hadoop.hdds.utils.db.Codec;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SnapshotDiffJobProto;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.SubStatus;

/**
* POJO for Snapshot diff job.
Expand Down Expand Up @@ -54,6 +55,13 @@ public static Codec<SnapshotDiffJob> getCodec() {
// is FAILED.
private String reason;

// Represents current sub-status of the job if the job is in IN_PROGRESS state.
private SubStatus subStatus;
// percentage of keys processed in the Object-ID generation phase.
// This is the most time-consuming phase as it loads both snapshots
// and reads from it populating the ObjectID-key map.
private double keysProcessedPct;

// Default constructor for Jackson Serializer.
public SnapshotDiffJob() {

Expand All @@ -69,7 +77,9 @@ public SnapshotDiffJob(long creationTime,
String toSnapshot,
boolean forceFullDiff,
boolean disableNativeDiff,
long totalDiffEntries) {
long totalDiffEntries,
SubStatus subStatus,
double keysProcessedPct) {
this.creationTime = creationTime;
this.jobId = jobId;
this.status = jobStatus;
Expand All @@ -81,6 +91,8 @@ public SnapshotDiffJob(long creationTime,
this.disableNativeDiff = disableNativeDiff;
this.totalDiffEntries = totalDiffEntries;
this.reason = StringUtils.EMPTY;
this.subStatus = subStatus;
this.keysProcessedPct = keysProcessedPct;
}

public String getJobId() {
Expand Down Expand Up @@ -171,6 +183,22 @@ public void disableNativeDiff(boolean disableNativeDiffVal) {
this.disableNativeDiff = disableNativeDiffVal;
}

public SubStatus getSubStatus() {
return subStatus;
}

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

public double getKeysProcessedPct() {
return keysProcessedPct;
}

public void setKeysProcessedPct(double keysProcessedPct) {
this.keysProcessedPct = keysProcessedPct;
}

@Override
public String toString() {
StringBuilder sb = new StringBuilder("creationTime : ").append(creationTime)
Expand All @@ -187,6 +215,13 @@ public String toString() {
if (StringUtils.isNotEmpty(reason)) {
sb.append(", reason: ").append(reason);
}
if (status.equals(JobStatus.IN_PROGRESS) && subStatus != null) {
sb.append(", subStatus: ").append(status);
if (subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_FSO) ||
subStatus.equals(SubStatus.OBJECT_ID_MAP_GEN_OBS)) {
sb.append(String.format(", keysProcessedPercent: %.2f", keysProcessedPct));
}
}
return sb.toString();
}

Expand All @@ -208,7 +243,9 @@ public boolean equals(Object other) {
Objects.equals(this.forceFullDiff, otherJob.forceFullDiff) &&
Objects.equals(this.totalDiffEntries, otherJob.totalDiffEntries) &&
Objects.equals(this.disableNativeDiff, otherJob.disableNativeDiff)
&& Objects.equals(this.reason, otherJob.reason);
&& Objects.equals(this.reason, otherJob.reason) &&
Objects.equals(this.subStatus, otherJob.subStatus) &&
Objects.equals(this.keysProcessedPct, otherJob.keysProcessedPct);
}
return false;
}
Expand All @@ -217,7 +254,7 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(creationTime, jobId, status, volume, bucket,
fromSnapshot, toSnapshot, forceFullDiff, disableNativeDiff,
totalDiffEntries, reason);
totalDiffEntries, reason, subStatus, keysProcessedPct);
}

public SnapshotDiffJobProto toProtoBuf() {
Expand All @@ -232,6 +269,8 @@ public SnapshotDiffJobProto toProtoBuf() {
.setForceFullDiff(forceFullDiff)
.setDisableNativeDiff(disableNativeDiff)
.setTotalDiffEntries(totalDiffEntries)
.setSubStatus(subStatus.toProtoBuf())
.setKeysProcessedPct(keysProcessedPct)
.build();
}

Expand All @@ -247,7 +286,9 @@ public static SnapshotDiffJob getFromProtoBuf(
diffJobProto.getToSnapshot(),
diffJobProto.getForceFullDiff(),
diffJobProto.getDisableNativeDiff(),
diffJobProto.getTotalDiffEntries());
diffJobProto.getTotalDiffEntries(),
SubStatus.fromProtoBuf(diffJobProto.getSubStatus()),
diffJobProto.getKeysProcessedPct());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.ozone.snapshot;

import org.apache.commons.lang3.StringUtils;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.SnapshotDiffResponse.JobStatusProto;

/**
Expand All @@ -44,11 +45,31 @@ public static JobStatus fromProtobuf(JobStatusProto jobStatusProto) {
return JobStatus.valueOf(jobStatusProto.name());
}
}
/**
* Snapshot diff job sub-status enum.
*/
public enum SubStatus {
SST_FILE_DELTA_DAG_WALK,
SST_FILE_DELTA_FULL_DIFF,
OBJECT_ID_MAP_GEN_OBS,
OBJECT_ID_MAP_GEN_FSO,
DIFF_REPORT_GEN;

public static SubStatus fromProtoBuf(OzoneManagerProtocolProtos.SnapshotDiffResponse.SubStatus subStatusProto) {
return SubStatus.valueOf(subStatusProto.name());
}

public OzoneManagerProtocolProtos.SnapshotDiffResponse.SubStatus toProtoBuf() {
return OzoneManagerProtocolProtos.SnapshotDiffResponse.SubStatus.valueOf(this.name());
}
}

private final SnapshotDiffReportOzone snapshotDiffReport;
private final JobStatus jobStatus;
private final long waitTimeInMs;
private final String reason;
private SubStatus subStatus;
private double progressPercent = 0.0;

public SnapshotDiffResponse(final SnapshotDiffReportOzone snapshotDiffReport,
final JobStatus jobStatus,
Expand Down Expand Up @@ -85,6 +106,14 @@ public String getReason() {
return reason;
}

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

public void setProgressPercent(double progressPercent) {
this.progressPercent = progressPercent;
}

@Override
public String toString() {
StringBuilder str = new StringBuilder();
Expand Down Expand Up @@ -112,6 +141,15 @@ public String toString() {
.append(". Please retry after ")
.append(waitTimeInMs)
.append(" ms.\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);
}
}
}
return str.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,8 @@ message SnapshotDiffJobProto {
optional uint64 totalDiffEntries = 9;
optional string message = 10;
optional bool disableNativeDiff = 11;
optional SnapshotDiffResponse.SubStatus subStatus = 12;
optional double keysProcessedPct = 13;
}

message OzoneObj {
Expand Down Expand Up @@ -2101,10 +2103,19 @@ message SnapshotDiffResponse {
CANCELLED = 6;
}

enum SubStatus {
SST_FILE_DELTA_DAG_WALK = 1;
SST_FILE_DELTA_FULL_DIFF = 2;
OBJECT_ID_MAP_GEN_OBS = 3;
OBJECT_ID_MAP_GEN_FSO = 4;
DIFF_REPORT_GEN = 5;
}

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

message CancelSnapshotDiffResponse {
Expand Down
Loading