Java Code Examples for org.apache.hadoop.hbase.HConstants#HBASE_TEMP_DIRECTORY

The following examples show how to use org.apache.hadoop.hbase.HConstants#HBASE_TEMP_DIRECTORY . 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: MasterFileSystem.java    From hbase with Apache License 2.0 6 votes vote down vote up
public MasterFileSystem(Configuration conf) throws IOException {
  this.conf = conf;
  // Set filesystem to be that of this.rootdir else we get complaints about
  // mismatched filesystems if hbase.rootdir is hdfs and fs.defaultFS is
  // default localfs.  Presumption is that rootdir is fully-qualified before
  // we get to here with appropriate fs scheme.
  this.rootdir = CommonFSUtils.getRootDir(conf);
  this.tempdir = new Path(this.rootdir, HConstants.HBASE_TEMP_DIRECTORY);
  // Cover both bases, the old way of setting default fs and the new.
  // We're supposed to run on 0.20 and 0.21 anyways.
  this.fs = this.rootdir.getFileSystem(conf);
  this.walRootDir = CommonFSUtils.getWALRootDir(conf);
  this.walFs = CommonFSUtils.getWALFileSystem(conf);
  CommonFSUtils.setFsDefault(conf, new Path(this.walFs.getUri()));
  walFs.setConf(conf);
  CommonFSUtils.setFsDefault(conf, new Path(this.fs.getUri()));
  // make sure the fs has the same conf
  fs.setConf(conf);
  this.secureRootSubDirPerms = new FsPermission(conf.get("hbase.rootdir.perms", "700"));
  this.isSecurityEnabled = "kerberos".equalsIgnoreCase(conf.get("hbase.security.authentication"));
  // setup the filesystem variable
  createInitialFileSystemLayout();
  HFileSystem.addLocationsOrderInterceptor(conf);
}
 
Example 2
Source File: SnapshotScannerHDFSAclHelper.java    From hbase with Apache License 2.0 5 votes vote down vote up
PathHelper(Configuration conf) {
  this.conf = conf;
  rootDir = new Path(conf.get(HConstants.HBASE_DIR));
  tmpDataDir = new Path(new Path(rootDir, HConstants.HBASE_TEMP_DIRECTORY),
      HConstants.BASE_NAMESPACE_DIR);
  dataDir = new Path(rootDir, HConstants.BASE_NAMESPACE_DIR);
  mobDataDir = new Path(MobUtils.getMobHome(rootDir), HConstants.BASE_NAMESPACE_DIR);
  archiveDataDir = new Path(new Path(rootDir, HConstants.HFILE_ARCHIVE_DIRECTORY),
      HConstants.BASE_NAMESPACE_DIR);
  snapshotDir = new Path(rootDir, HConstants.SNAPSHOT_DIR_NAME);
}
 
Example 3
Source File: HFileLink.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * @param rootDir Path to the root directory where hbase files are stored
 * @param archiveDir Path to the hbase archive directory
 * @param hFileLinkPattern The path of the HFile Link.
 */
public final static HFileLink buildFromHFileLinkPattern(final Path rootDir,
                                                        final Path archiveDir,
                                                        final Path hFileLinkPattern) {
  Path hfilePath = getHFileLinkPatternRelativePath(hFileLinkPattern);
  Path tempPath = new Path(new Path(rootDir, HConstants.HBASE_TEMP_DIRECTORY), hfilePath);
  Path originPath = new Path(rootDir, hfilePath);
  Path mobPath = new Path(new Path(rootDir, MobConstants.MOB_DIR_NAME), hfilePath);
  Path archivePath = new Path(archiveDir, hfilePath);
  return new HFileLink(originPath, tempPath, mobPath, archivePath);
}
 
Example 4
Source File: SnapshotScannerHDFSAclHelper.java    From hbase with Apache License 2.0 4 votes vote down vote up
Path getTmpDir() {
  return new Path(rootDir, HConstants.HBASE_TEMP_DIRECTORY);
}
 
Example 5
Source File: FSUtils.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * Sets version of file system
 *
 * @param fs filesystem object
 * @param rootdir hbase root directory
 * @param version version to set
 * @param wait time to wait for retry
 * @param retries number of times to retry before throwing an IOException
 * @throws IOException e
 */
public static void setVersion(FileSystem fs, Path rootdir, String version,
    int wait, int retries) throws IOException {
  Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME);
  Path tempVersionFile = new Path(rootdir, HConstants.HBASE_TEMP_DIRECTORY + Path.SEPARATOR +
    HConstants.VERSION_FILE_NAME);
  while (true) {
    try {
      // Write the version to a temporary file
      FSDataOutputStream s = fs.create(tempVersionFile);
      try {
        s.write(toVersionByteArray(version));
        s.close();
        s = null;
        // Move the temp version file to its normal location. Returns false
        // if the rename failed. Throw an IOE in that case.
        if (!fs.rename(tempVersionFile, versionFile)) {
          throw new IOException("Unable to move temp version file to " + versionFile);
        }
      } finally {
        // Cleaning up the temporary if the rename failed would be trying
        // too hard. We'll unconditionally create it again the next time
        // through anyway, files are overwritten by default by create().

        // Attempt to close the stream on the way out if it is still open.
        try {
          if (s != null) s.close();
        } catch (IOException ignore) { }
      }
      LOG.info("Created version file at " + rootdir.toString() + " with version=" + version);
      return;
    } catch (IOException e) {
      if (retries > 0) {
        LOG.debug("Unable to create version file at " + rootdir.toString() + ", retrying", e);
        fs.delete(versionFile, false);
        try {
          if (wait > 0) {
            Thread.sleep(wait);
          }
        } catch (InterruptedException ie) {
          throw (InterruptedIOException)new InterruptedIOException().initCause(ie);
        }
        retries--;
      } else {
        throw e;
      }
    }
  }
}
 
Example 6
Source File: HBaseFsck.java    From hbase with Apache License 2.0 4 votes vote down vote up
/**
 * @return Return the tmp dir this tool writes too.
 */
@VisibleForTesting
public static Path getTmpDir(Configuration conf) throws IOException {
  return new Path(CommonFSUtils.getRootDir(conf), HConstants.HBASE_TEMP_DIRECTORY);
}