org.apache.hadoop.hdfs.server.namenode
Class INodeDirectoryWithQuota

java.lang.Object
  extended by org.apache.hadoop.hdfs.server.namenode.INode
      extended by org.apache.hadoop.hdfs.server.namenode.INodeWithAdditionalFields
          extended by org.apache.hadoop.hdfs.server.namenode.INodeDirectory
              extended by org.apache.hadoop.hdfs.server.namenode.INodeDirectoryWithQuota
All Implemented Interfaces:
Comparable<byte[]>, org.apache.hadoop.hdfs.server.namenode.INodeAttributes, org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes, Diff.Element<byte[]>, org.apache.hadoop.util.LightWeightGSet.LinkedElement
Direct Known Subclasses:
INodeDirectoryWithSnapshot

public class INodeDirectoryWithQuota
extends INodeDirectory

Directory INode class that has a quota restriction


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.INodeDirectory
INodeDirectory.SnapshotAndINode
 
Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.namenode.INode
INode.BlocksMapUpdateInfo
 
Nested classes/interfaces inherited from interface org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes
INodeDirectoryAttributes.CopyWithQuota, INodeDirectoryAttributes.SnapshotCopy
 
Field Summary
 
Fields inherited from class org.apache.hadoop.hdfs.server.namenode.INodeDirectory
DEFAULT_FILES_PER_DIRECTORY
 
Fields inherited from class org.apache.hadoop.hdfs.server.namenode.INode
LOG
 
Constructor Summary
INodeDirectoryWithQuota(INodeDirectory other, boolean adopt, long nsQuota, long dsQuota)
          Convert an existing directory inode to one with the given quota
 
Method Summary
 void addSpaceConsumed(long nsDelta, long dsDelta, boolean verify)
          Check and add namespace/diskspace consumed to itself and the ancestors.
protected  void addSpaceConsumed2Cache(long nsDelta, long dsDelta)
          Update the size of the tree
 Content.Counts computeContentSummary(Content.Counts counts)
          Count subtree content summary with a Content.Counts.
 Quota.Counts computeQuotaUsage(Quota.Counts counts, boolean useCache, int lastSnapshotId)
          Count subtree Quota.NAMESPACE and Quota.DISKSPACE usages.
 long getDiskspace()
           
 long getDsQuota()
          Get this directory's diskspace quota
 long getNamespace()
           
 long getNsQuota()
          Get this directory's namespace quota
 void setQuota(long nsQuota, long dsQuota)
          Set this directory's quota
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INodeDirectory
addChild, addChild, asDirectory, cleanSubtree, cleanSubtreeRecursively, clear, clearChildren, computeQuotaUsage4CurrentDirectory, destroyAndCollectBlocks, dumpTreeRecursively, dumpTreeRecursively, getChild, getChildrenList, getChildrenNum, isDirectory, isSnapshottable, metadataEquals, recordModification, removeChild, removeChild, replaceChild, replaceSelf4INodeDirectory, replaceSelf4INodeDirectorySnapshottable, replaceSelf4INodeDirectoryWithSnapshot, saveChild2Snapshot, valueOf
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INodeWithAdditionalFields
getFsPermissionShort, getId, getLocalNameBytes, getNext, getPermissionLong, setAccessTime, setLocalName, setModificationTime, setNext, updateModificationTime
 
Methods inherited from class org.apache.hadoop.hdfs.server.namenode.INode
asFile, asReference, asSymlink, compareTo, computeContentSummary, computeQuotaUsage, computeQuotaUsage, dumpTreeRecursively, dumpTreeRecursively, equals, getAccessTime, getFsPermission, getFullPathName, getGroupName, getKey, getLocalName, getModificationTime, getObjectString, getParent, getParentReference, getParentString, getSnapshotINode, getUserName, hashCode, isAncestorDirectory, isFile, isInLatestSnapshot, isQuotaSet, isReference, isSymlink, setAccessTime, setModificationTime, setParent, setParentReference, shouldRecordInSrcSnapshot, toDetailString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.hdfs.server.namenode.INodeAttributes
getAccessTime, getFsPermission, getFsPermissionShort, getGroupName, getLocalNameBytes, getModificationTime, getPermissionLong, getUserName
 

Constructor Detail

INodeDirectoryWithQuota

public INodeDirectoryWithQuota(INodeDirectory other,
                               boolean adopt,
                               long nsQuota,
                               long dsQuota)
Convert an existing directory inode to one with the given quota

Parameters:
nsQuota - Namespace quota to be assigned to this inode
dsQuota - Diskspace quota to be assigned to this indoe
other - The other inode from which all other properties are copied
Method Detail

getNsQuota

public long getNsQuota()
Get this directory's namespace quota

Specified by:
getNsQuota in interface org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes
Overrides:
getNsQuota in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
this directory's namespace quota

getDsQuota

public long getDsQuota()
Get this directory's diskspace quota

Specified by:
getDsQuota in interface org.apache.hadoop.hdfs.server.namenode.INodeDirectoryAttributes
Overrides:
getDsQuota in class org.apache.hadoop.hdfs.server.namenode.INode
Returns:
this directory's diskspace quota

setQuota

public void setQuota(long nsQuota,
                     long dsQuota)
Set this directory's quota

Parameters:
nsQuota - Namespace quota to be set
dsQuota - diskspace quota to be set

computeQuotaUsage

public Quota.Counts computeQuotaUsage(Quota.Counts counts,
                                      boolean useCache,
                                      int lastSnapshotId)
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Count subtree 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 a INodeReference.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 a INodeReference.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 the INodeReference.WithName node.
 We do not count in the size of the diff list.  
 

Overrides:
computeQuotaUsage in class INodeDirectory
Parameters:
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.
Returns:
The same objects as the counts parameter.

computeContentSummary

public Content.Counts computeContentSummary(Content.Counts counts)
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Count subtree content summary with a Content.Counts.

Overrides:
computeContentSummary in class INodeDirectory
Parameters:
counts - The subtree counts for returning.
Returns:
The same objects as the counts parameter.

addSpaceConsumed

public final void addSpaceConsumed(long nsDelta,
                                   long dsDelta,
                                   boolean verify)
                            throws org.apache.hadoop.hdfs.protocol.QuotaExceededException
Description copied from class: org.apache.hadoop.hdfs.server.namenode.INode
Check and add namespace/diskspace consumed to itself and the ancestors.

Overrides:
addSpaceConsumed in class org.apache.hadoop.hdfs.server.namenode.INode
Throws:
org.apache.hadoop.hdfs.protocol.QuotaExceededException - if quote is violated.

addSpaceConsumed2Cache

protected void addSpaceConsumed2Cache(long nsDelta,
                                      long dsDelta)
Update the size of the tree

Parameters:
nsDelta - the change of the tree size
dsDelta - change to disk space occupied

getNamespace

public long getNamespace()

getDiskspace

public long getDiskspace()


Copyright © 2013 Apache Software Foundation. All Rights Reserved.