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