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:
parent
b77dca0c7f
commit
a4a4e97338
|
@ -34,7 +34,7 @@ public interface TableDescriptors {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public HTableDescriptor get(final String tablename)
|
public HTableDescriptor get(final String tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException;
|
throws FileNotFoundException, IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param tablename
|
* @param tablename
|
||||||
|
@ -44,7 +44,7 @@ public interface TableDescriptors {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public HTableDescriptor get(final byte[] tablename)
|
public HTableDescriptor get(final byte[] tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException;
|
throws FileNotFoundException, IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Map of all HTableDescriptors. Populates the descriptor cache as a
|
* Get Map of all HTableDescriptors. Populates the descriptor cache as a
|
||||||
|
|
|
@ -321,7 +321,7 @@ class CatalogJanitor extends Chore {
|
||||||
}
|
}
|
||||||
|
|
||||||
private HTableDescriptor getTableDescriptor(byte[] tableName)
|
private HTableDescriptor getTableDescriptor(byte[] tableName)
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
return this.services.getTableDescriptors().get(Bytes.toString(tableName));
|
return this.services.getTableDescriptors().get(Bytes.toString(tableName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -687,17 +687,14 @@ public class DefaultLoadBalancer implements LoadBalancer {
|
||||||
{
|
{
|
||||||
tableDescriptor = this.services.getTableDescriptors().
|
tableDescriptor = this.services.getTableDescriptors().
|
||||||
get(Bytes.toString(tableName));
|
get(Bytes.toString(tableName));
|
||||||
}
|
}
|
||||||
} catch (TableExistsException tee) {
|
|
||||||
LOG.debug("TableExistsException during getTableDescriptors." +
|
|
||||||
" Current table name = " + tableName , tee);
|
|
||||||
} catch (FileNotFoundException fnfe) {
|
} catch (FileNotFoundException fnfe) {
|
||||||
LOG.debug("FileNotFoundException during getTableDescriptors." +
|
LOG.debug("FileNotFoundException during getTableDescriptors." +
|
||||||
" Current table name = " + tableName , fnfe);
|
" Current table name = " + tableName , fnfe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tableDescriptor;
|
return tableDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map hostname to ServerName, The output ServerName list will have the same
|
* Map hostname to ServerName, The output ServerName list will have the same
|
||||||
|
|
|
@ -272,7 +272,7 @@ public abstract class TableEventHandler extends EventHandler {
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
HTableDescriptor getTableDescriptor()
|
HTableDescriptor getTableDescriptor()
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
final String name = Bytes.toString(tableName);
|
final String name = Bytes.toString(tableName);
|
||||||
HTableDescriptor htd =
|
HTableDescriptor htd =
|
||||||
this.masterServices.getTableDescriptors().get(name);
|
this.masterServices.getTableDescriptors().get(name);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class FSTableDescriptors implements TableDescriptors {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HTableDescriptor get(final byte [] tablename)
|
public HTableDescriptor get(final byte [] tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
return get(Bytes.toString(tablename));
|
return get(Bytes.toString(tablename));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class FSTableDescriptors implements TableDescriptors {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HTableDescriptor get(final String tablename)
|
public HTableDescriptor get(final String tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
invocations++;
|
invocations++;
|
||||||
if (HTableDescriptor.ROOT_TABLEDESC.getNameAsString().equals(tablename)) {
|
if (HTableDescriptor.ROOT_TABLEDESC.getNameAsString().equals(tablename)) {
|
||||||
cachehits++;
|
cachehits++;
|
||||||
|
@ -160,10 +160,12 @@ public class FSTableDescriptors implements TableDescriptors {
|
||||||
}
|
}
|
||||||
HTableDescriptor htd = getTableDescriptor(this.fs, this.rootdir, tablename);
|
HTableDescriptor htd = getTableDescriptor(this.fs, this.rootdir, tablename);
|
||||||
if (htd == null) {
|
if (htd == null) {
|
||||||
// More likely is above will throw a FileNotFoundException
|
LOG.warn("The following folder is in HBase's root directory and " +
|
||||||
throw new TableExistsException("No descriptor for " + tablename);
|
"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;
|
return htd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -235,13 +235,13 @@ public class TestCatalogJanitor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HTableDescriptor get(byte[] tablename)
|
public HTableDescriptor get(byte[] tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
return get(Bytes.toString(tablename));
|
return get(Bytes.toString(tablename));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HTableDescriptor get(String tablename)
|
public HTableDescriptor get(String tablename)
|
||||||
throws TableExistsException, FileNotFoundException, IOException {
|
throws FileNotFoundException, IOException {
|
||||||
return createHTableDescriptor();
|
return createHTableDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,14 +202,15 @@ public class TestFSTableDescriptors {
|
||||||
htds.cachehits >= ((count * 2) + 1));
|
htds.cachehits >= ((count * 2) + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test (expected=org.apache.hadoop.hbase.TableExistsException.class)
|
@Test
|
||||||
public void testNoSuchTable() throws IOException {
|
public void testNoSuchTable() throws IOException {
|
||||||
final String name = "testNoSuchTable";
|
final String name = "testNoSuchTable";
|
||||||
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
|
FileSystem fs = FileSystem.get(UTIL.getConfiguration());
|
||||||
// Cleanup old tests if any detrius laying around.
|
// Cleanup old tests if any detrius laying around.
|
||||||
Path rootdir = new Path(UTIL.getDataTestDir(), name);
|
Path rootdir = new Path(UTIL.getDataTestDir(), name);
|
||||||
TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
|
TableDescriptors htds = new FSTableDescriptors(fs, rootdir);
|
||||||
htds.get("NoSuchTable");
|
assertNull("There shouldn't be any HTD for this table",
|
||||||
|
htds.get("NoSuchTable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue