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
Nested ClassesModifier and TypeClassDescription(package private) static enumprivate classThis thread will keep writing to a 'wal' file even after the split process has started. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HBaseClassTestRuleprivate static org.apache.hadoop.conf.Configurationprivate org.apache.hadoop.fs.Pathprivate static final intprivate static final byte[]private static final Stringprivate org.apache.hadoop.fs.FileSystemprivate static String[]private org.apache.hadoop.fs.Pathprivate org.apache.hadoop.fs.Pathprivate static final org.slf4j.Loggerorg.junit.rules.TestNameprivate static final intprivate org.apache.hadoop.fs.Pathprivate static final byte[]private static Stringprivate static final org.apache.hadoop.hbase.TableNameprivate org.apache.hadoop.fs.Pathprotected static final HBaseTestingUtilityprivate Stringprivate static final byte[]private static final Stringprivate org.apache.hadoop.fs.Pathprivate org.apache.hadoop.hbase.wal.WALFactoryprivate static String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidappendCompactionEvent(org.apache.hadoop.hbase.wal.WALProvider.Writer w, org.apache.hadoop.hbase.client.RegionInfo hri, String[] inputs, String output) private static longappendEmptyEntry(org.apache.hadoop.hbase.wal.WALProvider.Writer writer, org.apache.hadoop.hbase.TableName table, byte[] region, long seq) private static longappendEntry(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 voidappendRegionEvent(org.apache.hadoop.hbase.wal.WALProvider.Writer w, String region) private voidcloseOrFlush(boolean close, org.apache.hadoop.fs.FSDataOutputStream out) private voidcorruptWAL(org.apache.hadoop.fs.Path path, TestWALSplit.Corruptions corruption, boolean close) private intcountWAL(org.apache.hadoop.fs.Path log) private static org.apache.hadoop.hbase.wal.WAL.EntrycreateEmptyEntry(org.apache.hadoop.hbase.TableName table, byte[] region, long seq) private org.apache.hadoop.fs.Pathprivate static org.apache.hadoop.hbase.wal.WAL.EntrycreateTestEntry(org.apache.hadoop.hbase.TableName table, byte[] region, byte[] row, byte[] family, byte[] qualifier, byte[] value, long seq) private voiddoTestThreading(int numFakeEdits, int bufferSize, int writerSlowness) Sets up a log splitter with a mock reader and writer.private voidgenerateEmptyEditWAL(org.apache.hadoop.fs.Path path, byte[] region) private voidgenerateReplicationMarkerEdits(org.apache.hadoop.fs.Path path, org.apache.hadoop.hbase.client.RegionInfo regionInfo) private org.apache.hadoop.hbase.wal.WALProvider.WritergenerateWALs(int leaveOpen) private org.apache.hadoop.hbase.wal.WALProvider.WritergenerateWALs(int writers, int entries, int leaveOpen) private org.apache.hadoop.hbase.wal.WALProvider.WritergenerateWALs(int writers, int entries, int leaveOpen, int regionEvents) private org.apache.hadoop.fs.Path[]getLogForRegion(org.apache.hadoop.hbase.TableName table, String region) private voidignoreCorruption(TestWALSplit.Corruptions corruption, int entryCount, int expectedCount) private voidinjectEmptyFile(String suffix, boolean closeFile) private booleanlogsAreEqual(org.apache.hadoop.fs.Path p1, org.apache.hadoop.fs.Path p2) private voidmakeRegionDirs(List<String> regions) private voidretryOverHdfsProblem(org.apache.hadoop.fs.FileSystem spiedFs) voidsetUp()static voidprivate intsplitAndCount(int expectedFiles, int expectedEntries) voidtearDown()static voidvoidvoidvoidvoidvoidprivate voidtestEmptyLogFiles(boolean close) voidvoidSee HBASE-27644, typically we should not have empty WALEdit but we should be able to process it, instead of losing data after it.voidvoidvoidvoidvoidSimulates splitting a WAL out from under a regionserver that is still trying to write it.voidvoidvoidvoidvoidTest old recovered edits file doesn't break WALSplitter.voidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidvoidTests that WalSplitter ignores replication marker edits.voidvoidvoidTest log split process with fake data and lots of edits to trigger threading issues.voidTest blocking behavior of the log split process if writers are writing slower than the reader is reading.voidvoidprivate 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:
IOExceptionInterruptedException
-
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:
IOExceptionorg.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
-