Search in sources :

Example 1 with WALEntryBatch

use of org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceWALReaderThread.WALEntryBatch in project hbase by apache.

the class TestWALEntryStream method testReplicationSourceWALReaderThread.

@Test
public void testReplicationSourceWALReaderThread() throws Exception {
    appendEntriesToLog(3);
    // get ending position
    long position;
    try (WALEntryStream entryStream = new WALEntryStream(walQueue, fs, conf, new MetricsSource("1"))) {
        entryStream.next();
        entryStream.next();
        entryStream.next();
        position = entryStream.getPosition();
    }
    // start up a batcher
    ReplicationSourceManager mockSourceManager = Mockito.mock(ReplicationSourceManager.class);
    when(mockSourceManager.getTotalBufferUsed()).thenReturn(new AtomicLong(0));
    ReplicationSourceWALReaderThread batcher = new ReplicationSourceWALReaderThread(mockSourceManager, getQueueInfo(), walQueue, 0, fs, conf, getDummyFilter(), new MetricsSource("1"));
    Path walPath = walQueue.peek();
    batcher.start();
    WALEntryBatch entryBatch = batcher.take();
    // should've batched up our entries
    assertNotNull(entryBatch);
    assertEquals(3, entryBatch.getWalEntries().size());
    assertEquals(position, entryBatch.getLastWalPosition());
    assertEquals(walPath, entryBatch.getLastWalPath());
    assertEquals(3, entryBatch.getNbRowKeys());
    appendToLog("foo");
    entryBatch = batcher.take();
    assertEquals(1, entryBatch.getNbEntries());
    assertEquals(getRow(entryBatch.getWalEntries().get(0)), "foo");
}
Also used : Path(org.apache.hadoop.fs.Path) AtomicLong(java.util.concurrent.atomic.AtomicLong) WALEntryBatch(org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceWALReaderThread.WALEntryBatch) Test(org.junit.Test)

Aggregations

AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Path (org.apache.hadoop.fs.Path)1 WALEntryBatch (org.apache.hadoop.hbase.replication.regionserver.ReplicationSourceWALReaderThread.WALEntryBatch)1 Test (org.junit.Test)1