@Override public void add(HTableDescriptor htd) throws IOException { if (Bytes.equals(HConstants.ROOT_TABLE_NAME, htd.getName())) { throw new NotImplementedException(); } if (Bytes.equals(HConstants.META_TABLE_NAME, htd.getName())) { throw new NotImplementedException(); } if (HConstants.HBASE_NON_USER_TABLE_DIRS.contains(htd.getNameAsString())) { throw new NotImplementedException(); } if (!this.fsreadonly) updateHTableDescriptor(this.fs, this.rootdir, htd); long modtime = getTableInfoModtime(this.fs, this.rootdir, htd.getNameAsString()); this.cache.put(htd.getNameAsString(), new TableDescriptorModtime(modtime, 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(); }