org.apache.hadoop.fs.PathOperationException Java Examples

The following examples show how to use org.apache.hadoop.fs.PathOperationException. 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: CommandWithDestination.java    From hadoop with Apache License 2.0 5 votes vote down vote up
/**
 * Called with a source and target destination pair
 * @param src for the operation
 * @param dst for the operation
 * @throws IOException if anything goes wrong
 */
protected void processPath(PathData src, PathData dst) throws IOException {
  if (src.stat.isSymlink()) {
    // TODO: remove when FileContext is supported, this needs to either
    // copy the symlink or deref the symlink
    throw new PathOperationException(src.toString());        
  } else if (src.stat.isFile()) {
    copyFileToTarget(src, dst);
  } else if (src.stat.isDirectory() && !isRecursive()) {
    throw new PathIsDirectoryException(src.toString());
  }
}
 
Example #2
Source File: CommandWithDestination.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Called with a source and target destination pair
 * @param src for the operation
 * @param dst for the operation
 * @throws IOException if anything goes wrong
 */
protected void processPath(PathData src, PathData dst) throws IOException {
  if (src.stat.isSymlink()) {
    // TODO: remove when FileContext is supported, this needs to either
    // copy the symlink or deref the symlink
    throw new PathOperationException(src.toString());        
  } else if (src.stat.isFile()) {
    copyFileToTarget(src, dst);
  } else if (src.stat.isDirectory() && !isRecursive()) {
    throw new PathIsDirectoryException(src.toString());
  }
}
 
Example #3
Source File: ObjectStoreFlatGlobFilter.java    From stocator with Apache License 2.0 4 votes vote down vote up
public ObjectStoreFlatGlobFilter(String pathPattern1, int start1, boolean bracketSupport1)
    throws PathOperationException {
  bracketSupport = bracketSupport1;
  parsedPatterns = parseInnerSet(pathPattern1);
  start = start1;
}
 
Example #4
Source File: ObjectStoreFlatGlobFilter.java    From stocator with Apache License 2.0 4 votes vote down vote up
private ArrayList<String> parseInnerSet(String pathStr) throws PathOperationException {
  LOG.trace("Process {}", pathStr);
  ArrayList<String> result = new ArrayList<String>();
  // found start and finish of the external boundary { }
  // we currently support only one nested level
  int nestedLevel = 0;
  Queue<String> q = new LinkedList<String>();
  int fromIndex = pathStr.indexOf("{");
  if (!bracketSupport || fromIndex < 0) {
    result.add(pathStr);
    return result;
  }
  int currIndex = fromIndex + 1;
  if (fromIndex >= 0) {
    q.add("{");
    nestedLevel++;
    while (!q.isEmpty() && currIndex < pathStr.length()) {
      if (pathStr.charAt(currIndex) == '{') {
        q.add("{");
        nestedLevel++;
      } else if (pathStr.charAt(currIndex) == '}') {
        q.remove();
      }
      currIndex++;
    }
  }
  if (nestedLevel > 2) {
    LOG.error("Only 1 nested level allowed. Found {} for {}", nestedLevel, pathStr);
    throw new PathOperationException("Only one nested level of brackets is supported");
  }
  if (!q.isEmpty()) {
    LOG.error("Invalid input {}", pathStr);
    throw new PathOperationException("Invalid input " + pathStr);

  }
  String globalPrefix = pathStr.substring(0, fromIndex);
  LOG.trace("Global prefix {} for {}", globalPrefix, pathStr);
  String globalSuffix = pathStr.substring(currIndex);
  LOG.trace("Global suffix {} for {}", globalSuffix, pathStr);

  // list parsed path inside external boundary
  // we need to make sure we don't separate inner boundaries
  StringTokenizer strk = new StringTokenizer(pathStr.substring(fromIndex + 1,
      currIndex - 1), ",");
  while (strk.hasMoreTokens()) {
    String st = strk.nextToken();
    // for each value see if internal boundary present, xx{yy,zz}ww
    int startInd = st.indexOf("{");
    int endInd = st.indexOf("}");
    // means it break inner boundary, need to aggregate
    while (endInd < 0 && startInd > 0) {
      st = st + "," + strk.nextToken();
      endInd = st.indexOf("}");
    }
    if (startInd >= 0 && endInd <= st.length()) {
      String localPrefix = st.substring(0, startInd);
      String localSuffix = st.substring(endInd + 1, st.length());
      LOG.trace("Local prefix: {} :local suffix {} for {}", localPrefix,
          localSuffix, st);
      StringTokenizer localTokenizer = new StringTokenizer(st.substring(
          startInd + 1, endInd), ",");
      while (localTokenizer.hasMoreTokens()) {
        String entry = localTokenizer.nextToken();
        result.add(globalPrefix + localPrefix + entry
            + localSuffix + globalSuffix);
      }
    } else {
      result.add(globalPrefix + st + globalSuffix);
    }
  }
  return result;
}