SaketaChalamchala commented on code in PR #9985:
URL: https://github.com/apache/ozone/pull/9985#discussion_r3061111720
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/snapshot/SnapshotDiffManager.java:
##########
@@ -549,6 +552,132 @@ public SnapshotDiffResponse getSnapshotDiffReport(
}
}
+ public SnapshotDiffResponse getSnapshotDiffReport(
+ final String volumeName,
+ final String bucketName,
+ final String fromSnapshotName,
+ final String toSnapshotName,
+ final String index,
+ final int pageSize
+ ) throws IOException {
+
+ SnapshotInfo fsInfo = getSnapshotInfo(ozoneManager,
+ volumeName, bucketName, fromSnapshotName);
+ SnapshotInfo tsInfo = getSnapshotInfo(ozoneManager,
+ volumeName, bucketName, toSnapshotName);
+
+ String snapDiffJobKey = generateSnapDiffJobKey.apply(fsInfo, tsInfo);
+ SnapshotDiffJob snapDiffJob = snapDiffJobTable.get(snapDiffJobKey);
+ OFSPath snapshotRoot = getSnapshotRootPath(volumeName, bucketName);
+
+ if (snapDiffJob == null) {
+ return new SnapshotDiffResponse(
+ new SnapshotDiffReportOzone(snapshotRoot.toString(), volumeName,
bucketName,
+ fromSnapshotName, toSnapshotName,
+ new ArrayList<>(), null), NOT_FOUND, defaultWaitTime);
+ }
+
+ switch (snapDiffJob.getStatus()) {
+ case QUEUED:
+ case REJECTED:
+ return new SnapshotDiffResponse(
+ new SnapshotDiffReportOzone(snapshotRoot.toString(), volumeName,
+ bucketName, fromSnapshotName, toSnapshotName, new ArrayList<>(),
+ null),
+ snapDiffJob.getStatus(), defaultWaitTime, true);
+ case IN_PROGRESS:
+ SnapshotDiffResponse response = new SnapshotDiffResponse(
+ new SnapshotDiffReportOzone(snapshotRoot.toString(), volumeName,
bucketName,
+ fromSnapshotName, toSnapshotName,
+ new ArrayList<>(), null), IN_PROGRESS, defaultWaitTime, true);
+ response.setSubStatus(snapDiffJob.getSubStatus());
+ response.setProgressPercent(snapDiffJob.getKeysProcessedPct());
+ return response;
+ case FAILED:
+ return new SnapshotDiffResponse(
+ new SnapshotDiffReportOzone(snapshotRoot.toString(), volumeName,
+ bucketName, fromSnapshotName, toSnapshotName, new ArrayList<>(),
+ null), FAILED,
+ // waitTime is equal to clean up internal. After that job will be
+ // removed and client can retry.
+ ozoneManager.getOmSnapshotManager().getDiffCleanupServiceInterval(),
+ snapDiffJob.getReason(), true);
+ case DONE:
+ SnapshotDiffReportOzone report = createPageResponse(snapDiffJob,
+ volumeName, bucketName, fromSnapshotName, toSnapshotName, index,
+ pageSize);
+ return new SnapshotDiffResponse(report, DONE, 0L, true);
+ case CANCELLED:
+ return new SnapshotDiffResponse(
+ new SnapshotDiffReportOzone(snapshotRoot.toString(), volumeName,
+ bucketName, fromSnapshotName, toSnapshotName, new ArrayList<>(),
+ null),
+ CANCELLED, 0L, true);
+ default:
+ throw new IllegalStateException("Unknown snapshot job status: " +
+ snapDiffJob.getStatus());
+ }
+ }
+
+ public synchronized SubmitSnapshotDiffResponse submitSnapshotDiff(
+ final String volumeName,
+ final String bucketName,
+ final String fromSnapshotName,
+ final String toSnapshotName,
+ final boolean forceFullDiff,
+ final boolean disableNativeDiff
+ ) throws IOException {
+ SnapshotInfo fsInfo = getSnapshotInfo(ozoneManager,
+ volumeName, bucketName, fromSnapshotName);
+ SnapshotInfo tsInfo = getSnapshotInfo(ozoneManager,
+ volumeName, bucketName, toSnapshotName);
+
+ String snapDiffJobKey = generateSnapDiffJobKey.apply(fsInfo, tsInfo);
+
+ SnapshotDiffJob snapDiffJob = getSnapDiffReportStatus(snapDiffJobKey,
+ volumeName, bucketName, fromSnapshotName, toSnapshotName,
+ forceFullDiff, disableNativeDiff);
+
+ JobStatus prevStatus = snapDiffJob.getStatus();
+ String prevReason = snapDiffJob.getReason();
+
+ switch (prevStatus) {
+ case QUEUED:
+ case FAILED:
+ case REJECTED:
+ case CANCELLED:
+ LOG.info("Submitting snapshot diff generation request for" +
+ " volume: {}, bucket: {}, fromSnapshot: {} and toSnapshot: {}",
+ volumeName, bucketName, fromSnapshotName, toSnapshotName);
+ try {
+ updateJobStatus(snapDiffJobKey, prevStatus, IN_PROGRESS);
+ snapDiffExecutor.execute(() ->
generateSnapshotDiffReport(snapDiffJobKey, snapDiffJob.getJobId(),
+ volumeName, bucketName, fromSnapshotName, toSnapshotName,
+ forceFullDiff, disableNativeDiff));
+ if (prevStatus == QUEUED) {
+ return new SubmitSnapshotDiffResponse(defaultWaitTime, null, null);
+ } else {
+ return new SubmitSnapshotDiffResponse(defaultWaitTime, prevStatus,
prevReason);
+ }
Review Comment:
Addressed this comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]