HDFS-3014. FSEditLogOp and its subclasses should have toString() method. Contributed by Sho Shimauchi.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1294926 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
137aa0763f
commit
e58b7e202b
|
@ -62,6 +62,9 @@ Trunk (unreleased changes)
|
|||
|
||||
HDFS-3016. Security in unit tests. (Jaimin Jetly via jitendra)
|
||||
|
||||
HDFS-3014. FSEditLogOp and its subclasses should have toString() method.
|
||||
(Sho Shimauchi via atm)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-2477. Optimize computing the diff between a block report and the
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.hadoop.hdfs.server.namenode;
|
|||
|
||||
import java.util.zip.CheckedInputStream;
|
||||
import java.util.zip.Checksum;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
|
||||
import org.apache.hadoop.fs.ChecksumException;
|
||||
|
@ -305,6 +306,36 @@ public abstract class FSEditLogOp {
|
|||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
public String stringifyMembers() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[length=");
|
||||
builder.append(length);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", replication=");
|
||||
builder.append(replication);
|
||||
builder.append(", mtime=");
|
||||
builder.append(mtime);
|
||||
builder.append(", atime=");
|
||||
builder.append(atime);
|
||||
builder.append(", blockSize=");
|
||||
builder.append(blockSize);
|
||||
builder.append(", blocks=");
|
||||
builder.append(Arrays.toString(blocks));
|
||||
builder.append(", permissions=");
|
||||
builder.append(permissions);
|
||||
builder.append(", clientName=");
|
||||
builder.append(clientName);
|
||||
builder.append(", clientMachine=");
|
||||
builder.append(clientMachine);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class AddOp extends AddCloseOp {
|
||||
|
@ -315,6 +346,14 @@ public abstract class FSEditLogOp {
|
|||
static AddOp getInstance() {
|
||||
return (AddOp)opInstances.get().get(OP_ADD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("AddOp ");
|
||||
builder.append(stringifyMembers());
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class CloseOp extends AddCloseOp {
|
||||
|
@ -325,6 +364,14 @@ public abstract class FSEditLogOp {
|
|||
static CloseOp getInstance() {
|
||||
return (CloseOp)opInstances.get().get(OP_CLOSE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CloseOp ");
|
||||
builder.append(stringifyMembers());
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SetReplicationOp extends FSEditLogOp {
|
||||
|
@ -366,6 +413,21 @@ public abstract class FSEditLogOp {
|
|||
this.replication = readShort(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SetReplicationOp [path=");
|
||||
builder.append(path);
|
||||
builder.append(", replication=");
|
||||
builder.append(replication);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class ConcatDeleteOp extends FSEditLogOp {
|
||||
|
@ -440,6 +502,25 @@ public abstract class FSEditLogOp {
|
|||
this.timestamp = readLong(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ConcatDeleteOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", trg=");
|
||||
builder.append(trg);
|
||||
builder.append(", srcs=");
|
||||
builder.append(Arrays.toString(srcs));
|
||||
builder.append(", timestamp=");
|
||||
builder.append(timestamp);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class RenameOldOp extends FSEditLogOp {
|
||||
|
@ -497,6 +578,25 @@ public abstract class FSEditLogOp {
|
|||
this.timestamp = readLong(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RenameOldOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", src=");
|
||||
builder.append(src);
|
||||
builder.append(", dst=");
|
||||
builder.append(dst);
|
||||
builder.append(", timestamp=");
|
||||
builder.append(timestamp);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class DeleteOp extends FSEditLogOp {
|
||||
|
@ -545,6 +645,23 @@ public abstract class FSEditLogOp {
|
|||
this.timestamp = readLong(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DeleteOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", timestamp=");
|
||||
builder.append(timestamp);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class MkdirOp extends FSEditLogOp {
|
||||
|
@ -623,6 +740,25 @@ public abstract class FSEditLogOp {
|
|||
this.permissions = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("MkdirOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", timestamp=");
|
||||
builder.append(timestamp);
|
||||
builder.append(", permissions=");
|
||||
builder.append(permissions);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SetGenstampOp extends FSEditLogOp {
|
||||
|
@ -652,6 +788,19 @@ public abstract class FSEditLogOp {
|
|||
throws IOException {
|
||||
this.genStamp = FSImageSerialization.readLong(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SetGenstampOp [genStamp=");
|
||||
builder.append(genStamp);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -676,6 +825,17 @@ public abstract class FSEditLogOp {
|
|||
//Datanodes are not persistent any more.
|
||||
FSImageSerialization.DatanodeImage.skipOne(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DatanodeAddOp [opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
@ -701,6 +861,17 @@ public abstract class FSEditLogOp {
|
|||
nodeID.readFields(in);
|
||||
//Datanodes are not persistent any more.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("DatanodeRemoveOp [opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SetPermissionsOp extends FSEditLogOp {
|
||||
|
@ -738,6 +909,21 @@ public abstract class FSEditLogOp {
|
|||
this.src = FSImageSerialization.readString(in);
|
||||
this.permissions = FsPermission.read(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SetPermissionsOp [src=");
|
||||
builder.append(src);
|
||||
builder.append(", permissions=");
|
||||
builder.append(permissions);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SetOwnerOp extends FSEditLogOp {
|
||||
|
@ -783,6 +969,23 @@ public abstract class FSEditLogOp {
|
|||
this.username = FSImageSerialization.readString_EmptyAsNull(in);
|
||||
this.groupname = FSImageSerialization.readString_EmptyAsNull(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SetOwnerOp [src=");
|
||||
builder.append(src);
|
||||
builder.append(", username=");
|
||||
builder.append(username);
|
||||
builder.append(", groupname=");
|
||||
builder.append(groupname);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SetNSQuotaOp extends FSEditLogOp {
|
||||
|
@ -809,6 +1012,21 @@ public abstract class FSEditLogOp {
|
|||
this.src = FSImageSerialization.readString(in);
|
||||
this.nsQuota = FSImageSerialization.readLong(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SetNSQuotaOp [src=");
|
||||
builder.append(src);
|
||||
builder.append(", nsQuota=");
|
||||
builder.append(nsQuota);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class ClearNSQuotaOp extends FSEditLogOp {
|
||||
|
@ -833,6 +1051,19 @@ public abstract class FSEditLogOp {
|
|||
throws IOException {
|
||||
this.src = FSImageSerialization.readString(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ClearNSQuotaOp [src=");
|
||||
builder.append(src);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SetQuotaOp extends FSEditLogOp {
|
||||
|
@ -878,6 +1109,23 @@ public abstract class FSEditLogOp {
|
|||
this.nsQuota = FSImageSerialization.readLong(in);
|
||||
this.dsQuota = FSImageSerialization.readLong(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SetQuotaOp [src=");
|
||||
builder.append(src);
|
||||
builder.append(", nsQuota=");
|
||||
builder.append(nsQuota);
|
||||
builder.append(", dsQuota=");
|
||||
builder.append(dsQuota);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class TimesOp extends FSEditLogOp {
|
||||
|
@ -936,6 +1184,25 @@ public abstract class FSEditLogOp {
|
|||
this.atime = readLong(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("TimesOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", mtime=");
|
||||
builder.append(mtime);
|
||||
builder.append(", atime=");
|
||||
builder.append(atime);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class SymlinkOp extends FSEditLogOp {
|
||||
|
@ -1011,6 +1278,29 @@ public abstract class FSEditLogOp {
|
|||
}
|
||||
this.permissionStatus = PermissionStatus.read(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SymlinkOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", value=");
|
||||
builder.append(value);
|
||||
builder.append(", mtime=");
|
||||
builder.append(mtime);
|
||||
builder.append(", atime=");
|
||||
builder.append(atime);
|
||||
builder.append(", permissionStatus=");
|
||||
builder.append(permissionStatus);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class RenameOp extends FSEditLogOp {
|
||||
|
@ -1097,6 +1387,27 @@ public abstract class FSEditLogOp {
|
|||
}
|
||||
return new BytesWritable(bytes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RenameOp [length=");
|
||||
builder.append(length);
|
||||
builder.append(", src=");
|
||||
builder.append(src);
|
||||
builder.append(", dst=");
|
||||
builder.append(dst);
|
||||
builder.append(", timestamp=");
|
||||
builder.append(timestamp);
|
||||
builder.append(", options=");
|
||||
builder.append(Arrays.toString(options));
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class ReassignLeaseOp extends FSEditLogOp {
|
||||
|
@ -1142,6 +1453,23 @@ public abstract class FSEditLogOp {
|
|||
this.path = FSImageSerialization.readString(in);
|
||||
this.newHolder = FSImageSerialization.readString(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ReassignLeaseOp [leaseHolder=");
|
||||
builder.append(leaseHolder);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append(", newHolder=");
|
||||
builder.append(newHolder);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class GetDelegationTokenOp extends FSEditLogOp {
|
||||
|
@ -1185,6 +1513,21 @@ public abstract class FSEditLogOp {
|
|||
this.expiryTime = readLong(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GetDelegationTokenOp [token=");
|
||||
builder.append(token);
|
||||
builder.append(", expiryTime=");
|
||||
builder.append(expiryTime);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class RenewDelegationTokenOp extends FSEditLogOp {
|
||||
|
@ -1228,6 +1571,21 @@ public abstract class FSEditLogOp {
|
|||
this.expiryTime = readLong(in);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("RenewDelegationTokenOp [token=");
|
||||
builder.append(token);
|
||||
builder.append(", expiryTime=");
|
||||
builder.append(expiryTime);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class CancelDelegationTokenOp extends FSEditLogOp {
|
||||
|
@ -1259,6 +1617,19 @@ public abstract class FSEditLogOp {
|
|||
this.token = new DelegationTokenIdentifier();
|
||||
this.token.readFields(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("CancelDelegationTokenOp [token=");
|
||||
builder.append(token);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class UpdateMasterKeyOp extends FSEditLogOp {
|
||||
|
@ -1289,6 +1660,19 @@ public abstract class FSEditLogOp {
|
|||
this.key = new DelegationKey();
|
||||
this.key.readFields(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("UpdateMasterKeyOp [key=");
|
||||
builder.append(key);
|
||||
builder.append(", opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class LogSegmentOp extends FSEditLogOp {
|
||||
|
@ -1311,6 +1695,17 @@ public abstract class FSEditLogOp {
|
|||
void writeFields(DataOutputStream out) throws IOException {
|
||||
// no data stored
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("LogSegmentOp [opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static class InvalidOp extends FSEditLogOp {
|
||||
|
@ -1331,6 +1726,17 @@ public abstract class FSEditLogOp {
|
|||
throws IOException {
|
||||
// nothing to read
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("InvalidOp [opCode=");
|
||||
builder.append(opCode);
|
||||
builder.append(", txid=");
|
||||
builder.append(txid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
static private short readShort(DataInputStream in) throws IOException {
|
||||
|
|
Loading…
Reference in New Issue