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
2 changes: 1 addition & 1 deletion hadoop-hdds/common/src/main/resources/ozone-default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3991,7 +3991,7 @@

<property>
<name>ozone.om.snapshot.diff.cleanup.service.run.internal</name>
<value>60m</value>
<value>1m</value>
<tag>OZONE, OM</tag>
<description>
Interval at which snapshot diff clean up service will run.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.hadoop.ozone.om.helpers.TenantUserList;
import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponse;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.security.UserGroupInformation;

Expand Down Expand Up @@ -667,22 +668,37 @@ private List<OzoneSnapshot> getNextListOfSnapshots(String prevSnapshot)
* @param token to get the index to return diff report from.
* @param pageSize maximum entries returned to the report.
* @param forceFullDiff request to force full diff, skipping DAG optimization
* @param cancel request to cancel a running snapshot diff job.
* @return the difference report between two snapshots
* @throws IOException in case of any exception while generating snapshot diff
*/
@SuppressWarnings("parameternumber")
public SnapshotDiffResponse snapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot,
String token,
int pageSize,
boolean forceFullDiff,
boolean cancel)
boolean forceFullDiff)
throws IOException {
return proxy.snapshotDiff(volumeName, bucketName, fromSnapshot, toSnapshot,
token, pageSize, forceFullDiff, cancel);
token, pageSize, forceFullDiff);
}

/**
* Cancel the snap diff jobs.
* @param volumeName Name of the volume to which the snapshot bucket belong
* @param bucketName Name of the bucket to which the snapshots belong
* @param fromSnapshot The name of the starting snapshot
* @param toSnapshot The name of the ending snapshot
* @return the success if cancel succeeds.
* @throws IOException in case of any exception while generating snapshot diff
*/
public CancelSnapshotDiffResponse cancelSnapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot)
throws IOException {
return proxy.cancelSnapshotDiff(volumeName, bucketName, fromSnapshot,
toSnapshot);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.OMRoleInfo;
import org.apache.hadoop.ozone.security.OzoneTokenIdentifier;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponse;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.security.KerberosInfo;
import org.apache.hadoop.security.token.Token;
Expand Down Expand Up @@ -1058,7 +1059,6 @@ List<OzoneSnapshot> listSnapshot(
String volumeName, String bucketName, String snapshotPrefix,
String prevSnapshot, int maxListResult) throws IOException;


/**
* Get the differences between two snapshots.
* @param volumeName Name of the volume to which the snapshotted bucket belong
Expand All @@ -1068,15 +1068,28 @@ List<OzoneSnapshot> listSnapshot(
* @param token to get the index to return diff report from.
* @param pageSize maximum entries returned to the report.
* @param forceFullDiff request to force full diff, skipping DAG optimization
* @param cancel request to cancel a running snapshot diff job.
* @return the difference report between two snapshots
* @throws IOException in case of any exception while generating snapshot diff
*/
@SuppressWarnings("parameternumber")
SnapshotDiffResponse snapshotDiff(String volumeName, String bucketName,
String fromSnapshot, String toSnapshot,
String token, int pageSize,
boolean forceFullDiff, boolean cancel)
boolean forceFullDiff)
throws IOException;

/**
* Cancel snapshot diff job.
* @param volumeName Name of the volume to which the snapshotted bucket belong
* @param bucketName Name of the bucket to which the snapshots belong
* @param fromSnapshot The name of the starting snapshot
* @param toSnapshot The name of the ending snapshot
* @return the success if cancel succeeds.
* @throws IOException in case of any exception while cancelling snap diff job
*/
CancelSnapshotDiffResponse cancelSnapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot)
throws IOException;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
import org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType;
import org.apache.hadoop.ozone.security.acl.OzoneAclConfig;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponse;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.token.Token;
Expand Down Expand Up @@ -986,15 +987,32 @@ public SnapshotDiffResponse snapshotDiff(String volumeName,
String toSnapshot,
String token,
int pageSize,
boolean forceFullDiff,
boolean cancel)
boolean forceFullDiff)
throws IOException {
Preconditions.checkArgument(StringUtils.isNotBlank(volumeName),
"volume can't be null or empty.");
Preconditions.checkArgument(StringUtils.isNotBlank(bucketName),
"bucket can't be null or empty.");
return ozoneManagerClient.snapshotDiff(volumeName, bucketName,
fromSnapshot, toSnapshot, token, pageSize, forceFullDiff, cancel);
fromSnapshot, toSnapshot, token, pageSize, forceFullDiff);
}

@Override
public CancelSnapshotDiffResponse cancelSnapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot)
throws IOException {
Preconditions.checkArgument(StringUtils.isNotBlank(volumeName),
"volume can't be null or empty.");
Preconditions.checkArgument(StringUtils.isNotBlank(bucketName),
"bucket can't be null or empty.");
Preconditions.checkArgument(StringUtils.isNotBlank(fromSnapshot),
"fromSnapshot can't be null or empty.");
Preconditions.checkArgument(StringUtils.isNotBlank(toSnapshot),
"toSnapshot can't be null or empty.");
return ozoneManagerClient.cancelSnapshotDiff(volumeName, bucketName,
fromSnapshot, toSnapshot);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ public static boolean isReadOnly(
// operation SetRangerServiceVersion.
case GetKeyInfo:
case SnapshotDiff:
case CancelSnapshotDiff:
case ListSnapshotDiffJobs:
case TransferLeadership:
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ private OMConfigKeys() {
= "ozone.om.snapshot.diff.cleanup.service.run.internal";
public static final long
OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_RUN_INTERVAL_DEFAULT
= TimeUnit.HOURS.toMillis(1);
= TimeUnit.MINUTES.toMillis(1);

public static final String OZONE_OM_SNAPSHOT_DIFF_CLEANUP_SERVICE_TIMEOUT
= "ozone.om.snapshot.diff.cleanup.service.timeout";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;
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;
Expand All @@ -48,6 +50,10 @@ public static Codec<SnapshotDiffJob> getCodec() {
private boolean forceFullDiff;
private long totalDiffEntries;

// Reason tells why the job was FAILED. It should be set only if job status
// is FAILED.
private String reason;

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

Expand All @@ -72,6 +78,7 @@ public SnapshotDiffJob(long creationTime,
this.toSnapshot = toSnapshot;
this.forceFullDiff = forceFullDiff;
this.totalDiffEntries = totalDiffEntries;
this.reason = StringUtils.EMPTY;
}

public String getJobId() {
Expand Down Expand Up @@ -146,17 +153,30 @@ public void setTotalDiffEntries(long totalDiffEntries) {
this.totalDiffEntries = totalDiffEntries;
}

public String getReason() {
return reason;
}

public void setReason(String reason) {
this.reason = reason;
}

@Override
public String toString() {
return "creationTime : " + creationTime +
", jobId: " + jobId +
", status: " + status +
", volume: " + volume +
", bucket: " + bucket +
", fromSnapshot: " + fromSnapshot +
", toSnapshot: " + toSnapshot +
", forceFullDiff: " + forceFullDiff +
", totalDiffEntries: " + totalDiffEntries;
StringBuilder sb = new StringBuilder("creationTime : ").append(creationTime)
.append(", jobId: ").append(jobId)
.append(", status: ").append(status)
.append(", volume: ").append(volume)
.append(", bucket: ").append(bucket)
.append(", fromSnapshot: ").append(fromSnapshot)
.append(", toSnapshot: ").append(toSnapshot)
.append(", forceFullDiff: ").append(forceFullDiff)
.append(", totalDiffEntries: ").append(totalDiffEntries);

if (StringUtils.isNotEmpty(reason)) {
sb.append(", reason: ").append(reason);
}
return sb.toString();
}

@Override
Expand All @@ -175,15 +195,16 @@ public boolean equals(Object other) {
Objects.equals(this.fromSnapshot, otherJob.fromSnapshot) &&
Objects.equals(this.toSnapshot, otherJob.toSnapshot) &&
Objects.equals(this.forceFullDiff, otherJob.forceFullDiff) &&
Objects.equals(this.totalDiffEntries, otherJob.totalDiffEntries);
Objects.equals(this.totalDiffEntries, otherJob.totalDiffEntries) &&
Objects.equals(this.reason, otherJob.reason);
}
return false;
}

@Override
public int hashCode() {
return Objects.hash(creationTime, jobId, status, volume, bucket,
fromSnapshot, toSnapshot, forceFullDiff, totalDiffEntries);
fromSnapshot, toSnapshot, forceFullDiff, totalDiffEntries, reason);
}

public SnapshotDiffJobProto toProtoBuf() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.EchoRPCResponse;
import org.apache.hadoop.ozone.security.OzoneDelegationTokenSelector;
import org.apache.hadoop.ozone.security.acl.OzoneObj;
import org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponse;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages;
import org.apache.hadoop.security.KerberosInfo;
Expand Down Expand Up @@ -715,19 +716,34 @@ default List<SnapshotInfo> listSnapshot(
* @param token to get the index to return diff report from.
* @param pageSize maximum entries returned to the report.
* @param forceFullDiff request to force full diff, skipping DAG optimization
* @param cancel request to cancel a running snapshot diff job.
* @return the difference report between two snapshots
* @throws IOException in case of any exception while generating snapshot diff
*/
@SuppressWarnings("parameternumber")
default SnapshotDiffResponse snapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot,
String token,
int pageSize,
boolean forceFullDiff,
boolean cancel)
boolean forceFullDiff)
throws IOException {
throw new UnsupportedOperationException("OzoneManager does not require " +
"this to be implemented");
}

/**
* Cancel snapshot diff job.
* @param volumeName Name of the volume to which the snapshotted bucket belong
* @param bucketName Name of the bucket to which the snapshots belong
* @param fromSnapshot The name of the starting snapshot
* @param toSnapshot The name of the ending snapshot
* @return the success if cancel succeeds.
* @throws IOException in case of any exception while cancelling snap diff job
*/
default CancelSnapshotDiffResponse cancelSnapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot)
throws IOException {
throw new UnsupportedOperationException("OzoneManager does not require " +
"this to be implemented");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@
import org.apache.hadoop.ozone.security.proto.SecurityProtos.CancelDelegationTokenRequestProto;
import org.apache.hadoop.ozone.security.proto.SecurityProtos.GetDelegationTokenRequestProto;
import org.apache.hadoop.ozone.security.proto.SecurityProtos.RenewDelegationTokenRequestProto;
import org.apache.hadoop.ozone.snapshot.CancelSnapshotDiffResponse;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffReportOzone;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobStatus;
import org.apache.hadoop.ozone.snapshot.SnapshotDiffResponse.JobCancelResult;
import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer;
import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer.StatusAndMessages;
import org.apache.hadoop.security.token.Token;
Expand Down Expand Up @@ -1217,8 +1217,7 @@ public SnapshotDiffResponse snapshotDiff(String volumeName,
String toSnapshot,
String token,
int pageSize,
boolean forceFullDiff,
boolean cancel)
boolean forceFullDiff)
throws IOException {
final OzoneManagerProtocolProtos.SnapshotDiffRequest.Builder
requestBuilder =
Expand All @@ -1228,8 +1227,7 @@ public SnapshotDiffResponse snapshotDiff(String volumeName,
.setFromSnapshot(fromSnapshot)
.setToSnapshot(toSnapshot)
.setPageSize(pageSize)
.setForceFullDiff(forceFullDiff)
.setCancel(cancel);
.setForceFullDiff(forceFullDiff);

if (!StringUtils.isBlank(token)) {
requestBuilder.setToken(token);
Expand All @@ -1247,7 +1245,36 @@ public SnapshotDiffResponse snapshotDiff(String volumeName,
diffResponse.getSnapshotDiffReport()),
JobStatus.fromProtobuf(diffResponse.getJobStatus()),
diffResponse.getWaitTimeInMs(),
JobCancelResult.fromProtobuf(diffResponse.getJobCancelResult()));
diffResponse.getReason());
}

/**
* {@inheritDoc}
*/
@Override
public CancelSnapshotDiffResponse cancelSnapshotDiff(String volumeName,
String bucketName,
String fromSnapshot,
String toSnapshot)
throws IOException {
final OzoneManagerProtocolProtos.CancelSnapshotDiffRequest.Builder
requestBuilder =
OzoneManagerProtocolProtos.CancelSnapshotDiffRequest.newBuilder()
.setVolumeName(volumeName)
.setBucketName(bucketName)
.setFromSnapshot(fromSnapshot)
.setToSnapshot(toSnapshot);

final OMRequest omRequest = createOMRequest(Type.CancelSnapshotDiff)
.setCancelSnapshotDiffRequest(requestBuilder)
.build();

final OMResponse omResponse = submitRequest(omRequest);
handleError(omResponse);
OzoneManagerProtocolProtos.CancelSnapshotDiffResponse diffResponse =
omResponse.getCancelSnapshotDiffResponse();

return new CancelSnapshotDiffResponse(diffResponse.getReason());
}

/**
Expand Down
Loading