|
@@ -3437,6 +3437,8 @@ public abstract class FSEditLogOp {
|
|
|
static class CreateSnapshotOp extends FSEditLogOp {
|
|
|
String snapshotRoot;
|
|
|
String snapshotName;
|
|
|
+ /** Modification time of the edit set by Time.now(). */
|
|
|
+ long mtime;
|
|
|
|
|
|
public CreateSnapshotOp() {
|
|
|
super(OP_CREATE_SNAPSHOT);
|
|
@@ -3450,22 +3452,32 @@ public abstract class FSEditLogOp {
|
|
|
void resetSubFields() {
|
|
|
snapshotRoot = null;
|
|
|
snapshotName = null;
|
|
|
+ mtime = 0L;
|
|
|
}
|
|
|
|
|
|
+ /* set the name of the snapshot. */
|
|
|
CreateSnapshotOp setSnapshotName(String snapName) {
|
|
|
this.snapshotName = snapName;
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /* set the directory path where the snapshot is taken. */
|
|
|
public CreateSnapshotOp setSnapshotRoot(String snapRoot) {
|
|
|
snapshotRoot = snapRoot;
|
|
|
return this;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /* The snapshot creation time set by Time.now(). */
|
|
|
+ CreateSnapshotOp 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);
|
|
@@ -3475,6 +3487,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);
|
|
|
}
|
|
|
|
|
@@ -3482,6 +3495,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);
|
|
|
}
|
|
|
|
|
@@ -3489,6 +3503,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);
|
|
|
}
|
|
@@ -3499,7 +3514,8 @@ public abstract class FSEditLogOp {
|
|
|
builder.append("CreateSnapshotOp [snapshotRoot=")
|
|
|
.append(snapshotRoot)
|
|
|
.append(", snapshotName=")
|
|
|
- .append(snapshotName);
|
|
|
+ .append(snapshotName)
|
|
|
+ .append(", mtime=").append(mtime);
|
|
|
appendRpcIdsToString(builder, rpcClientId, rpcCallId);
|
|
|
builder.append("]");
|
|
|
return builder.toString();
|