@InterfaceAudience.Private public abstract class INode extends Object implements INodeAttributes, Diff.Element<byte[]>
Modifier and Type | Class and Description |
---|---|
static class |
INode.BlocksMapUpdateInfo
Information used for updating the blocksMap when deleting files.
|
INodeAttributes.SnapshotCopy
Modifier and Type | Field and Description |
---|---|
static org.apache.commons.logging.Log |
LOG |
Modifier and Type | Method and Description |
---|---|
void |
addSpaceConsumed(long nsDelta,
long dsDelta,
boolean verify)
Check and add namespace/diskspace consumed to itself and the ancestors.
|
INodeDirectory |
asDirectory()
Cast this inode to an
INodeDirectory . |
INodeFile |
asFile()
Cast this inode to an
INodeFile . |
INodeReference |
asReference()
Cast this inode to an
INodeReference . |
INodeSymlink |
asSymlink()
Cast this inode to an
INodeSymlink . |
abstract Quota.Counts |
cleanSubtree(Snapshot snapshot,
Snapshot prior,
INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes,
boolean countDiffChange)
Clean the subtree under this inode and collect the blocks from the descents
for further block deletion/update.
|
void |
clear()
Clear references to other objects.
|
int |
compareTo(byte[] bytes) |
ContentSummary |
computeContentSummary()
Compute
ContentSummary . |
abstract Content.Counts |
computeContentSummary(Content.Counts counts)
Count subtree content summary with a
Content.Counts . |
Quota.Counts |
computeQuotaUsage()
Count subtree
Quota.NAMESPACE and Quota.DISKSPACE usages. |
Quota.Counts |
computeQuotaUsage(Quota.Counts counts,
boolean useCache) |
abstract Quota.Counts |
computeQuotaUsage(Quota.Counts counts,
boolean useCache,
int lastSnapshotId)
Count subtree
Quota.NAMESPACE and Quota.DISKSPACE usages. |
abstract void |
destroyAndCollectBlocks(INode.BlocksMapUpdateInfo collectedBlocks,
List<INode> removedINodes)
Destroy self and clear everything! If the INode is a file, this method
collects its blocks for further block deletion.
|
StringBuffer |
dumpTreeRecursively()
Dump the subtree starting from this inode.
|
void |
dumpTreeRecursively(PrintStream out) |
void |
dumpTreeRecursively(PrintWriter out,
StringBuilder prefix,
Snapshot snapshot)
Dump tree recursively.
|
boolean |
equals(Object that) |
long |
getAccessTime()
The same as getAccessTime(null).
|
long |
getDsQuota() |
FsPermission |
getFsPermission()
The same as getFsPermission(null).
|
String |
getFullPathName() |
String |
getGroupName()
The same as getGroupName(null).
|
abstract long |
getId()
Get inode id
|
byte[] |
getKey() |
String |
getLocalName() |
long |
getModificationTime()
The same as getModificationTime(null).
|
long |
getNsQuota()
Get the quota set for this inode
|
String |
getObjectString() |
INodeDirectory |
getParent() |
INodeReference |
getParentReference() |
String |
getParentString() |
INodeAttributes |
getSnapshotINode(Snapshot snapshot) |
String |
getUserName()
The same as getUserName(null).
|
int |
hashCode() |
boolean |
isAncestorDirectory(INodeDirectory dir) |
boolean |
isDirectory()
Check whether it's a directory
|
boolean |
isFile()
Check whether it's a file.
|
boolean |
isInLatestSnapshot(Snapshot latest)
Is this inode in the latest snapshot?
|
boolean |
isQuotaSet() |
boolean |
isReference()
Check whether it's a reference.
|
boolean |
isSymlink()
Check whether it's a symlink
|
abstract void |
setAccessTime(long accessTime)
Set last access time of inode.
|
INode |
setAccessTime(long accessTime,
Snapshot latest,
INodeMap inodeMap)
Set last access time of inode.
|
abstract void |
setLocalName(byte[] name)
Set local file name
|
abstract void |
setModificationTime(long modificationTime)
Set the last modification time of inode.
|
INode |
setModificationTime(long modificationTime,
Snapshot latest,
INodeMap inodeMap)
Set the last modification time of inode.
|
void |
setParent(INodeDirectory parent)
Set parent directory
|
void |
setParentReference(INodeReference parent)
Set container.
|
boolean |
shouldRecordInSrcSnapshot(Snapshot latestInDst)
When
recordModification(org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot, org.apache.hadoop.hdfs.server.namenode.INodeMap) is called on a referred node,
this method tells which snapshot the modification should be
associated with: the snapshot that belongs to the SRC tree of the rename
operation, or the snapshot belonging to the DST tree. |
String |
toDetailString() |
String |
toString() |
abstract INode |
updateModificationTime(long mtime,
Snapshot latest,
INodeMap inodeMap)
Update modification time if it is larger than the current value.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getFsPermissionShort, getLocalNameBytes, getPermissionLong
public abstract long getId()
public final String getUserName()
getUserName
in interface INodeAttributes
public final String getGroupName()
getGroupName
in interface INodeAttributes
public final FsPermission getFsPermission()
getFsPermission
in interface INodeAttributes
public INodeAttributes getSnapshotINode(Snapshot snapshot)
public final boolean isInLatestSnapshot(Snapshot latest)
public final boolean isAncestorDirectory(INodeDirectory dir)
public final boolean shouldRecordInSrcSnapshot(Snapshot latestInDst)
recordModification(org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot, org.apache.hadoop.hdfs.server.namenode.INodeMap)
is called on a referred node,
this method tells which snapshot the modification should be
associated with: the snapshot that belongs to the SRC tree of the rename
operation, or the snapshot belonging to the DST tree.latestInDst
- the latest snapshot in the DST tree above the reference nodepublic boolean isReference()
public INodeReference asReference()
INodeReference
.public boolean isFile()
public boolean isDirectory()
public INodeDirectory asDirectory()
INodeDirectory
.public boolean isSymlink()
public INodeSymlink asSymlink()
INodeSymlink
.public abstract Quota.Counts cleanSubtree(Snapshot snapshot, Snapshot prior, INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes, boolean countDiffChange) throws QuotaExceededException
In general, we have the following rules. 1. When deleting a file/directory in the current tree, we have different actions according to the type of the node to delete. 1.1 The current inode (this) is anINodeFile
. 1.1.1 Ifprior
is null, there is no snapshot taken on ancestors before. Thus we simply destroy (i.e., to delete completely, no need to save snapshot copy) the current INode and collect its blocks for further cleansing. 1.1.2 Else do nothing since the current INode will be stored as a snapshot copy. 1.2 The current inode is anINodeDirectory
. 1.2.1 Ifprior
is null, there is no snapshot taken on ancestors before. Similarly, we destroy the whole subtree and collect blocks. 1.2.2 Else do nothing with the current INode. Recursively clean its children. 1.3 The current inode is aFileWithSnapshot
. Call recordModification(..) to capture the current states. Mark the INode as deleted. 1.4 The current inode is aINodeDirectoryWithSnapshot
. Call recordModification(..) to capture the current states. Destroy files/directories created after the latest snapshot (i.e., the inodes stored in the created list of the latest snapshot). Recursively clean remaining children. 2. When deleting a snapshot. 2.1 To cleanINodeFile
: do nothing. 2.2 To cleanINodeDirectory
: recursively clean its children. 2.3 To cleanFileWithSnapshot
: delete the corresponding snapshot in its diff list. 2.4 To cleanINodeDirectoryWithSnapshot
: delete the corresponding snapshot in its diff list. Recursively clean its children.
snapshot
- The snapshot to delete. Null means to delete the current
file/directory.prior
- The latest snapshot before the to-be-deleted snapshot. When
deleting a current inode, this parameter captures the latest
snapshot.collectedBlocks
- blocks collected from the descents for further block
deletion/update will be added to the given map.removedINodes
- INodes collected from the descents for further cleaning up of
inodeMapQuotaExceededException
public abstract void destroyAndCollectBlocks(INode.BlocksMapUpdateInfo collectedBlocks, List<INode> removedINodes)
collectedBlocks
- blocks collected from the descents for further block
deletion/update will be added to this map.removedINodes
- INodes collected from the descents for further cleaning up of
inodeMappublic final ContentSummary computeContentSummary()
ContentSummary
.public abstract Content.Counts computeContentSummary(Content.Counts counts)
Content.Counts
.counts
- The subtree counts for returning.public void addSpaceConsumed(long nsDelta, long dsDelta, boolean verify) throws QuotaExceededException
QuotaExceededException
- if quote is violated.public long getNsQuota()
public long getDsQuota()
public final boolean isQuotaSet()
public final Quota.Counts computeQuotaUsage()
Quota.NAMESPACE
and Quota.DISKSPACE
usages.public abstract Quota.Counts computeQuotaUsage(Quota.Counts counts, boolean useCache, int lastSnapshotId)
Quota.NAMESPACE
and Quota.DISKSPACE
usages.
With the existence of INodeReference
, the same inode and its
subtree may be referred by multiple INodeReference.WithName
nodes and a
INodeReference.DstReference
node. To avoid circles while quota usage computation,
we have the following rules:
1. For aINodeReference.DstReference
node, since the node must be in the current tree (or has been deleted as the end point of a series of rename operations), we compute the quota usage of the referred node (and its subtree) in the regular manner, i.e., including every inode in the current tree and in snapshot copies, as well as the size of diff list. 2. For aINodeReference.WithName
node, since the node must be in a snapshot, we only count the quota usage for those nodes that still existed at the creation time of the snapshot associated with theINodeReference.WithName
node. We do not count in the size of the diff list.
counts
- The subtree counts for returning.useCache
- Whether to use cached quota usage. Note that
INodeReference.WithName
node never uses cache for its subtree.lastSnapshotId
- Snapshot.INVALID_ID
indicates the computation
is in the current tree. Otherwise the id indicates
the computation range for a INodeReference.WithName
node.public final Quota.Counts computeQuotaUsage(Quota.Counts counts, boolean useCache)
public final String getLocalName()
public final byte[] getKey()
getKey
in interface Diff.Element<byte[]>
public abstract void setLocalName(byte[] name)
public String getFullPathName()
public final String getObjectString()
public final String getParentString()
public String toDetailString()
public final INodeDirectory getParent()
public INodeReference getParentReference()
public final void setParent(INodeDirectory parent)
public final void setParentReference(INodeReference parent)
public void clear()
public final long getModificationTime()
getModificationTime
in interface INodeAttributes
public abstract INode updateModificationTime(long mtime, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
QuotaExceededException
public abstract void setModificationTime(long modificationTime)
public final INode setModificationTime(long modificationTime, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
QuotaExceededException
public final long getAccessTime()
getAccessTime
in interface INodeAttributes
public abstract void setAccessTime(long accessTime)
public final INode setAccessTime(long accessTime, Snapshot latest, INodeMap inodeMap) throws QuotaExceededException
QuotaExceededException
public final int compareTo(byte[] bytes)
compareTo
in interface Comparable<byte[]>
public final StringBuffer dumpTreeRecursively()
public final void dumpTreeRecursively(PrintStream out)
public void dumpTreeRecursively(PrintWriter out, StringBuilder prefix, Snapshot snapshot)
prefix
- The prefix string that each line should print.Copyright © 2013 Apache Software Foundation. All rights reserved.