Search in sources :

Example 1 with FlushResultImpl

use of org.apache.hadoop.hbase.regionserver.HRegion.FlushResultImpl in project hbase by apache.

the class TestHRegionReplayEvents method testRegionReplicaSecondaryCannotFlush.

// Some of the test cases are as follows:
// 1. replay flush start marker again
// 2. replay flush with smaller seqId than what is there in memstore snapshot
// 3. replay flush with larger seqId than what is there in memstore snapshot
// 4. replay flush commit without flush prepare. non droppable memstore
// 5. replay flush commit without flush prepare. droppable memstore
// 6. replay open region event
// 7. replay open region event after flush start
// 8. replay flush form an earlier seqId (test ignoring seqIds)
// 9. start flush does not prevent region from closing.
@Test
public void testRegionReplicaSecondaryCannotFlush() throws IOException {
    // load some data and flush ensure that the secondary replica will not execute the flush
    // load some data to secondary by replaying
    putDataByReplay(secondaryRegion, 0, 1000, cq, families);
    verifyData(secondaryRegion, 0, 1000, cq, families);
    // flush region
    FlushResultImpl flush = (FlushResultImpl) secondaryRegion.flush(true);
    assertEquals(flush.result, FlushResultImpl.Result.CANNOT_FLUSH);
    verifyData(secondaryRegion, 0, 1000, cq, families);
    // close the region, and inspect that it has not flushed
    Map<byte[], List<StoreFile>> files = secondaryRegion.close(false);
    // assert that there are no files (due to flush)
    for (List<StoreFile> f : files.values()) {
        assertTrue(f.isEmpty());
    }
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) FlushResultImpl(org.apache.hadoop.hbase.regionserver.HRegion.FlushResultImpl) Test(org.junit.Test)

Example 2 with FlushResultImpl

use of org.apache.hadoop.hbase.regionserver.HRegion.FlushResultImpl in project hbase by apache.

the class TestHRegionReplayEvents method testWriteFlushRequestMarker.

/**
   * Tests the case where a request for flush cache is sent to the region, but region cannot flush.
   * It should write the flush request marker instead.
   */
@Test
public void testWriteFlushRequestMarker() throws IOException {
    // primary region is empty at this point. Request a flush with writeFlushRequestWalMarker=false
    FlushResultImpl result = (FlushResultImpl) ((HRegion) primaryRegion).flushcache(true, false);
    assertNotNull(result);
    assertEquals(result.result, FlushResultImpl.Result.CANNOT_FLUSH_MEMSTORE_EMPTY);
    assertFalse(result.wroteFlushWalMarker);
    // request flush again, but this time with writeFlushRequestWalMarker = true
    result = (FlushResultImpl) ((HRegion) primaryRegion).flushcache(true, true);
    assertNotNull(result);
    assertEquals(result.result, FlushResultImpl.Result.CANNOT_FLUSH_MEMSTORE_EMPTY);
    assertTrue(result.wroteFlushWalMarker);
    List<FlushDescriptor> flushes = Lists.newArrayList();
    reader = createWALReaderForPrimary();
    while (true) {
        WAL.Entry entry = reader.next();
        if (entry == null) {
            break;
        }
        FlushDescriptor flush = WALEdit.getFlushDescriptor(entry.getEdit().getCells().get(0));
        if (flush != null) {
            flushes.add(flush);
        }
    }
    assertEquals(1, flushes.size());
    assertNotNull(flushes.get(0));
    assertEquals(FlushDescriptor.FlushAction.CANNOT_FLUSH, flushes.get(0).getAction());
}
Also used : WAL(org.apache.hadoop.hbase.wal.WAL) FlushDescriptor(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor) StoreFlushDescriptor(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor.StoreFlushDescriptor) FlushResultImpl(org.apache.hadoop.hbase.regionserver.HRegion.FlushResultImpl) Test(org.junit.Test)

Aggregations

FlushResultImpl (org.apache.hadoop.hbase.regionserver.HRegion.FlushResultImpl)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FlushDescriptor (org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor)1 StoreFlushDescriptor (org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor.StoreFlushDescriptor)1 WAL (org.apache.hadoop.hbase.wal.WAL)1