|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.hbase.util.FSTableDescriptors
public class FSTableDescriptors
Implementation of TableDescriptors
that reads descriptors from the
passed filesystem. It expects descriptors to be in a file under 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 under the table directory in the filesystem.
It has a TABLEINFO_NAME
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.
Field Summary | |
---|---|
static String |
TABLEINFO_NAME
The file name used to store HTD in HDFS |
Constructor Summary | |
---|---|
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)
|
Method Summary | |
---|---|
void |
add(HTableDescriptor htd)
Add or update descriptor |
static boolean |
createTableDescriptor(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
HTableDescriptor htableDescriptor)
Create new HTableDescriptor in HDFS. |
static boolean |
createTableDescriptor(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
HTableDescriptor htableDescriptor,
boolean forceCreation)
Create new HTableDescriptor in HDFS. |
static boolean |
createTableDescriptor(HTableDescriptor htableDescriptor,
org.apache.hadoop.conf.Configuration conf)
Create new HTableDescriptor in HDFS. |
static boolean |
createTableDescriptorForTableDirectory(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tabledir,
HTableDescriptor htableDescriptor,
boolean forceCreation)
Create a new HTableDescriptor in HDFS in the specified table directory. |
static void |
deleteTableDescriptorIfExists(String tableName,
org.apache.hadoop.conf.Configuration conf)
Deletes a table's directory from the file system if exists. |
HTableDescriptor |
get(byte[] tablename)
|
HTableDescriptor |
get(String tablename)
|
Map<String,HTableDescriptor> |
getAll()
Get Map of all HTableDescriptors. |
static HTableDescriptor |
getTableDescriptor(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tableDir)
|
static HTableDescriptor |
getTableDescriptor(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir,
byte[] tableName)
Get HTD from HDFS. |
static HTableDescriptor |
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 HTableDescriptor |
getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path hbaseRootDir,
String tableName)
Returns the latest table descriptor for the given table directly from the file system if it exists, bypassing the local cache. |
static org.apache.hadoop.fs.FileStatus |
getTableInfoPath(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path tabledir)
Looks under the table directory in the filesystem for files with a TABLEINFO_NAME prefix. |
static boolean |
isTableInfoExists(org.apache.hadoop.fs.FileSystem fs,
org.apache.hadoop.fs.Path rootdir,
String tableName)
Checks if .tableinfo |
HTableDescriptor |
remove(String tablename)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String TABLEINFO_NAME
Constructor Detail |
---|
public 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)
fs
- rootdir
- fsreadOnly
- True if we are read-only when it comes to filesystem
operations; i.e. on remove, we do not do delete in fs.Method Detail |
---|
public HTableDescriptor get(byte[] tablename) throws IOException
get
in interface TableDescriptors
IOException
public HTableDescriptor get(String tablename) throws IOException
get
in interface TableDescriptors
IOException
public Map<String,HTableDescriptor> getAll() throws IOException
TableDescriptors
getAll
in interface TableDescriptors
IOException
public void add(HTableDescriptor htd) throws IOException
TableDescriptors
add
in interface TableDescriptors
htd
- Descriptor to set into TableDescriptors
IOException
public HTableDescriptor remove(String tablename) throws IOException
remove
in interface TableDescriptors
IOException
public static boolean isTableInfoExists(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, String tableName) throws IOException
.tableinfo exists for given table
- Parameters:
fs
- file systemrootdir
- root directory of HBase installationtableName
- name of table
- Returns:
- true if exists
- Throws:
IOException
public static org.apache.hadoop.fs.FileStatus getTableInfoPath(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tabledir) throws IOException
TABLEINFO_NAME
prefix. Returns reference to the 'latest' instance.
fs
- tabledir
-
IOException
public static HTableDescriptor getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir, String tableName) throws IOException
IOException
public static HTableDescriptor getTableDescriptorFromFs(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir) throws IOException
TableInfoMissingException
- if there is no descriptor
IOException
public static HTableDescriptor getTableDescriptor(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path hbaseRootDir, byte[] tableName) throws IOException
fs
- hbaseRootDir
- tableName
-
IOException
public static HTableDescriptor getTableDescriptor(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tableDir) throws IOException, NullPointerException
IOException
NullPointerException
public static void deleteTableDescriptorIfExists(String tableName, org.apache.hadoop.conf.Configuration conf) throws IOException
IOException
public static boolean createTableDescriptor(HTableDescriptor htableDescriptor, org.apache.hadoop.conf.Configuration conf) throws IOException
htableDescriptor
- conf
-
IOException
public static boolean createTableDescriptor(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, HTableDescriptor htableDescriptor) throws IOException
fs
- htableDescriptor
- rootdir
-
IOException
public static boolean createTableDescriptor(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path rootdir, HTableDescriptor htableDescriptor, boolean forceCreation) throws IOException
fs
- htableDescriptor
- rootdir
- forceCreation
-
IOException
public static boolean createTableDescriptorForTableDirectory(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path tabledir, HTableDescriptor htableDescriptor, boolean forceCreation) throws IOException
fs
- filesystem where the descriptor should be writtentabledir
- directory under which we should write the filehtableDescriptor
- description of the table to writeforceCreation
- if true,then even if previous table descriptor is present it will
be overwritten
IOException
- if a filesystem error occurs
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |