Exemple #1
0
  /**
   * Get filestatuses of all the children of a given directory. This just reads through index file
   * and reads line by line to get all statuses for children of a directory. Its a brute force way
   * of getting all such filestatuses
   *
   * @param parent the parent path directory
   * @param statuses the list to add the children filestatuses to
   */
  private void fileStatusesInIndex(HarStatus parent, List<FileStatus> statuses) throws IOException {
    String parentString = parent.getName();
    if (!parentString.endsWith(Path.SEPARATOR)) {
      parentString += Path.SEPARATOR;
    }
    Path harPath = new Path(parentString);
    int harlen = harPath.depth();
    final Map<String, FileStatus> cache = new TreeMap<String, FileStatus>();

    for (HarStatus hstatus : metadata.archive.values()) {
      String child = hstatus.getName();
      if ((child.startsWith(parentString))) {
        Path thisPath = new Path(child);
        if (thisPath.depth() == harlen + 1) {
          statuses.add(toFileStatus(hstatus, cache));
        }
      }
    }
  }
Exemple #2
0
 /*
  * find the parent path that is the
  * archive path in the path. The last
  * path segment that ends with .har is
  * the path that will be returned.
  */
 private Path archivePath(Path p) {
   Path retPath = null;
   Path tmp = p;
   for (int i = 0; i < p.depth(); i++) {
     if (tmp.toString().endsWith(".har")) {
       retPath = tmp;
       break;
     }
     tmp = tmp.getParent();
   }
   return retPath;
 }
Exemple #3
0
 // the relative path of p. basically
 // getting rid of /. Parsing and doing
 // string manipulation is not good - so
 // just use the path api to do it.
 private Path makeRelative(String initial, Path p) {
   String scheme = this.uri.getScheme();
   String authority = this.uri.getAuthority();
   Path root = new Path(Path.SEPARATOR);
   if (root.compareTo(p) == 0) return new Path(scheme, authority, initial);
   Path retPath = new Path(p.getName());
   Path parent = p.getParent();
   for (int i = 0; i < p.depth() - 1; i++) {
     retPath = new Path(parent.getName(), retPath);
     parent = parent.getParent();
   }
   return new Path(new Path(scheme, authority, initial), retPath.toString());
 }
  @Before
  public void setUp() throws IOException {
    htu = new HBaseCommonTestingUtility();
    setupConfiguration(htu.getConfiguration());

    testDir = htu.getDataTestDir();
    fs = testDir.getFileSystem(htu.getConfiguration());
    assertTrue(testDir.depth() > 1);

    logDir = new Path(testDir, "proc-logs");
    procStore = ProcedureTestingUtility.createWalStore(htu.getConfiguration(), fs, logDir);
    procStore.start(PROCEDURE_STORE_SLOTS);
    procStore.recoverLease();

    LoadCounter loader = new LoadCounter();
    procStore.load(loader);
    assertEquals(0, loader.getMaxProcId());
    assertEquals(0, loader.getLoadedCount());
    assertEquals(0, loader.getCorruptedCount());
  }
 /**
  * Check path length does not exceed maximum. Returns true if length and depth are okay. Returns
  * false if length is too long or depth is too great.
  */
 private boolean checkPathLength(String src) {
   Path srcPath = new Path(src);
   return (src.length() <= MAX_PATH_LENGTH && srcPath.depth() <= MAX_PATH_DEPTH);
 }