コード例 #1
0
 /** Deletes a table's directory from the file system if exists. Used in unit tests. */
 public static void deleteTableDescriptorIfExists(String tableName, Configuration conf)
     throws IOException {
   FileSystem fs = FSUtils.getCurrentFileSystem(conf);
   FileStatus status = getTableInfoPath(fs, FSUtils.getRootDir(conf), tableName);
   // The below deleteDirectory works for either file or directory.
   if (status != null && fs.exists(status.getPath())) {
     FSUtils.deleteDirectory(fs, status.getPath());
   }
 }
コード例 #2
0
  @Override
  public void start(CoprocessorEnvironment e) throws IOException {
    region = (HRegion) ((RegionCoprocessorEnvironment) e).getRegion();
    String[] name = region.getTableDesc().getNameAsString().split(":");
    if (name.length == 2) {
      namespace = name[0];
      tableName = name[1];
    } else {
      tableName = name[0];
    }
    regionName = region.getRegionInfo().getEncodedName();

    path = HConfiguration.getConfiguration().getBackupPath() + "/" + tableName + "/" + regionName;
    conf = HConfiguration.unwrapDelegate();
    rootDir = FSUtils.getRootDir(conf);
    fs = FSUtils.getCurrentFileSystem(conf);
    backupDir =
        new Path(
            rootDir,
            BackupRestoreConstants.BACKUP_DIR + "/data/splice/" + tableName + "/" + regionName);
    preparing = false;
  }
コード例 #3
0
 /**
  * Create new HTableDescriptor in HDFS. Happens when we are creating table. If forceCreation is
  * true then even if previous table descriptor is present it will be overwritten
  *
  * @param htableDescriptor
  * @param conf
  * @param forceCreation True if we are to overwrite existing file.
  */
 static boolean createTableDescriptor(
     final HTableDescriptor htableDescriptor, final Configuration conf, boolean forceCreation)
     throws IOException {
   FileSystem fs = FSUtils.getCurrentFileSystem(conf);
   return createTableDescriptor(fs, FSUtils.getRootDir(conf), htableDescriptor, forceCreation);
 }