HDFS-6838. Code cleanup for unnecessary INode replacement. Contributed by Jing Zhao.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1617361 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c4dc685343
commit
80691b073f
@ -390,6 +390,9 @@ Release 2.6.0 - UNRELEASED
|
||||
HDFS-6837. Code cleanup for Balancer and Dispatcher. (szetszwo via
|
||||
jing9)
|
||||
|
||||
HDFS-6838. Code cleanup for unnecessary INode replacement.
|
||||
(Jing Zhao via wheat9)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-6690. Deduplicate xattr names in memory. (wang)
|
||||
|
@ -764,8 +764,6 @@ private static void validateRenameSource(String src, INodesInPath srcIIP)
|
||||
checkSnapshot(srcInode, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private class RenameOperation {
|
||||
private final INodesInPath srcIIP;
|
||||
private final INodesInPath dstIIP;
|
||||
@ -798,7 +796,7 @@ private RenameOperation(String src, String dst, INodesInPath srcIIP, INodesInPat
|
||||
// snapshot is taken on the dst tree, changes will be recorded in the latest
|
||||
// snapshot of the src tree.
|
||||
if (isSrcInSnapshot) {
|
||||
srcChild = srcChild.recordModification(srcIIP.getLatestSnapshotId());
|
||||
srcChild.recordModification(srcIIP.getLatestSnapshotId());
|
||||
}
|
||||
|
||||
// check srcChild for reference
|
||||
@ -928,8 +926,7 @@ Block[] unprotectedSetReplication(String src, short replication,
|
||||
updateCount(iip, 0, dsDelta, true);
|
||||
}
|
||||
|
||||
file = file.setFileReplication(replication, iip.getLatestSnapshotId(),
|
||||
inodeMap);
|
||||
file.setFileReplication(replication, iip.getLatestSnapshotId());
|
||||
|
||||
final short newBR = file.getBlockReplication();
|
||||
// check newBR < oldBR case.
|
||||
@ -1212,8 +1209,7 @@ long unprotectedDelete(INodesInPath iip, BlocksMapUpdateInfo collectedBlocks,
|
||||
|
||||
// record modification
|
||||
final int latestSnapshot = iip.getLatestSnapshotId();
|
||||
targetNode = targetNode.recordModification(latestSnapshot);
|
||||
iip.setLastINode(targetNode);
|
||||
targetNode.recordModification(latestSnapshot);
|
||||
|
||||
// Remove the node from the namespace
|
||||
long removed = removeLastINode(iip);
|
||||
@ -2122,7 +2118,7 @@ INodeDirectory unprotectedSetQuota(String src, long nsQuota, long dsQuota)
|
||||
}
|
||||
|
||||
final int latest = iip.getLatestSnapshotId();
|
||||
dirNode = dirNode.recordModification(latest);
|
||||
dirNode.recordModification(latest);
|
||||
dirNode.setQuota(nsQuota, dsQuota);
|
||||
return dirNode;
|
||||
}
|
||||
|
@ -2516,7 +2516,7 @@ LocatedBlock prepareFileForWrite(String src, INodeFile file,
|
||||
boolean writeToEditLog,
|
||||
int latestSnapshot, boolean logRetryCache)
|
||||
throws IOException {
|
||||
file = file.recordModification(latestSnapshot);
|
||||
file.recordModification(latestSnapshot);
|
||||
final INodeFile cons = file.toUnderConstruction(leaseHolder, clientMachine);
|
||||
|
||||
leaseManager.addLease(cons.getFileUnderConstructionFeature()
|
||||
@ -4211,7 +4211,7 @@ private void finalizeINodeFileUnderConstruction(String src,
|
||||
Preconditions.checkArgument(uc != null);
|
||||
leaseManager.removeLease(uc.getClientName(), src);
|
||||
|
||||
pendingFile = pendingFile.recordModification(latestSnapshot);
|
||||
pendingFile.recordModification(latestSnapshot);
|
||||
|
||||
// The file is no longer pending.
|
||||
// Create permanent INode, update blocks. No need to replace the inode here
|
||||
|
@ -97,9 +97,9 @@ public final String getUserName() {
|
||||
/** Set user */
|
||||
final INode setUser(String user, int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.setUser(user);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
setUser(user);
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* @param snapshotId
|
||||
@ -122,9 +122,9 @@ public final String getGroupName() {
|
||||
/** Set group */
|
||||
final INode setGroup(String group, int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.setGroup(group);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
setGroup(group);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -148,9 +148,9 @@ public final FsPermission getFsPermission() {
|
||||
/** Set the {@link FsPermission} of this {@link INode} */
|
||||
INode setPermission(FsPermission permission, int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.setPermission(permission);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
setPermission(permission);
|
||||
return this;
|
||||
}
|
||||
|
||||
abstract AclFeature getAclFeature(int snapshotId);
|
||||
@ -164,18 +164,18 @@ public final AclFeature getAclFeature() {
|
||||
|
||||
final INode addAclFeature(AclFeature aclFeature, int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.addAclFeature(aclFeature);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
addAclFeature(aclFeature);
|
||||
return this;
|
||||
}
|
||||
|
||||
abstract void removeAclFeature();
|
||||
|
||||
final INode removeAclFeature(int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.removeAclFeature();
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
removeAclFeature();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,9 +199,9 @@ public final XAttrFeature getXAttrFeature() {
|
||||
|
||||
final INode addXAttrFeature(XAttrFeature xAttrFeature, int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.addXAttrFeature(xAttrFeature);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
addXAttrFeature(xAttrFeature);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -211,9 +211,9 @@ final INode addXAttrFeature(XAttrFeature xAttrFeature, int latestSnapshotId)
|
||||
|
||||
final INode removeXAttrFeature(int lastestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(lastestSnapshotId);
|
||||
nodeToUpdate.removeXAttrFeature();
|
||||
return nodeToUpdate;
|
||||
recordModification(lastestSnapshotId);
|
||||
removeXAttrFeature();
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,11 +298,8 @@ public final boolean shouldRecordInSrcSnapshot(final int latestInDst) {
|
||||
* @param latestSnapshotId The id of the latest snapshot that has been taken.
|
||||
* Note that it is {@link Snapshot#CURRENT_STATE_ID}
|
||||
* if no snapshots have been taken.
|
||||
* @return The current inode, which usually is the same object of this inode.
|
||||
* However, in some cases, this inode may be replaced with a new inode
|
||||
* for maintaining snapshots. The current inode is then the new inode.
|
||||
*/
|
||||
abstract INode recordModification(final int latestSnapshotId)
|
||||
abstract void recordModification(final int latestSnapshotId)
|
||||
throws QuotaExceededException;
|
||||
|
||||
/** Check whether it's a reference. */
|
||||
@ -652,9 +649,9 @@ public abstract INode updateModificationTime(long mtime, int latestSnapshotId)
|
||||
/** Set the last modification time of inode. */
|
||||
public final INode setModificationTime(long modificationTime,
|
||||
int latestSnapshotId) throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.setModificationTime(modificationTime);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
setModificationTime(modificationTime);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -682,9 +679,9 @@ public final long getAccessTime() {
|
||||
*/
|
||||
public final INode setAccessTime(long accessTime, int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
final INode nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.setAccessTime(accessTime);
|
||||
return nodeToUpdate;
|
||||
recordModification(latestSnapshotId);
|
||||
setAccessTime(accessTime);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
@ -318,7 +318,7 @@ INodeReference.WithName replaceChild4ReferenceWithName(INode oldChild,
|
||||
}
|
||||
|
||||
@Override
|
||||
public INodeDirectory recordModification(int latestSnapshotId)
|
||||
public void recordModification(int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
if (isInLatestSnapshot(latestSnapshotId)
|
||||
&& !shouldRecordInSrcSnapshot(latestSnapshotId)) {
|
||||
@ -330,7 +330,6 @@ public INodeDirectory recordModification(int latestSnapshotId)
|
||||
// record self in the diff list if necessary
|
||||
sf.getDiffs().saveSelf2Snapshot(latestSnapshotId, this, null);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,7 +284,7 @@ public INodeFileAttributes getSnapshotINode(final int snapshotId) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public INodeFile recordModification(final int latestSnapshotId)
|
||||
public void recordModification(final int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
if (isInLatestSnapshot(latestSnapshotId)
|
||||
&& !shouldRecordInSrcSnapshot(latestSnapshotId)) {
|
||||
@ -296,7 +296,6 @@ public INodeFile recordModification(final int latestSnapshotId)
|
||||
// record self in the diff list if necessary
|
||||
sf.getDiffs().saveSelf2Snapshot(latestSnapshotId, this, null);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public FileDiffList getDiffs() {
|
||||
@ -344,11 +343,10 @@ public final void setFileReplication(short replication) {
|
||||
|
||||
/** Set the replication factor of this file. */
|
||||
public final INodeFile setFileReplication(short replication,
|
||||
int latestSnapshotId, final INodeMap inodeMap)
|
||||
throws QuotaExceededException {
|
||||
final INodeFile nodeToUpdate = recordModification(latestSnapshotId);
|
||||
nodeToUpdate.setFileReplication(replication);
|
||||
return nodeToUpdate;
|
||||
int latestSnapshotId) throws QuotaExceededException {
|
||||
recordModification(latestSnapshotId);
|
||||
setFileReplication(replication);
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @return preferred block size (in bytes) of the file. */
|
||||
|
@ -93,9 +93,8 @@ public INode get(long id) {
|
||||
"", "", new FsPermission((short) 0)), 0, 0) {
|
||||
|
||||
@Override
|
||||
INode recordModification(int latestSnapshotId)
|
||||
void recordModification(int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -287,11 +287,9 @@ public final void setAccessTime(long accessTime) {
|
||||
}
|
||||
|
||||
@Override
|
||||
final INode recordModification(int latestSnapshotId)
|
||||
final void recordModification(int latestSnapshotId)
|
||||
throws QuotaExceededException {
|
||||
referred.recordModification(latestSnapshotId);
|
||||
// reference is never replaced
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // used by WithCount
|
||||
|
@ -47,12 +47,11 @@ public class INodeSymlink extends INodeWithAdditionalFields {
|
||||
}
|
||||
|
||||
@Override
|
||||
INode recordModification(int latestSnapshotId) throws QuotaExceededException {
|
||||
void recordModification(int latestSnapshotId) throws QuotaExceededException {
|
||||
if (isInLatestSnapshot(latestSnapshotId)) {
|
||||
INodeDirectory parent = getParent();
|
||||
parent.saveChild2Snapshot(this, latestSnapshotId, new INodeSymlink(this));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/** @return true unconditionally. */
|
||||
|
Loading…
Reference in New Issue
Block a user