Java Code Examples for org.apache.hadoop.hdfs.DFSClient#exists()

The following examples show how to use org.apache.hadoop.hdfs.DFSClient#exists() . 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: NamenodeFsck.java    From RDFS with Apache License 2.0 6 votes vote down vote up
private void lostFoundInit(DFSClient dfs) {
  lfInited = true;
  try {
    String lfName = "/lost+found";
    // check that /lost+found exists
    if (!dfs.exists(lfName)) {
      lfInitedOk = dfs.mkdirs(lfName);
      lostFound = lfName;
    } else        if (!dfs.isDirectory(lfName)) {
      LOG.warn("Cannot use /lost+found : a regular file with this name exists.");
      lfInitedOk = false;
    }  else { // exists and isDirectory
      lostFound = lfName;
      lfInitedOk = true;
    }
  }  catch (Exception e) {
    e.printStackTrace();
    lfInitedOk = false;
  }
  if (lostFound == null) {
    LOG.warn("Cannot initialize /lost+found .");
    lfInitedOk = false;
  }
}
 
Example 2
Source File: NamenodeFsck.java    From hadoop-gpu with Apache License 2.0 6 votes vote down vote up
private void lostFoundInit(DFSClient dfs) {
  lfInited = true;
  try {
    String lfName = "/lost+found";
    // check that /lost+found exists
    if (!dfs.exists(lfName)) {
      lfInitedOk = dfs.mkdirs(lfName);
      lostFound = lfName;
    } else        if (!dfs.isDirectory(lfName)) {
      LOG.warn("Cannot use /lost+found : a regular file with this name exists.");
      lfInitedOk = false;
    }  else { // exists and isDirectory
      lostFound = lfName;
      lfInitedOk = true;
    }
  }  catch (Exception e) {
    e.printStackTrace();
    lfInitedOk = false;
  }
  if (lostFound == null) {
    LOG.warn("Cannot initialize /lost+found .");
    lfInitedOk = false;
  }
}
 
Example 3
Source File: TestDFSClientCache.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private static boolean isDfsClientClose(DFSClient c) {
  try {
    c.exists("");
  } catch (IOException e) {
    return e.getMessage().equals("Filesystem closed");
  }
  return false;
}
 
Example 4
Source File: TestDFSClientCache.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static boolean isDfsClientClose(DFSClient c) {
  try {
    c.exists("");
  } catch (IOException e) {
    return e.getMessage().equals("Filesystem closed");
  }
  return false;
}