Java Code Examples for org.apache.hadoop.hdfs.protocol.QuotaExceededException#setPathName()

The following examples show how to use org.apache.hadoop.hdfs.protocol.QuotaExceededException#setPathName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FSDirectory.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Verify quota for adding or moving a new INode with required 
 * namespace and storagespace to a given position.
 *  
 * @param iip INodes corresponding to a path
 * @param pos position where a new INode will be added
 * @param deltas needed namespace, storagespace and storage types
 * @param commonAncestor Last node in inodes array that is a common ancestor
 *          for a INode that is being moved from one location to the other.
 *          Pass null if a node is not being moved.
 * @throws QuotaExceededException if quota limit is exceeded.
 */
static void verifyQuota(INodesInPath iip, int pos, QuotaCounts deltas,
                        INode commonAncestor) throws QuotaExceededException {
  if (deltas.getNameSpace() <= 0 && deltas.getStorageSpace() <= 0
      && deltas.getTypeSpaces().allLessOrEqual(0L)) {
    // if quota is being freed or not being consumed
    return;
  }

  // check existing components in the path
  for(int i = (pos > iip.length() ? iip.length(): pos) - 1; i >= 0; i--) {
    if (commonAncestor == iip.getINode(i)) {
      // Stop checking for quota when common ancestor is reached
      return;
    }
    final DirectoryWithQuotaFeature q
        = iip.getINode(i).asDirectory().getDirectoryWithQuotaFeature();
    if (q != null) { // a directory with quota
      try {
        q.verifyQuota(deltas);
      } catch (QuotaExceededException e) {
        List<INode> inodes = iip.getReadOnlyINodes();
        final String path = getFullPathName(inodes.toArray(new INode[inodes.size()]), i);
        e.setPathName(path);
        throw e;
      }
    }
  }
}
 
Example 2
Source File: FSDirectory.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Verify quota for adding or moving a new INode with required 
 * namespace and storagespace to a given position.
 *  
 * @param iip INodes corresponding to a path
 * @param pos position where a new INode will be added
 * @param deltas needed namespace, storagespace and storage types
 * @param commonAncestor Last node in inodes array that is a common ancestor
 *          for a INode that is being moved from one location to the other.
 *          Pass null if a node is not being moved.
 * @throws QuotaExceededException if quota limit is exceeded.
 */
static void verifyQuota(INodesInPath iip, int pos, QuotaCounts deltas,
                        INode commonAncestor) throws QuotaExceededException {
  if (deltas.getNameSpace() <= 0 && deltas.getStorageSpace() <= 0
      && deltas.getTypeSpaces().allLessOrEqual(0L)) {
    // if quota is being freed or not being consumed
    return;
  }

  // check existing components in the path
  for(int i = (pos > iip.length() ? iip.length(): pos) - 1; i >= 0; i--) {
    if (commonAncestor == iip.getINode(i)) {
      // Stop checking for quota when common ancestor is reached
      return;
    }
    final DirectoryWithQuotaFeature q
        = iip.getINode(i).asDirectory().getDirectoryWithQuotaFeature();
    if (q != null) { // a directory with quota
      try {
        q.verifyQuota(deltas);
      } catch (QuotaExceededException e) {
        List<INode> inodes = iip.getReadOnlyINodes();
        final String path = getFullPathName(inodes.toArray(new INode[inodes.size()]), i);
        e.setPathName(path);
        throw e;
      }
    }
  }
}
 
Example 3
Source File: FSDirectory.java    From RDFS with Apache License 2.0 5 votes vote down vote up
/**
 * Verify quota for adding or moving a new INode with required 
 * namespace and diskspace to a given position.
 *  
 * @param inodes INodes corresponding to a path
 * @param pos position where a new INode will be added
 * @param nsDelta needed namespace
 * @param dsDelta needed diskspace
 * @param commonAncestor Last node in inodes array that is a common ancestor
 *          for a INode that is being moved from one location to the other.
 *          Pass null if a node is not being moved.
 * @throws QuotaExceededException if quota limit is exceeded.
 */
private void verifyQuota(INode[] inodes, int pos, long nsDelta, long dsDelta,
    INode commonAncestor) throws QuotaExceededException {
  if (!ready) {
    // Do not check quota if edits log is still being processed
    return;
  }
  if (pos>inodes.length) {
    pos = inodes.length;
  }
  int i = pos - 1;
  try {
    // check existing components in the path  
    for(; i >= 0; i--) {
      if (commonAncestor == inodes[i]) {
        // Moving an existing node. Stop checking for quota when common
        // ancestor is reached
        return;
      }
      if (inodes[i].isQuotaSet()) { // a directory with quota
        INodeDirectoryWithQuota node =(INodeDirectoryWithQuota)inodes[i]; 
        node.verifyQuota(nsDelta, dsDelta);
      }
    }
  } catch (QuotaExceededException e) {
    e.setPathName(getFullPathName(inodes, i));
    throw e;
  }
}