HBASE-3208 HLog.findMemstoresWithEditsOlderThan needs to look for edits
that are equal to too git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1032790 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a68b2c6645
commit
520676aaf1
|
@ -658,6 +658,8 @@ Release 0.90.0 - Unreleased
|
||||||
HBASE-3204 Reenable deferred log flush
|
HBASE-3204 Reenable deferred log flush
|
||||||
HBASE-3195 [rest] Fix TestTransform breakage on Hudson
|
HBASE-3195 [rest] Fix TestTransform breakage on Hudson
|
||||||
HBASE-3205 TableRecordReaderImpl.restart NPEs when first next is restarted
|
HBASE-3205 TableRecordReaderImpl.restart NPEs when first next is restarted
|
||||||
|
HBASE-3208 HLog.findMemstoresWithEditsOlderThan needs to look for edits
|
||||||
|
that are equal to too
|
||||||
|
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
|
|
|
@ -642,7 +642,7 @@ public class HLog implements Syncable {
|
||||||
if (logCount > this.maxLogs && this.outputfiles != null &&
|
if (logCount > this.maxLogs && this.outputfiles != null &&
|
||||||
this.outputfiles.size() > 0) {
|
this.outputfiles.size() > 0) {
|
||||||
// This is an array of encoded region names.
|
// This is an array of encoded region names.
|
||||||
regions = findMemstoresWithEditsOlderThan(this.outputfiles.firstKey(),
|
regions = findMemstoresWithEditsEqualOrOlderThan(this.outputfiles.firstKey(),
|
||||||
this.lastSeqWritten);
|
this.lastSeqWritten);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < regions.length; i++) {
|
for (int i = 0; i < regions.length; i++) {
|
||||||
|
@ -657,19 +657,19 @@ public class HLog implements Syncable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return regions (memstores) that have edits that are less than the passed
|
* Return regions (memstores) that have edits that are equal or less than
|
||||||
* <code>oldestWALseqid</code>.
|
* the passed <code>oldestWALseqid</code>.
|
||||||
* @param oldestWALseqid
|
* @param oldestWALseqid
|
||||||
* @param regionsToSeqids
|
* @param regionsToSeqids
|
||||||
* @return All regions whose seqid is < than <code>oldestWALseqid</code> (Not
|
* @return All regions whose seqid is < than <code>oldestWALseqid</code> (Not
|
||||||
* necessarily in order). Null if no regions found.
|
* necessarily in order). Null if no regions found.
|
||||||
*/
|
*/
|
||||||
static byte [][] findMemstoresWithEditsOlderThan(final long oldestWALseqid,
|
static byte [][] findMemstoresWithEditsEqualOrOlderThan(final long oldestWALseqid,
|
||||||
final Map<byte [], Long> regionsToSeqids) {
|
final Map<byte [], Long> regionsToSeqids) {
|
||||||
// This method is static so it can be unit tested the easier.
|
// This method is static so it can be unit tested the easier.
|
||||||
List<byte []> regions = null;
|
List<byte []> regions = null;
|
||||||
for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
|
for (Map.Entry<byte [], Long> e: regionsToSeqids.entrySet()) {
|
||||||
if (e.getValue().longValue() < oldestWALseqid) {
|
if (e.getValue().longValue() <= oldestWALseqid) {
|
||||||
if (regions == null) regions = new ArrayList<byte []>();
|
if (regions == null) regions = new ArrayList<byte []>();
|
||||||
regions.add(e.getKey());
|
regions.add(e.getKey());
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,28 +262,30 @@ public class TestHLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the findMemstoresWithEditsOlderThan method.
|
* Test the findMemstoresWithEditsEqualOrOlderThan method.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testFindMemstoresWithEditsOlderThan() throws IOException {
|
public void testFindMemstoresWithEditsEqualOrOlderThan() throws IOException {
|
||||||
Map<byte [], Long> regionsToSeqids = new HashMap<byte [], Long>();
|
Map<byte [], Long> regionsToSeqids = new HashMap<byte [], Long>();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Long l = Long.valueOf(i);
|
Long l = Long.valueOf(i);
|
||||||
regionsToSeqids.put(l.toString().getBytes(), l);
|
regionsToSeqids.put(l.toString().getBytes(), l);
|
||||||
}
|
}
|
||||||
byte [][] regions =
|
byte [][] regions =
|
||||||
HLog.findMemstoresWithEditsOlderThan(1, regionsToSeqids);
|
HLog.findMemstoresWithEditsEqualOrOlderThan(1, regionsToSeqids);
|
||||||
assertEquals(1, regions.length);
|
assertEquals(2, regions.length);
|
||||||
assertTrue(Bytes.equals(regions[0], "0".getBytes()));
|
assertTrue(Bytes.equals(regions[0], "0".getBytes()) ||
|
||||||
regions = HLog.findMemstoresWithEditsOlderThan(3, regionsToSeqids);
|
Bytes.equals(regions[0], "1".getBytes()));
|
||||||
int count = 3;
|
regions = HLog.findMemstoresWithEditsEqualOrOlderThan(3, regionsToSeqids);
|
||||||
|
int count = 4;
|
||||||
assertEquals(count, regions.length);
|
assertEquals(count, regions.length);
|
||||||
// Regions returned are not ordered.
|
// Regions returned are not ordered.
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
assertTrue(Bytes.equals(regions[i], "0".getBytes()) ||
|
assertTrue(Bytes.equals(regions[i], "0".getBytes()) ||
|
||||||
Bytes.equals(regions[i], "1".getBytes()) ||
|
Bytes.equals(regions[i], "1".getBytes()) ||
|
||||||
Bytes.equals(regions[i], "2".getBytes()));
|
Bytes.equals(regions[i], "2".getBytes()) ||
|
||||||
|
Bytes.equals(regions[i], "3".getBytes()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue