@InterfaceAudience.Private public class FSTableDescriptors extends Object implements TableDescriptors
TableDescriptors that reads descriptors from the passed filesystem. It
expects descriptors to be in a file in the TABLEINFO_DIR subdir of the table's directory
in FS. Can be read-only -- i.e. does not modify the filesystem or can be read and write.
Also has utility for keeping up the table descriptors tableinfo file. The table schema file is
kept in the TABLEINFO_DIR subdir of the table directory in the filesystem. It has a
TABLEINFO_FILE_PREFIX and then a suffix that is the edit sequenceid: e.g.
.tableinfo.0000000003. This sequenceid is always increasing. It starts at zero. The
table schema file with the highest sequenceid has the most recent schema edit. Usually there is
one file only, the most recent but there may be short periods where there are more than one file.
Old files are eventually cleaned. Presumption is that there will not be lots of concurrent
clients making table schema edits. If so, the below needs a bit of a reworking and perhaps some
supporting api in hdfs.
| Modifier and Type | Field and Description |
|---|---|
static String |
TABLEINFO_DIR |
| Constructor and Description |
|---|
FSTableDescriptors(org.apache.hadoop.conf.Configuration conf)
Construct a FSTableDescriptors instance using the hbase root dir of the given conf and the
filesystem where that root dir lives.
|
FSTableDescriptors(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir) |
FSTableDescriptors(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
boolean fsreadonly,
boolean usecache) |
| Modifier and Type | Method and Description |
|---|---|
static TableDescriptorBuilder |
createMetaTableDescriptorBuilder(org.apache.hadoop.conf.Configuration conf) |
boolean |
createTableDescriptor(TableDescriptor htd)
Create new TableDescriptor in HDFS.
|
boolean |
createTableDescriptor(TableDescriptor htd,
boolean forceCreation)
Create new TableDescriptor in HDFS.
|
static boolean |
createTableDescriptorForTableDirectory(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
TableDescriptor htd,
boolean forceCreation)
Create a new TableDescriptor in HDFS in the specified table directory.
|
boolean |
createTableDescriptorForTableDirectory(org.apache.hadoop.fs.Path tableDir,
TableDescriptor htd,
boolean forceCreation)
Create a new TableDescriptor in HDFS in the specified table directory.
|
static void |
deleteTableDescriptors(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir) |
TableDescriptor |
get(TableName tableName)
Get the current table descriptor for the given table, or null if none exists.
|
Map<String,TableDescriptor> |
getAll()
Returns a map from table name to table descriptor for all tables.
|
Map<String,TableDescriptor> |
getByNamespace(String name)
Find descriptors by namespace.
|
static ColumnFamilyDescriptor |
getReplBarrierFamilyDescForMeta() |
static TableDescriptor |
getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir)
Returns the latest table descriptor for the table located at the given directory directly from
the file system if it exists.
|
static TableDescriptor |
getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir,
TableName tableName)
Returns the latest table descriptor for the given table directly from the file system if it
exists, bypassing the local cache.
|
static ColumnFamilyDescriptor |
getTableFamilyDescForMeta(org.apache.hadoop.conf.Configuration conf) |
static boolean |
isTableDir(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir)
Check whether we have a valid TableDescriptor.
|
protected boolean |
isUsecache() |
TableDescriptor |
remove(TableName tablename)
Removes the table descriptor from the local cache and returns it.
|
static TableDescriptor |
tryUpdateAndGetMetaTableDescriptor(org.apache.hadoop.conf.Configuration conf,
org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir) |
static void |
tryUpdateMetaTableDescriptor(org.apache.hadoop.conf.Configuration conf) |
void |
update(TableDescriptor td,
boolean cacheOnly)
Add or update descriptor
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitexists, updatepublic static final String TABLEINFO_DIR
public FSTableDescriptors(org.apache.hadoop.conf.Configuration conf)
throws IOException
IOExceptionpublic FSTableDescriptors(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir)
public FSTableDescriptors(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
boolean fsreadonly,
boolean usecache)
public static void tryUpdateMetaTableDescriptor(org.apache.hadoop.conf.Configuration conf)
throws IOException
IOExceptionpublic static TableDescriptor tryUpdateAndGetMetaTableDescriptor(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir) throws IOException
IOExceptionpublic static ColumnFamilyDescriptor getTableFamilyDescForMeta(org.apache.hadoop.conf.Configuration conf)
public static ColumnFamilyDescriptor getReplBarrierFamilyDescForMeta()
public static TableDescriptorBuilder createMetaTableDescriptorBuilder(org.apache.hadoop.conf.Configuration conf) throws IOException
IOExceptionprotected boolean isUsecache()
@Nullable public TableDescriptor get(TableName tableName)
fsvisited is not true, i.e, we haven't done a full scan yet, to see if a newer
file has been created since the cached one was read.get in interface TableDescriptorspublic Map<String,TableDescriptor> getAll() throws IOException
getAll in interface TableDescriptorsIOExceptionpublic Map<String,TableDescriptor> getByNamespace(String name) throws IOException
getByNamespace in interface TableDescriptorsIOExceptionget(org.apache.hadoop.hbase.TableName)public void update(TableDescriptor td, boolean cacheOnly) throws IOException
TableDescriptorsupdate in interface TableDescriptorstd - Descriptor to set into TableDescriptorscacheOnly - only add the given htd to cache, without updating the storage. For
example, when creating table, we will write the descriptor to fs when creating
the fs layout, so we do not need to update the fs again.IOExceptionpublic TableDescriptor remove(TableName tablename) throws IOException
remove in interface TableDescriptorsIOExceptionpublic static boolean isTableDir(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir)
throws IOException
IOExceptionpublic static TableDescriptor getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir, TableName tableName) throws IOException
IOExceptionpublic static TableDescriptor getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir) throws IOException
IOExceptionpublic static void deleteTableDescriptors(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir)
throws IOException
IOExceptionpublic boolean createTableDescriptor(TableDescriptor htd) throws IOException
IOExceptionpublic boolean createTableDescriptor(TableDescriptor htd, boolean forceCreation) throws IOException
IOExceptionpublic boolean createTableDescriptorForTableDirectory(org.apache.hadoop.fs.Path tableDir,
TableDescriptor htd,
boolean forceCreation)
throws IOException
tableDir - table directory under which we should write the filehtd - description of the table to writeforceCreation - if true,then even if previous table descriptor is present it will
be overwrittenIOException - if a filesystem error occurspublic static boolean createTableDescriptorForTableDirectory(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir,
TableDescriptor htd,
boolean forceCreation)
throws IOException
fs - Filesystem to use.tableDir - table directory under which we should write the filehtd - description of the table to writeforceCreation - if true,then even if previous table descriptor is present it will
be overwrittenIOException - if a filesystem error occursCopyright © 2007–2020 The Apache Software Foundation. All rights reserved.