HBASE-1215 migration; metautils scan of meta region was broken; wouldn't see first row
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@796850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2fc56ed998
commit
9037b2149a
|
@ -380,6 +380,13 @@ public class HColumnDescriptor implements ISerializable, WritableComparable<HCol
|
|||
new ImmutableBytesWritable(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key Key whose key and value we're to remove from HCD parameters.
|
||||
*/
|
||||
public void remove(final byte [] key) {
|
||||
values.remove(new ImmutableBytesWritable(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key The key.
|
||||
* @param value The value.
|
||||
|
|
|
@ -2042,10 +2042,10 @@ public class HRegionServer implements HConstants, HRegionInterface,
|
|||
}
|
||||
String lockName = String.valueOf(lockId);
|
||||
Integer rl = null;
|
||||
synchronized(rowlocks) {
|
||||
synchronized (rowlocks) {
|
||||
rl = rowlocks.get(lockName);
|
||||
}
|
||||
if(rl == null) {
|
||||
if (rl == null) {
|
||||
throw new IOException("Invalid row lock");
|
||||
}
|
||||
this.leases.renewLease(lockName);
|
||||
|
|
|
@ -192,23 +192,33 @@ public class MetaUtils {
|
|||
if (this.rootRegion == null) {
|
||||
openRootRegion();
|
||||
}
|
||||
scanMetaRegion(this.rootRegion, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the passed in metaregion <code>m</code> invoking the passed
|
||||
* <code>listener</code> per row found.
|
||||
* @param m
|
||||
* @param listener
|
||||
* @throws IOException
|
||||
*/
|
||||
public void scanMetaRegion(final HRegion r, final ScannerListener listener)
|
||||
throws IOException {
|
||||
Scan scan = new Scan();
|
||||
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
|
||||
InternalScanner rootScanner = this.rootRegion.getScanner(scan);
|
||||
|
||||
InternalScanner s = r.getScanner(scan);
|
||||
try {
|
||||
List<KeyValue> results = new ArrayList<KeyValue>();
|
||||
boolean hasNext = true;
|
||||
do {
|
||||
hasNext = rootScanner.next(results);
|
||||
hasNext = s.next(results);
|
||||
HRegionInfo info = null;
|
||||
for (KeyValue kv: results) {
|
||||
info = Writables.getHRegionInfoOrNull(kv.getValue());
|
||||
if (info == null) {
|
||||
LOG.warn("region info is null for row " +
|
||||
Bytes.toString(kv.getRow()) + " in table " +
|
||||
HConstants.ROOT_TABLE_NAME);
|
||||
LOG.warn("Region info is null for row " +
|
||||
Bytes.toString(kv.getRow()) + " in table " +
|
||||
r.getTableDesc().getNameAsString());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -218,7 +228,7 @@ public class MetaUtils {
|
|||
results.clear();
|
||||
} while (hasNext);
|
||||
} finally {
|
||||
rootScanner.close();
|
||||
r.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,46 +254,6 @@ public class MetaUtils {
|
|||
scanMetaRegion(metaRegion, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scan the passed in metaregion <code>m</code> invoking the passed
|
||||
* <code>listener</code> per row found.
|
||||
* @param m
|
||||
* @param listener
|
||||
* @throws IOException
|
||||
*/
|
||||
public void scanMetaRegion(final HRegion m, final ScannerListener listener)
|
||||
throws IOException {
|
||||
|
||||
Scan scan = new Scan();
|
||||
scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
|
||||
InternalScanner metaScanner = m.getScanner(scan);
|
||||
|
||||
try {
|
||||
List<KeyValue> results = new ArrayList<KeyValue>();
|
||||
while (metaScanner.next(results)) {
|
||||
HRegionInfo info = null;
|
||||
for (KeyValue kv: results) {
|
||||
if(kv.matchingColumn(HConstants.CATALOG_FAMILY,
|
||||
HConstants.REGIONINFO_QUALIFIER)) {
|
||||
info = Writables.getHRegionInfoOrNull(kv.getValue());
|
||||
if (info == null) {
|
||||
LOG.warn("region info is null for row " +
|
||||
Bytes.toString(kv.getRow()) +
|
||||
" in table " + HConstants.META_TABLE_NAME);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!listener.processRow(info)) {
|
||||
break;
|
||||
}
|
||||
results.clear();
|
||||
}
|
||||
} finally {
|
||||
metaScanner.close();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized HRegion openRootRegion() throws IOException {
|
||||
if (this.rootRegion != null) {
|
||||
return this.rootRegion;
|
||||
|
|
|
@ -247,8 +247,9 @@ public class Migrate extends Configured implements Tool {
|
|||
final MetaUtils utils = new MetaUtils(this.conf);
|
||||
final List<HRegionInfo> metas = new ArrayList<HRegionInfo>();
|
||||
try {
|
||||
// Rewrite root.
|
||||
rewriteHRegionInfo(utils.getRootRegion().getRegionInfo());
|
||||
// Scan the root region
|
||||
// Scan the root region to rewrite metas.
|
||||
utils.scanRootRegion(new MetaUtils.ScannerListener() {
|
||||
public boolean processRow(HRegionInfo info)
|
||||
throws IOException {
|
||||
|
@ -261,7 +262,7 @@ public class Migrate extends Configured implements Tool {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
// Scan meta.
|
||||
// Scan meta to rewrite table stuff.
|
||||
for (HRegionInfo hri: metas) {
|
||||
final HRegion h = utils.getMetaRegion(hri);
|
||||
utils.scanMetaRegion(h, new MetaUtils.ScannerListener() {
|
||||
|
@ -432,8 +433,11 @@ public class Migrate extends Configured implements Tool {
|
|||
// Set compression to none. Previous was 'none'. Needs to be upper-case.
|
||||
// Any other compression we are turning off. Have user enable it.
|
||||
hcd.setCompressionType(Algorithm.NONE);
|
||||
// Remove the old MEMCACHE_FLUSHSIZE if present
|
||||
hcd.remove(Bytes.toBytes("MEMCACHE_FLUSHSIZE"));
|
||||
result = true;
|
||||
}
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -25,6 +25,17 @@ import java.util.Arrays;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
public class TestBytes extends TestCase {
|
||||
public void testNullHashCode() {
|
||||
byte [] b = null;
|
||||
Exception ee = null;
|
||||
try {
|
||||
Bytes.hashCode(b);
|
||||
} catch (Exception e) {
|
||||
ee = e;
|
||||
}
|
||||
assertNotNull(ee);
|
||||
}
|
||||
|
||||
public void testSplit() throws Exception {
|
||||
byte [] lowest = Bytes.toBytes("AAA");
|
||||
byte [] middle = Bytes.toBytes("CCC");
|
||||
|
|
Loading…
Reference in New Issue