HBASE-5415 FSTableDescriptors should handle random folders in

hbase.root.dir better


git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1293042 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jean-Daniel Cryans 2012-02-24 00:41:31 +00:00
parent b77dca0c7f
commit a4a4e97338
7 changed files with 18 additions and 18 deletions

View File

@ -34,7 +34,7 @@ public interface TableDescriptors {
* @throws IOException
*/
public HTableDescriptor get(final String tablename)
throws TableExistsException, FileNotFoundException, IOException;
throws FileNotFoundException, IOException;
/**
* @param tablename
@ -44,7 +44,7 @@ public interface TableDescriptors {
* @throws IOException
*/
public HTableDescriptor get(final byte[] tablename)
throws TableExistsException, FileNotFoundException, IOException;
throws FileNotFoundException, IOException;
/**
* Get Map of all HTableDescriptors. Populates the descriptor cache as a

View File

@ -321,7 +321,7 @@ class CatalogJanitor extends Chore {
}
private HTableDescriptor getTableDescriptor(byte[] tableName)
throws TableExistsException, FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
return this.services.getTableDescriptors().get(Bytes.toString(tableName));
}
}

View File

@ -687,17 +687,14 @@ public class DefaultLoadBalancer implements LoadBalancer {
{
tableDescriptor = this.services.getTableDescriptors().
get(Bytes.toString(tableName));
}
} catch (TableExistsException tee) {
LOG.debug("TableExistsException during getTableDescriptors." +
" Current table name = " + tableName , tee);
}
} catch (FileNotFoundException fnfe) {
LOG.debug("FileNotFoundException during getTableDescriptors." +
" Current table name = " + tableName , fnfe);
}
return tableDescriptor;
}
}
/**
* Map hostname to ServerName, The output ServerName list will have the same

View File

@ -272,7 +272,7 @@ public abstract class TableEventHandler extends EventHandler {
* @throws IOException
*/
HTableDescriptor getTableDescriptor()
throws TableExistsException, FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
final String name = Bytes.toString(tableName);
HTableDescriptor htd =
this.masterServices.getTableDescriptors().get(name);

View File

@ -122,7 +122,7 @@ public class FSTableDescriptors implements TableDescriptors {
*/
@Override
public HTableDescriptor get(final byte [] tablename)
throws TableExistsException, FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
return get(Bytes.toString(tablename));
}
@ -131,7 +131,7 @@ public class FSTableDescriptors implements TableDescriptors {
*/
@Override
public HTableDescriptor get(final String tablename)
throws TableExistsException, FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
invocations++;
if (HTableDescriptor.ROOT_TABLEDESC.getNameAsString().equals(tablename)) {
cachehits++;
@ -160,10 +160,12 @@ public class FSTableDescriptors implements TableDescriptors {
}
HTableDescriptor htd = getTableDescriptor(this.fs, this.rootdir, tablename);
if (htd == null) {
// More likely is above will throw a FileNotFoundException
throw new TableExistsException("No descriptor for " + tablename);
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, new TableDescriptorModtime(modtime, htd));
}
this.cache.put(tablename, new TableDescriptorModtime(modtime, htd));
return htd;
}

View File

@ -235,13 +235,13 @@ public class TestCatalogJanitor {
@Override
public HTableDescriptor get(byte[] tablename)
throws TableExistsException, FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
return get(Bytes.toString(tablename));
}
@Override
public HTableDescriptor get(String tablename)
throws TableExistsException, FileNotFoundException, IOException {
throws FileNotFoundException, IOException {
return createHTableDescriptor();
}

View File

@ -202,14 +202,15 @@ public class TestFSTableDescriptors {
htds.cachehits >= ((count * 2) + 1));
}
@Test (expected=org.apache.hadoop.hbase.TableExistsException.class)
@Test
public void testNoSuchTable() throws IOException {
final String name = "testNoSuchTable";
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
// Cleanup old tests if any detrius laying around.
Path rootdir = new Path(UTIL.getDataTestDir(), name);
TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
htds.get("NoSuchTable");
assertNull("There shouldn't be any HTD for this table",
htds.get("NoSuchTable"));
}
@Test