|
@@ -3529,6 +3529,8 @@ public abstract class FSEditLogOp {
|
|
|
static class DeleteSnapshotOp extends FSEditLogOp {
|
|
|
String snapshotRoot;
|
|
|
String snapshotName;
|
|
|
+ /** Modification time of the edit set by Time.now(). */
|
|
|
+ long mtime;
|
|
|
|
|
|
DeleteSnapshotOp() {
|
|
|
super(OP_DELETE_SNAPSHOT);
|
|
@@ -3542,22 +3544,32 @@ public abstract class FSEditLogOp {
|
|
|
void resetSubFields() {
|
|
|
snapshotRoot = null;
|
|
|
snapshotName = null;
|
|
|
+ mtime = 0L;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /* set the name of the snapshot. */
|
|
|
DeleteSnapshotOp setSnapshotName(String snapName) {
|
|
|
this.snapshotName = snapName;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /* set the directory path where the snapshot is taken. */
|
|
|
DeleteSnapshotOp setSnapshotRoot(String snapRoot) {
|
|
|
snapshotRoot = snapRoot;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /* The snapshot deletion time set by Time.now(). */
|
|
|
+ DeleteSnapshotOp setSnapshotMTime(long mTime) {
|
|
|
+ this.mtime = mTime;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
void readFields(DataInputStream in, int logVersion) throws IOException {
|
|
|
snapshotRoot = FSImageSerialization.readString(in);
|
|
|
snapshotName = FSImageSerialization.readString(in);
|
|
|
+ mtime = FSImageSerialization.readLong(in);
|
|
|
|
|
|
// read RPC ids if necessary
|
|
|
readRpcIds(in, logVersion);
|
|
@@ -3567,6 +3579,7 @@ public abstract class FSEditLogOp {
|
|
|
public void writeFields(DataOutputStream out) throws IOException {
|
|
|
FSImageSerialization.writeString(snapshotRoot, out);
|
|
|
FSImageSerialization.writeString(snapshotName, out);
|
|
|
+ FSImageSerialization.writeLong(mtime, out);
|
|
|
writeRpcIds(rpcClientId, rpcCallId, out);
|
|
|
}
|
|
|
|
|
@@ -3574,6 +3587,7 @@ public abstract class FSEditLogOp {
|
|
|
protected void toXml(ContentHandler contentHandler) throws SAXException {
|
|
|
XMLUtils.addSaxString(contentHandler, "SNAPSHOTROOT", snapshotRoot);
|
|
|
XMLUtils.addSaxString(contentHandler, "SNAPSHOTNAME", snapshotName);
|
|
|
+ XMLUtils.addSaxString(contentHandler, "MTIME", Long.toString(mtime));
|
|
|
appendRpcIdsToXml(contentHandler, rpcClientId, rpcCallId);
|
|
|
}
|
|
|
|
|
@@ -3581,6 +3595,7 @@ public abstract class FSEditLogOp {
|
|
|
void fromXml(Stanza st) throws InvalidXmlException {
|
|
|
snapshotRoot = st.getValue("SNAPSHOTROOT");
|
|
|
snapshotName = st.getValue("SNAPSHOTNAME");
|
|
|
+ this.mtime = Long.parseLong(st.getValue("MTIME"));
|
|
|
|
|
|
readRpcIdsFromXml(st);
|
|
|
}
|
|
@@ -3591,7 +3606,8 @@ public abstract class FSEditLogOp {
|
|
|
builder.append("DeleteSnapshotOp [snapshotRoot=")
|
|
|
.append(snapshotRoot)
|
|
|
.append(", snapshotName=")
|
|
|
- .append(snapshotName);
|
|
|
+ .append(snapshotName)
|
|
|
+ .append(", mtime=").append(mtime);
|
|
|
appendRpcIdsToString(builder, rpcClientId, rpcCallId);
|
|
|
builder.append("]");
|
|
|
return builder.toString();
|