HBASE-729 lient region/metadata cache should have a public method for invalidating entries
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@684951 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0696c139f5
commit
6cab23c4a0
|
@ -7,6 +7,8 @@ Release 0.3.0 - Unreleased
|
||||||
HBASE-805 Remove unnecessary getRow overloads in HRS (Jonathan Gray via
|
HBASE-805 Remove unnecessary getRow overloads in HRS (Jonathan Gray via
|
||||||
Jim Kellerman) (Fix whitespace diffs in HRegionServer)
|
Jim Kellerman) (Fix whitespace diffs in HRegionServer)
|
||||||
HBASE-811 HTD is not fully copyable (Andrew Purtell via Jim Kellerman)
|
HBASE-811 HTD is not fully copyable (Andrew Purtell via Jim Kellerman)
|
||||||
|
HBASE-729 Client region/metadata cache should have a public method for
|
||||||
|
invalidating entries (Andrew Purtell via Stack)
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-801 When a table haven't disable, shell could response in a "user
|
HBASE-801 When a table haven't disable, shell could response in a "user
|
||||||
|
|
|
@ -371,62 +371,43 @@ public class HConnectionManager implements HConstants {
|
||||||
return rowsScanned > 0 && result;
|
return rowsScanned > 0 && result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class HTableDescriptorFinder
|
||||||
|
implements MetaScanner.MetaScannerVisitor {
|
||||||
|
byte[] tableName;
|
||||||
|
HTableDescriptor result;
|
||||||
|
public HTableDescriptorFinder(byte[] tableName) {
|
||||||
|
this.tableName = tableName;
|
||||||
|
}
|
||||||
|
public boolean processRow(RowResult rowResult) throws IOException {
|
||||||
|
HRegionInfo info = Writables.getHRegionInfo(
|
||||||
|
rowResult.get(HConstants.COL_REGIONINFO));
|
||||||
|
HTableDescriptor desc = info.getTableDesc();
|
||||||
|
if (Bytes.compareTo(desc.getName(), tableName) == 0) {
|
||||||
|
result = desc;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
HTableDescriptor getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public HTableDescriptor getHTableDescriptor(byte[] tableName)
|
public HTableDescriptor getHTableDescriptor(final byte[] tableName)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
|
if (Bytes.equals(tableName, HConstants.ROOT_TABLE_NAME)) {
|
||||||
return new UnmodifyableHTableDescriptor(HTableDescriptor.ROOT_TABLEDESC);
|
return new UnmodifyableHTableDescriptor(HTableDescriptor.ROOT_TABLEDESC);
|
||||||
}
|
}
|
||||||
if (!tableExists(tableName)) {
|
if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
|
||||||
|
return new UnmodifyableHTableDescriptor(HTableDescriptor.META_TABLEDESC);
|
||||||
|
}
|
||||||
|
HTableDescriptorFinder finder = new HTableDescriptorFinder(tableName);
|
||||||
|
MetaScanner.metaScan(conf, finder);
|
||||||
|
HTableDescriptor result = finder.getResult();
|
||||||
|
if (result == null) {
|
||||||
throw new TableNotFoundException(Bytes.toString(tableName));
|
throw new TableNotFoundException(Bytes.toString(tableName));
|
||||||
}
|
}
|
||||||
byte[] startKey =
|
|
||||||
HRegionInfo.createRegionName(tableName, null, HConstants.ZEROES);
|
|
||||||
|
|
||||||
HTableDescriptor result = null;
|
|
||||||
HRegionInfo currentRegion = null;
|
|
||||||
ScannerCallable s = null;
|
|
||||||
while (result == null) {
|
|
||||||
if (currentRegion != null) {
|
|
||||||
byte[] endKey = currentRegion.getEndKey();
|
|
||||||
if (endKey == null ||
|
|
||||||
Bytes.equals(endKey, HConstants.EMPTY_BYTE_ARRAY)) {
|
|
||||||
// We have reached the end of the table and we're done
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
HRegionInfo oldRegion = currentRegion;
|
|
||||||
if (oldRegion != null) {
|
|
||||||
startKey = oldRegion.getEndKey();
|
|
||||||
}
|
|
||||||
s = new ScannerCallable(this,
|
|
||||||
(Bytes.equals(tableName, HConstants.META_TABLE_NAME) ?
|
|
||||||
HConstants.ROOT_TABLE_NAME : HConstants.META_TABLE_NAME),
|
|
||||||
HConstants.COL_REGIONINFO_ARRAY, startKey,
|
|
||||||
HConstants.LATEST_TIMESTAMP, null
|
|
||||||
);
|
|
||||||
// Open scanner
|
|
||||||
getRegionServerWithRetries(s);
|
|
||||||
currentRegion = s.getHRegionInfo();
|
|
||||||
try {
|
|
||||||
RowResult r = null;
|
|
||||||
while ((r = getRegionServerWithRetries(s)) != null) {
|
|
||||||
Cell c = r.get(HConstants.COL_REGIONINFO);
|
|
||||||
if (c != null) {
|
|
||||||
HRegionInfo info = Writables.getHRegionInfoOrNull(c.getValue());
|
|
||||||
if (info != null) {
|
|
||||||
if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
|
|
||||||
result = new UnmodifyableHTableDescriptor(info.getTableDesc());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
s.setClose();
|
|
||||||
getRegionServerWithRetries(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,19 +150,12 @@ public class TestHTable extends HBaseClusterTestCase implements HConstants {
|
||||||
// enable the table
|
// enable the table
|
||||||
admin.enableTable(tableAname);
|
admin.enableTable(tableAname);
|
||||||
|
|
||||||
// Use a metascanner to avoid client API caching (HConnection has a
|
// test that attribute changes were applied
|
||||||
// metadata cache)
|
desc = a.getTableDescriptor();
|
||||||
MetaScanner.MetaScannerVisitor visitor =
|
if (Bytes.compareTo(desc.getName(), tableAname) != 0)
|
||||||
new MetaScanner.MetaScannerVisitor() {
|
fail("wrong table descriptor returned");
|
||||||
public boolean processRow(RowResult rowResult) throws IOException {
|
|
||||||
HRegionInfo info = Writables.getHRegionInfo(
|
|
||||||
rowResult.get(HConstants.COL_REGIONINFO));
|
|
||||||
|
|
||||||
LOG.info("visiting " + info.toString());
|
|
||||||
HTableDescriptor desc = info.getTableDesc();
|
|
||||||
if (Bytes.compareTo(desc.getName(), tableAname) == 0) {
|
|
||||||
// check HTD attribute
|
// check HTD attribute
|
||||||
byte[] value = desc.getValue(attrName);
|
value = desc.getValue(attrName);
|
||||||
if (value == null)
|
if (value == null)
|
||||||
fail("missing HTD attribute value");
|
fail("missing HTD attribute value");
|
||||||
if (Bytes.compareTo(value, attrValue) != 0)
|
if (Bytes.compareTo(value, attrValue) != 0)
|
||||||
|
@ -175,11 +168,7 @@ public class TestHTable extends HBaseClusterTestCase implements HConstants {
|
||||||
if (Bytes.compareTo(value, attrValue) != 0)
|
if (Bytes.compareTo(value, attrValue) != 0)
|
||||||
fail("HCD attribute value is incorrect");
|
fail("HCD attribute value is incorrect");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
MetaScanner.metaScan(conf, visitor);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail();
|
fail();
|
||||||
|
|
Loading…
Reference in New Issue