Package org.apache.hadoop.hbase.wal
Class TestWALSplit
java.lang.Object
org.apache.hadoop.hbase.wal.TestWALSplit
- Direct Known Subclasses:
TestWALSplitBoundedLogWriterCreation
,TestWALSplitCompressed
,TestWALSplitValueCompression
Testing
WAL
splitting code.-
Nested Class Summary
Modifier and TypeClassDescription(package private) static enum
private class
This thread will keep writing to a 'wal' file even after the split process has started. -
Field Summary
Modifier and TypeFieldDescriptionstatic final HBaseClassTestRule
private static org.apache.hadoop.conf.Configuration
private org.apache.hadoop.fs.Path
private static final int
private static final byte[]
private static final String
private org.apache.hadoop.fs.FileSystem
private static String[]
private org.apache.hadoop.fs.Path
private org.apache.hadoop.fs.Path
private static final org.slf4j.Logger
org.junit.rules.TestName
private static final int
private org.apache.hadoop.fs.Path
private static final byte[]
private static String
private static final org.apache.hadoop.hbase.TableName
private org.apache.hadoop.fs.Path
protected static final HBaseTestingUtility
private String
private static final byte[]
private static final String
private org.apache.hadoop.fs.Path
private org.apache.hadoop.hbase.wal.WALFactory
private static String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate static void
appendCompactionEvent
(org.apache.hadoop.hbase.wal.WALProvider.Writer w, org.apache.hadoop.hbase.client.RegionInfo hri, String[] inputs, String output) private static long
appendEmptyEntry
(org.apache.hadoop.hbase.wal.WALProvider.Writer writer, org.apache.hadoop.hbase.TableName table, byte[] region, long seq) private static long
appendEntry
(org.apache.hadoop.hbase.wal.WALProvider.Writer writer, org.apache.hadoop.hbase.TableName table, byte[] region, byte[] row, byte[] family, byte[] qualifier, byte[] value, long seq) private static void
appendRegionEvent
(org.apache.hadoop.hbase.wal.WALProvider.Writer w, String region) private void
closeOrFlush
(boolean close, org.apache.hadoop.fs.FSDataOutputStream out) private void
corruptWAL
(org.apache.hadoop.fs.Path path, TestWALSplit.Corruptions corruption, boolean close) private int
countWAL
(org.apache.hadoop.fs.Path log) private static org.apache.hadoop.hbase.wal.WAL.Entry
createEmptyEntry
(org.apache.hadoop.hbase.TableName table, byte[] region, long seq) private org.apache.hadoop.fs.Path
private static org.apache.hadoop.hbase.wal.WAL.Entry
createTestEntry
(org.apache.hadoop.hbase.TableName table, byte[] region, byte[] row, byte[] family, byte[] qualifier, byte[] value, long seq) private void
doTestThreading
(int numFakeEdits, int bufferSize, int writerSlowness) Sets up a log splitter with a mock reader and writer.private void
generateEmptyEditWAL
(org.apache.hadoop.fs.Path path, byte[] region) private void
generateReplicationMarkerEdits
(org.apache.hadoop.fs.Path path, org.apache.hadoop.hbase.client.RegionInfo regionInfo) private org.apache.hadoop.hbase.wal.WALProvider.Writer
generateWALs
(int leaveOpen) private org.apache.hadoop.hbase.wal.WALProvider.Writer
generateWALs
(int writers, int entries, int leaveOpen) private org.apache.hadoop.hbase.wal.WALProvider.Writer
generateWALs
(int writers, int entries, int leaveOpen, int regionEvents) private org.apache.hadoop.fs.Path[]
getLogForRegion
(org.apache.hadoop.hbase.TableName table, String region) private void
ignoreCorruption
(TestWALSplit.Corruptions corruption, int entryCount, int expectedCount) private void
injectEmptyFile
(String suffix, boolean closeFile) private boolean
logsAreEqual
(org.apache.hadoop.fs.Path p1, org.apache.hadoop.fs.Path p2) private void
makeRegionDirs
(List<String> regions) private void
retryOverHdfsProblem
(org.apache.hadoop.fs.FileSystem spiedFs) void
setUp()
static void
private int
splitAndCount
(int expectedFiles, int expectedEntries) void
tearDown()
static void
void
void
void
void
void
private void
testEmptyLogFiles
(boolean close) void
void
See HBASE-27644, typically we should not have empty WALEdit but we should be able to process it, instead of losing data after it.void
void
void
void
void
Simulates splitting a WAL out from under a regionserver that is still trying to write it.void
void
void
void
void
Test old recovered edits file doesn't break WALSplitter.void
void
void
void
void
void
void
void
void
void
void
void
void
void
Tests that WalSplitter ignores replication marker edits.void
void
void
Test log split process with fake data and lots of edits to trigger threading issues.void
Test blocking behavior of the log split process if writers are writing slower than the reader is reading.void
void
private void
-
Field Details
-
CLASS_RULE
-
LOG
-
conf
-
fs
-
TEST_UTIL
-
HBASEDIR
-
HBASELOGDIR
-
WALDIR
-
OLDLOGDIR
-
CORRUPTDIR
-
TABLEDIR
-
TMPDIRNAME
-
NUM_WRITERS
- See Also:
-
ENTRIES
- See Also:
-
FILENAME_BEING_SPLIT
- See Also:
-
TABLE_NAME
-
FAMILY
-
QUALIFIER
-
VALUE
-
WAL_FILE_PREFIX
- See Also:
-
REGIONS
-
ROBBER
-
ZOMBIE
-
GROUP
-
name
-
wals
-
-
Constructor Details
-
TestWALSplit
public TestWALSplit()
-
-
Method Details
-
setUpBeforeClass
- Throws:
Exception
-
tearDownAfterClass
- Throws:
Exception
-
setUp
- Throws:
Exception
-
tearDown
- Throws:
Exception
-
testLogCannotBeWrittenOnceParsed
Simulates splitting a WAL out from under a regionserver that is still trying to write it. Ensures we do not lose edits.- Throws:
IOException
InterruptedException
-
testRecoveredEditsPathForMeta
- Throws:
IOException
- See Also:
-
- "https://issues.apache.org/jira/browse/HBASE-3020"
-
testOldRecoveredEditsFileSidelined
Test old recovered edits file doesn't break WALSplitter. This is useful in upgrading old instances.- Throws:
IOException
-
createRecoveredEditsPathForRegion
- Throws:
IOException
-
testHasRecoveredEdits
- Throws:
IOException
-
useDifferentDFSClient
- Throws:
IOException
-
testSplitPreservesEdits
- Throws:
IOException
-
testSplitRemovesRegionEventsEdits
- Throws:
IOException
-
testSplitLeavesCompactionEventsEdits
- Throws:
IOException
-
testSplitRemovesReplicationMarkerEdits
Tests that WalSplitter ignores replication marker edits.- Throws:
IOException
-
generateReplicationMarkerEdits
private void generateReplicationMarkerEdits(org.apache.hadoop.fs.Path path, org.apache.hadoop.hbase.client.RegionInfo regionInfo) throws IOException - Throws:
IOException
-
splitAndCount
- Parameters:
expectedEntries
- -1 to not assert- Returns:
- the count across all regions
- Throws:
IOException
-
testEmptyLogFiles
- Throws:
IOException
-
testEmptyOpenLogFiles
- Throws:
IOException
-
testEmptyLogFiles
- Throws:
IOException
-
testOpenZeroLengthReportedFileButWithDataGetsSplit
- Throws:
IOException
-
testTralingGarbageCorruptionFileSkipErrorsPasses
- Throws:
IOException
-
testFirstLineCorruptionLogFileSkipErrorsPasses
- Throws:
IOException
-
testMiddleGarbageCorruptionSkipErrorsReadsHalfOfFile
- Throws:
IOException
-
testCorruptedFileGetsArchivedIfSkipErrors
- Throws:
IOException
-
splitCorruptWALs
private Set<String> splitCorruptWALs(FaultyProtobufWALStreamReader.FailureType failureType) throws IOException - Returns:
- set of wal names present prior to split attempt.
- Throws:
IOException
- if the split process fails
-
testTrailingGarbageCorruptionLogFileSkipErrorsFalseThrows
- Throws:
IOException
-
testCorruptedLogFilesSkipErrorsFalseDoesNotTouchLogs
- Throws:
IOException
-
ignoreCorruption
private void ignoreCorruption(TestWALSplit.Corruptions corruption, int entryCount, int expectedCount) throws IOException - Throws:
IOException
-
testEOFisIgnored
- Throws:
IOException
-
testCorruptWALTrailer
- Throws:
IOException
-
testLogsGetArchivedAfterSplit
- Throws:
IOException
-
testSplit
- Throws:
IOException
-
testLogDirectoryShouldBeDeletedAfterSuccessfulSplit
- Throws:
IOException
-
testSplitWillFailIfWritingToRegionFails
- Throws:
Exception
-
testSplitDeletedRegion
- Throws:
IOException
-
testIOEOnOutputThread
- Throws:
Exception
-
retryOverHdfsProblem
- Parameters:
spiedFs
- should be instrumented for failure.- Throws:
Exception
-
testMovedWALDuringRecovery
- Throws:
Exception
-
testRetryOpenDuringRecovery
- Throws:
Exception
-
testTerminationAskedByReporter
public void testTerminationAskedByReporter() throws IOException, org.apache.hadoop.hbase.wal.WALSplitter.CorruptedLogFileException- Throws:
IOException
org.apache.hadoop.hbase.wal.WALSplitter.CorruptedLogFileException
-
testThreading
Test log split process with fake data and lots of edits to trigger threading issues.- Throws:
Exception
-
testThreadingSlowWriterSmallBuffer
Test blocking behavior of the log split process if writers are writing slower than the reader is reading.- Throws:
Exception
-
doTestThreading
Sets up a log splitter with a mock reader and writer. The mock reader generates a specified number of edits spread across 5 regions. The mock writer optionally sleeps for each edit it is fed. After the split is complete, verifies that the statistics show the correct number of edits output into each region.- Parameters:
numFakeEdits
- number of fake edits to push through pipelinebufferSize
- size of in-memory bufferwriterSlowness
- writer threads will sleep this many ms per edit- Throws:
Exception
-
testSplitLogFileDeletedRegionDir
- Throws:
IOException
-
testSplitLogFileEmpty
- Throws:
IOException
-
testSplitLogFileMultipleRegions
- Throws:
IOException
-
testSplitLogFileFirstLineCorruptionLog
- Throws:
IOException
-
testConcurrentSplitLogAndReplayRecoverEdit
- Throws:
IOException
- See Also:
-
- "https://issues.apache.org/jira/browse/HBASE-4862"
-
testRecoveredEditsStoragePolicy
- Throws:
IOException
-
testEmptyWALEdit
See HBASE-27644, typically we should not have empty WALEdit but we should be able to process it, instead of losing data after it.- Throws:
IOException
-
generateEmptyEditWAL
- Throws:
IOException
-
generateWALs
private org.apache.hadoop.hbase.wal.WALProvider.Writer generateWALs(int leaveOpen) throws IOException - Throws:
IOException
-
generateWALs
private org.apache.hadoop.hbase.wal.WALProvider.Writer generateWALs(int writers, int entries, int leaveOpen) throws IOException - Throws:
IOException
-
makeRegionDirs
- Throws:
IOException
-
generateWALs
private org.apache.hadoop.hbase.wal.WALProvider.Writer generateWALs(int writers, int entries, int leaveOpen, int regionEvents) throws IOException - Parameters:
leaveOpen
- index to leave un-closed. -1 to close all.- Returns:
- the writer that's still open, or null if all were closed.
- Throws:
IOException
-
getLogForRegion
private org.apache.hadoop.fs.Path[] getLogForRegion(org.apache.hadoop.hbase.TableName table, String region) throws IOException - Throws:
IOException
-
corruptWAL
private void corruptWAL(org.apache.hadoop.fs.Path path, TestWALSplit.Corruptions corruption, boolean close) throws IOException - Throws:
IOException
-
closeOrFlush
private void closeOrFlush(boolean close, org.apache.hadoop.fs.FSDataOutputStream out) throws IOException - Throws:
IOException
-
countWAL
- Throws:
IOException
-
appendCompactionEvent
private static void appendCompactionEvent(org.apache.hadoop.hbase.wal.WALProvider.Writer w, org.apache.hadoop.hbase.client.RegionInfo hri, String[] inputs, String output) throws IOException - Throws:
IOException
-
appendRegionEvent
private static void appendRegionEvent(org.apache.hadoop.hbase.wal.WALProvider.Writer w, String region) throws IOException - Throws:
IOException
-
appendEntry
private static long appendEntry(org.apache.hadoop.hbase.wal.WALProvider.Writer writer, org.apache.hadoop.hbase.TableName table, byte[] region, byte[] row, byte[] family, byte[] qualifier, byte[] value, long seq) throws IOException - Throws:
IOException
-
createTestEntry
private static org.apache.hadoop.hbase.wal.WAL.Entry createTestEntry(org.apache.hadoop.hbase.TableName table, byte[] region, byte[] row, byte[] family, byte[] qualifier, byte[] value, long seq) -
appendEmptyEntry
private static long appendEmptyEntry(org.apache.hadoop.hbase.wal.WALProvider.Writer writer, org.apache.hadoop.hbase.TableName table, byte[] region, long seq) throws IOException - Throws:
IOException
-
createEmptyEntry
private static org.apache.hadoop.hbase.wal.WAL.Entry createEmptyEntry(org.apache.hadoop.hbase.TableName table, byte[] region, long seq) -
injectEmptyFile
- Throws:
IOException
-
logsAreEqual
private boolean logsAreEqual(org.apache.hadoop.fs.Path p1, org.apache.hadoop.fs.Path p2) throws IOException - Throws:
IOException
-