HBASE-451 Remove HTableDescriptor from HRegionInfo -- part 2, some cleanup
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1138601 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f389865787
commit
7b6f6d6e19
|
@ -35,6 +35,7 @@ import org.apache.hadoop.hbase.HBaseConfiguration;
|
||||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.MasterNotRunningException;
|
import org.apache.hadoop.hbase.MasterNotRunningException;
|
||||||
import org.apache.hadoop.hbase.TableExistsException;
|
import org.apache.hadoop.hbase.TableExistsException;
|
||||||
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
import org.apache.hadoop.hbase.avro.generated.AClusterStatus;
|
import org.apache.hadoop.hbase.avro.generated.AClusterStatus;
|
||||||
import org.apache.hadoop.hbase.avro.generated.ADelete;
|
import org.apache.hadoop.hbase.avro.generated.ADelete;
|
||||||
import org.apache.hadoop.hbase.avro.generated.AFamilyDescriptor;
|
import org.apache.hadoop.hbase.avro.generated.AFamilyDescriptor;
|
||||||
|
@ -190,6 +191,8 @@ public class AvroServer {
|
||||||
public ATableDescriptor describeTable(ByteBuffer table) throws AIOError {
|
public ATableDescriptor describeTable(ByteBuffer table) throws AIOError {
|
||||||
try {
|
try {
|
||||||
return AvroUtil.htdToATD(admin.getTableDescriptor(Bytes.toBytes(table)));
|
return AvroUtil.htdToATD(admin.getTableDescriptor(Bytes.toBytes(table)));
|
||||||
|
} catch (TableNotFoundException e) {
|
||||||
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
AIOError ioe = new AIOError();
|
AIOError ioe = new AIOError();
|
||||||
ioe.message = new Utf8(e.getMessage());
|
ioe.message = new Utf8(e.getMessage());
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.hadoop.hbase.RegionException;
|
||||||
import org.apache.hadoop.hbase.RemoteExceptionHandler;
|
import org.apache.hadoop.hbase.RemoteExceptionHandler;
|
||||||
import org.apache.hadoop.hbase.ServerName;
|
import org.apache.hadoop.hbase.ServerName;
|
||||||
import org.apache.hadoop.hbase.TableExistsException;
|
import org.apache.hadoop.hbase.TableExistsException;
|
||||||
|
import org.apache.hadoop.hbase.TableNotFoundException;
|
||||||
import org.apache.hadoop.hbase.UnknownRegionException;
|
import org.apache.hadoop.hbase.UnknownRegionException;
|
||||||
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
|
import org.apache.hadoop.hbase.ZooKeeperConnectionException;
|
||||||
import org.apache.hadoop.hbase.catalog.CatalogTracker;
|
import org.apache.hadoop.hbase.catalog.CatalogTracker;
|
||||||
|
@ -194,10 +195,11 @@ public class HBaseAdmin implements Abortable, Closeable {
|
||||||
* Method for getting the tableDescriptor
|
* Method for getting the tableDescriptor
|
||||||
* @param tableName as a byte []
|
* @param tableName as a byte []
|
||||||
* @return the tableDescriptor
|
* @return the tableDescriptor
|
||||||
|
* @throws TableNotFoundException
|
||||||
* @throws IOException if a remote or network exception occurs
|
* @throws IOException if a remote or network exception occurs
|
||||||
*/
|
*/
|
||||||
public HTableDescriptor getTableDescriptor(final byte [] tableName)
|
public HTableDescriptor getTableDescriptor(final byte [] tableName)
|
||||||
throws IOException {
|
throws TableNotFoundException, IOException {
|
||||||
return this.connection.getHTableDescriptor(tableName);
|
return this.connection.getHTableDescriptor(tableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -936,6 +936,9 @@ public class FSUtils {
|
||||||
HTableDescriptor htd = null;
|
HTableDescriptor htd = null;
|
||||||
try {
|
try {
|
||||||
htd = getTableDescriptor(fs, getTablePath(hbaseRootDir, tableName));
|
htd = getTableDescriptor(fs, getTablePath(hbaseRootDir, tableName));
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
LOG.debug("Exception during readTableDecriptor. Current table name = " +
|
||||||
|
tableName , e);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
LOG.debug("Exception during readTableDecriptor. Current table name = " +
|
LOG.debug("Exception during readTableDecriptor. Current table name = " +
|
||||||
tableName , ioe);
|
tableName , ioe);
|
||||||
|
@ -944,10 +947,10 @@ public class FSUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HTableDescriptor getTableDescriptor(FileSystem fs, Path tableDir)
|
public static HTableDescriptor getTableDescriptor(FileSystem fs, Path tableDir)
|
||||||
throws IOException {
|
throws IOException, NullPointerException {
|
||||||
if (tableDir == null) throw new NullPointerException();
|
if (tableDir == null) throw new NullPointerException();
|
||||||
FSDataInputStream fsDataInputStream =
|
Path tableinfo = new Path(tableDir, HConstants.TABLEINFO_NAME);
|
||||||
fs.open(new Path(tableDir, HConstants.TABLEINFO_NAME));
|
FSDataInputStream fsDataInputStream = fs.open(tableinfo);
|
||||||
HTableDescriptor hTableDescriptor = null;
|
HTableDescriptor hTableDescriptor = null;
|
||||||
try {
|
try {
|
||||||
hTableDescriptor = new HTableDescriptor();
|
hTableDescriptor = new HTableDescriptor();
|
||||||
|
|
|
@ -125,7 +125,11 @@ public class TestAvroServer {
|
||||||
tableA.maxFileSize = 123456L;
|
tableA.maxFileSize = 123456L;
|
||||||
impl.modifyTable(tableAname, tableA);
|
impl.modifyTable(tableAname, tableA);
|
||||||
// It can take a while for the change to take effect. Wait here a while.
|
// It can take a while for the change to take effect. Wait here a while.
|
||||||
while(impl.describeTable(tableAname).maxFileSize != 123456L) Threads.sleep(100);
|
while(impl.describeTable(tableAname) == null) {
|
||||||
|
Threads.sleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(impl.describeTable(tableAname).maxFileSize == 123456L);
|
||||||
assertEquals(123456L, (long) impl.describeTable(tableAname).maxFileSize);
|
assertEquals(123456L, (long) impl.describeTable(tableAname).maxFileSize);
|
||||||
/* DISABLED FOR NOW TILL WE HAVE BETTER DISABLE/ENABLE
|
/* DISABLED FOR NOW TILL WE HAVE BETTER DISABLE/ENABLE
|
||||||
impl.enableTable(tableAname);
|
impl.enableTable(tableAname);
|
||||||
|
|
|
@ -36,8 +36,6 @@ import org.apache.hadoop.hbase.HTableDescriptor;
|
||||||
import org.apache.hadoop.hbase.catalog.CatalogTracker;
|
import org.apache.hadoop.hbase.catalog.CatalogTracker;
|
||||||
import org.apache.hadoop.hbase.catalog.MetaReader;
|
import org.apache.hadoop.hbase.catalog.MetaReader;
|
||||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.client.HConnection;
|
|
||||||
import org.apache.hadoop.hbase.client.HConnectionManager;
|
|
||||||
import org.apache.hadoop.hbase.client.Put;
|
import org.apache.hadoop.hbase.client.Put;
|
||||||
import org.apache.hadoop.hbase.regionserver.HRegion;
|
import org.apache.hadoop.hbase.regionserver.HRegion;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -96,7 +94,9 @@ public class TestMergeTable {
|
||||||
byte [] row_70001 = Bytes.toBytes("row_70001");
|
byte [] row_70001 = Bytes.toBytes("row_70001");
|
||||||
byte [] row_80001 = Bytes.toBytes("row_80001");
|
byte [] row_80001 = Bytes.toBytes("row_80001");
|
||||||
|
|
||||||
// Create regions and populate them at same time.
|
// Create regions and populate them at same time. Create the tabledir
|
||||||
|
// for them first.
|
||||||
|
FSUtils.createTableDescriptor(fs, rootdir, desc);
|
||||||
HRegion [] regions = {
|
HRegion [] regions = {
|
||||||
createRegion(desc, null, row_70001, 1, 70000, rootdir),
|
createRegion(desc, null, row_70001, 1, 70000, rootdir),
|
||||||
createRegion(desc, row_70001, row_80001, 70001, 10000, rootdir),
|
createRegion(desc, row_70001, row_80001, 70001, 10000, rootdir),
|
||||||
|
|
Loading…
Reference in New Issue