APISonar


org.apache.hadoop.fs.FileContext.util

> org > apache > hadoop > fs > FileContext > util
org APIs apache APIs hadoop APIs fs APIs FileContext APIs util APIs

Example 1
public boolean blobExists(String blobName) {
        try {
            return store.execute(new Operation<Boolean>() {
                @Override
                public Boolean run(FileContext fileContext) throws IOException {
                    return fileContext.util().exists(new Path(path, blobName));
                }
            });
        } catch (Exception e) {
            return false;
        }
    }
Example 2
public static void assertPathExists(FileContext fileContext, String message,
      Path path) throws IOException {
    if (!fileContext.util().exists(path)) {
      //failure, report it
      throw new FileNotFoundException(
          message + ": not found " + path + " in " + path.getParent());
    }
  }
Example 3
private void deleteFileWithRetries(final FileContext fileContext,
      final Path deletePath) throws Exception {
    new FSAction<Void>() {
      @Override
      public Void run() throws Exception {
        if (fileContext.util().exists(deletePath)) {
          fileContext.delete(deletePath, false);
        }
        return null;
      }
    }.runWithRetries();
  }
Example 4
private Object deleteFileWithPrivilege(final FileContext fileContext,
      final UserGroupInformation userUgi, final Path fileToDelete)
      throws Exception {
    return userUgi.doAs(new PrivilegedExceptionAction<Object>() {
      @Override
      public Object run() throws Exception {
        if (fileContext.util().exists(fileToDelete)) {
          fileContext.delete(fileToDelete, false);
        }
        return null;
      }
    });
  }
Example 5
private void cleanupLogDir(FileContext fs, DeletionService del,
      String logDir) throws IOException {
    if (!fs.util().exists(new Path(logDir))){
      return;
    }
    renameAppLogDir(logDir);
    deleteAppLogDir(fs, del, logDir);
  }
Example 6
private static FileContext fc;

  private void initFileDirTables(Path path) throws IOException {
    FileStatus[] stats = fc.util().listStatus(path);

    for (FileStatus stat : stats) {
      if (stat.isDirectory()) {
        dirs.add(stat.getPath().toString());
        initFileDirTables(stat.getPath());
      } else {
        Path filePath = stat.getPath();
        if (filePath.getName().startsWith(StructureGenerator.FILE_NAME_PREFIX)) {
          files.add(filePath.toString());
        }
      }
    }
  }
Example 7
private FileContext doneDirFc; // done Dir FileContext

  private void moveToDoneNow(final Path src, final Path target)
      throws IOException {
    LOG.info("Moving " + src.toString() + " to " + target.toString());
    try {
      intermediateDoneDirFc.rename(src, target, Options.Rename.NONE);
    } catch (FileNotFoundException e) {
      if (doneDirFc.util().exists(target)) {
        LOG.info("Source file " + src.toString() + " not found, but target "
            + "file " + target.toString() + " already exists. Move already "
            + "happened.");
      } else {
        throw e;
      }
    }
  }