@Override
 public HTableDescriptor remove(final String tablename) throws IOException {
   if (!this.fsreadonly) {
     Path tabledir = FSUtils.getTablePath(this.rootdir, tablename);
     if (this.fs.exists(tabledir)) {
       if (!this.fs.delete(tabledir, true)) {
         throw new IOException("Failed delete of " + tabledir.toString());
       }
     }
   }
   TableDescriptorModtime tdm = this.cache.remove(tablename);
   return tdm == null ? null : tdm.getTableDescriptor();
 }
 /**
  * Get HTD from HDFS.
  *
  * @param fs
  * @param hbaseRootDir
  * @param tableName
  * @return Descriptor or null if none found.
  * @throws IOException
  */
 public static HTableDescriptor getTableDescriptor(
     FileSystem fs, Path hbaseRootDir, byte[] tableName) throws IOException {
   HTableDescriptor htd = null;
   try {
     TableDescriptorModtime tdmt =
         getTableDescriptorModtime(fs, hbaseRootDir, Bytes.toString(tableName));
     htd = tdmt == null ? null : tdmt.getTableDescriptor();
   } catch (NullPointerException e) {
     LOG.debug(
         "Exception during readTableDecriptor. Current table name = " + Bytes.toString(tableName),
         e);
   }
   return htd;
 }
  /* (non-Javadoc)
   * @see org.apache.hadoop.hbase.TableDescriptors#getTableDescriptor(byte[])
   */
  @Override
  public HTableDescriptor get(final String tablename) throws IOException {
    invocations++;
    if (HTableDescriptor.ROOT_TABLEDESC.getNameAsString().equals(tablename)) {
      cachehits++;
      return HTableDescriptor.ROOT_TABLEDESC;
    }
    if (HTableDescriptor.META_TABLEDESC.getNameAsString().equals(tablename)) {
      cachehits++;
      return HTableDescriptor.META_TABLEDESC;
    }
    // .META. and -ROOT- is already handled. If some one tries to get the descriptor for
    // .logs, .oldlogs or .corrupt throw an exception.
    if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(tablename)) {
      throw new IOException("No descriptor found for table = " + tablename);
    }

    // Look in cache of descriptors.
    TableDescriptorModtime cachedtdm = this.cache.get(tablename);

    if (cachedtdm != null) {
      // Check mod time has not changed (this is trip to NN).
      if (getTableInfoModtime(this.fs, this.rootdir, tablename) <= cachedtdm.getModtime()) {
        cachehits++;
        return cachedtdm.getTableDescriptor();
      }
    }

    TableDescriptorModtime tdmt = null;
    try {
      tdmt = getTableDescriptorModtime(this.fs, this.rootdir, tablename);
    } catch (NullPointerException e) {
      LOG.debug("Exception during readTableDecriptor. Current table name = " + tablename, e);
    } catch (IOException ioe) {
      LOG.debug("Exception during readTableDecriptor. Current table name = " + tablename, ioe);
    }

    if (tdmt == null) {
      LOG.warn(
          "The following folder is in HBase's root directory and "
              + "doesn't contain a table descriptor, "
              + "do consider deleting it: "
              + tablename);
    } else {
      this.cache.put(tablename, tdmt);
    }
    return tdmt == null ? null : tdmt.getTableDescriptor();
  }
 public static HTableDescriptor getTableDescriptor(FileSystem fs, Path tableDir)
     throws IOException, NullPointerException {
   TableDescriptorModtime tdmt = getTableDescriptorModtime(fs, tableDir);
   return tdmt == null ? null : tdmt.getTableDescriptor();
 }
 static HTableDescriptor getTableDescriptor(FileSystem fs, Path hbaseRootDir, String tableName)
     throws NullPointerException, IOException {
   TableDescriptorModtime tdmt = getTableDescriptorModtime(fs, hbaseRootDir, tableName);
   return tdmt == null ? null : tdmt.getTableDescriptor();
 }