Package org.apache.hadoop.hbase
Class TestPartialResultsFromClientSide
java.lang.Object
org.apache.hadoop.hbase.TestPartialResultsFromClientSide
These tests are focused on testing how partial results appear to a client. Partial results are
Result
s that contain only a portion of a row's complete list of cells. Partial results
are formed when the server breaches its maximum result size when trying to service a client's RPC
request. It is the responsibility of the scanner on the client side to recognize when partial
results have been returned and to take action to form the complete results.
Unless the flag Scan.setAllowPartialResults(boolean)
has been set to true, the caller of
ResultScanner.next()
should never see partial results.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static long
static final HBaseClassTestRule
private static byte[][]
private static byte[]
private static final org.slf4j.Logger
private static final int
org.junit.rules.TestName
private static int
private static int
private static int
private static int
private static byte[]
private static byte[][]
private static byte[]
private static byte[][]
private static org.apache.hadoop.hbase.client.Table
private static org.apache.hadoop.hbase.TableName
Table configurationprivate static final HBaseTestingUtil
private static long
private static byte[]
private static int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
assertCell
(org.apache.hadoop.hbase.Cell cell, byte[] row, byte[] cf, byte[] cq) (package private) static void
compareResults
(org.apache.hadoop.hbase.client.Result r1, org.apache.hadoop.hbase.client.Result r2, String message) Compares two results and fails the test if the results are differentprivate int
countCellsFromScanner
(org.apache.hadoop.hbase.client.ResultScanner scanner) Exhausts the scanner by calling next repetitively.(package private) static ArrayList<org.apache.hadoop.hbase.Cell>
createKeyValuesForRow
(byte[] row, byte[][] families, byte[][] qualifiers, byte[] value) Make key values to represent each possible combination of family and qualifier in the specified row.(package private) static ArrayList<org.apache.hadoop.hbase.client.Put>
createPuts
(byte[][] rows, byte[][] families, byte[][] qualifiers, byte[] value) Make puts to put the input value into each combination of row, family, and qualifier(package private) static org.apache.hadoop.hbase.client.Table
createTestTable
(org.apache.hadoop.hbase.TableName name, byte[][] rows, byte[][] families, byte[][] qualifiers, byte[] cellValue) private long
private long
getResultSizeForNumberOfCells
(int numberOfCells) private void
moveRegion
(org.apache.hadoop.hbase.client.Table table, int index) static void
static void
void
Ensure that we only see Results marked as partial when the allowPartial flag is setvoid
void
void
void
Ensure that the results returned from a scanner that retrieves all results in a single RPC call matches the results that are returned from a scanner that must incrementally combine partial results into complete results.void
testEquivalenceOfScanResults
(org.apache.hadoop.hbase.client.Table table, org.apache.hadoop.hbase.client.Scan scan1, org.apache.hadoop.hbase.client.Scan scan2) void
When reconstructing the complete result from its partials we ensure that the row of each partial result is the same.void
Setting the max result size allows us to control how many cells we expect to see on each call to next on the scanner.void
testExpectedNumberOfCellsPerPartialResult
(org.apache.hadoop.hbase.client.Scan baseScan) void
testExpectedNumberOfCellsPerPartialResult
(org.apache.hadoop.hbase.client.Scan baseScan, int expectedNumberOfCells) void
Ensure that the expected key values appear in a result returned from a scanner that is combining partial results into complete resultsvoid
testExpectedValuesOfPartialResults
(boolean reversed) void
void
When a scan has a filter whereFilter.hasFilterRow()
is true, the scanner should not return partial results.void
Order of cells in partial results matches the ordering of cells from complete resultsvoid
testOrderingOfCellsInPartialResults
(org.apache.hadoop.hbase.client.Scan basePartialScan) void
Test various combinations of batching and partial results for correctnessvoid
testPartialResultsAndBatch
(int batch, int cellsPerPartialResult) void
Examine the interaction between the maxResultSize and caching.void
testPartialResultsAndCaching
(int resultSizeRowLimit, int cachingRowLimit) void
Test the methodResult.createCompleteResult(Iterable)
void
testPartialResultsReassembly
(org.apache.hadoop.hbase.client.Scan scanBase) void
Test partial Result re-assembly in the presence of different filters.void
testPartialResultsWithColumnFilter
(org.apache.hadoop.hbase.filter.Filter filter) void
void
void
void
(package private) static void
verifyResult
(org.apache.hadoop.hbase.client.Result result, List<org.apache.hadoop.hbase.Cell> expKvList, String msg) Verifies that result contains all the key values within expKvList.
-
Field Details
-
CLASS_RULE
-
LOG
-
TEST_UTIL
-
MINICLUSTER_SIZE
- See Also:
-
TABLE
-
TABLE_NAME
Table configuration -
NUM_ROWS
-
ROW
-
ROWS
-
NUM_FAMILIES
-
FAMILY
-
FAMILIES
-
NUM_QUALIFIERS
-
QUALIFIER
-
QUALIFIERS
-
VALUE_SIZE
-
VALUE
-
NUM_COLS
-
CELL_HEAP_SIZE
-
timeout
-
name
-
-
Constructor Details
-
TestPartialResultsFromClientSide
public TestPartialResultsFromClientSide()
-
-
Method Details
-
setUpBeforeClass
- Throws:
Exception
-
createTestTable
static org.apache.hadoop.hbase.client.Table createTestTable(org.apache.hadoop.hbase.TableName name, byte[][] rows, byte[][] families, byte[][] qualifiers, byte[] cellValue) throws IOException - Throws:
IOException
-
tearDownAfterClass
- Throws:
Exception
-
testExpectedValuesOfPartialResults
Ensure that the expected key values appear in a result returned from a scanner that is combining partial results into complete results- Throws:
Exception
-
testExpectedValuesOfPartialResults
- Throws:
Exception
-
testAllowPartialResults
Ensure that we only see Results marked as partial when the allowPartial flag is set- Throws:
Exception
-
testEquivalenceOfScanResults
Ensure that the results returned from a scanner that retrieves all results in a single RPC call matches the results that are returned from a scanner that must incrementally combine partial results into complete results. A variety of scan configurations can be tested- Throws:
Exception
-
testEquivalenceOfScanResults
public void testEquivalenceOfScanResults(org.apache.hadoop.hbase.client.Table table, org.apache.hadoop.hbase.client.Scan scan1, org.apache.hadoop.hbase.client.Scan scan2) throws Exception - Throws:
Exception
-
testOrderingOfCellsInPartialResults
Order of cells in partial results matches the ordering of cells from complete results- Throws:
Exception
-
testOrderingOfCellsInPartialResults
public void testOrderingOfCellsInPartialResults(org.apache.hadoop.hbase.client.Scan basePartialScan) throws Exception - Throws:
Exception
-
testExpectedNumberOfCellsPerPartialResult
Setting the max result size allows us to control how many cells we expect to see on each call to next on the scanner. Test a variety of different sizes for correctness- Throws:
Exception
-
testExpectedNumberOfCellsPerPartialResult
public void testExpectedNumberOfCellsPerPartialResult(org.apache.hadoop.hbase.client.Scan baseScan) throws Exception - Throws:
Exception
-
testExpectedNumberOfCellsPerPartialResult
public void testExpectedNumberOfCellsPerPartialResult(org.apache.hadoop.hbase.client.Scan baseScan, int expectedNumberOfCells) throws Exception - Throws:
Exception
-
getCellHeapSize
- Returns:
- The approximate heap size of a cell in the test table. All cells should have approximately the same heap size, so the value is cached to avoid repeating the calculation
- Throws:
Exception
-
getResultSizeForNumberOfCells
- Returns:
- the result size that should be used in
Scan.setMaxResultSize(long)
if you want the server to return exactly numberOfCells cells - Throws:
Exception
-
testPartialResultsAndBatch
Test various combinations of batching and partial results for correctness- Throws:
Exception
-
testPartialResultsAndBatch
- Throws:
Exception
-
testPartialResultsReassembly
Test the methodResult.createCompleteResult(Iterable)
- Throws:
Exception
-
testPartialResultsReassembly
public void testPartialResultsReassembly(org.apache.hadoop.hbase.client.Scan scanBase) throws Exception - Throws:
Exception
-
testExceptionThrownOnMismatchedPartialResults
When reconstructing the complete result from its partials we ensure that the row of each partial result is the same. If one of the rows differs, an exception is thrown.- Throws:
IOException
-
testNoPartialResultsWhenRowFilterPresent
When a scan has a filter whereFilter.hasFilterRow()
is true, the scanner should not return partial results. The scanner cannot return partial results because the entire row needs to be read for the include/exclude decision to be made- Throws:
Exception
-
testPartialResultsAndCaching
Examine the interaction between the maxResultSize and caching. If the caching limit is reached before the maxResultSize limit, we should not see partial results. On the other hand, if the maxResultSize limit is reached before the caching limit, it is likely that partial results will be seen.- Throws:
Exception
-
testPartialResultsAndCaching
public void testPartialResultsAndCaching(int resultSizeRowLimit, int cachingRowLimit) throws Exception - Parameters:
resultSizeRowLimit
- The row limit that will be enforced through maxResultSizecachingRowLimit
- The row limit that will be enforced through caching- Throws:
Exception
-
createPuts
static ArrayList<org.apache.hadoop.hbase.client.Put> createPuts(byte[][] rows, byte[][] families, byte[][] qualifiers, byte[] value) throws IOException Make puts to put the input value into each combination of row, family, and qualifier- Parameters:
rows
- the rows to usefamilies
- the families to usequalifiers
- the qualifiers to usevalue
- the values to use- Returns:
- the dot product of the given rows, families, qualifiers, and values
- Throws:
IOException
- if there is a problem creating one of the Put objects
-
createKeyValuesForRow
static ArrayList<org.apache.hadoop.hbase.Cell> createKeyValuesForRow(byte[] row, byte[][] families, byte[][] qualifiers, byte[] value) Make key values to represent each possible combination of family and qualifier in the specified row.- Parameters:
row
- the row to usefamilies
- the families to usequalifiers
- the qualifiers to usevalue
- the values to use- Returns:
- the dot product of the given families, qualifiers, and values for a given row
-
verifyResult
static void verifyResult(org.apache.hadoop.hbase.client.Result result, List<org.apache.hadoop.hbase.Cell> expKvList, String msg) Verifies that result contains all the key values within expKvList. Fails the test otherwise -
compareResults
static void compareResults(org.apache.hadoop.hbase.client.Result r1, org.apache.hadoop.hbase.client.Result r2, String message) Compares two results and fails the test if the results are different -
testReadPointAndPartialResults
- Throws:
Exception
-
countCellsFromScanner
private int countCellsFromScanner(org.apache.hadoop.hbase.client.ResultScanner scanner) throws Exception Exhausts the scanner by calling next repetitively. Once completely exhausted, close scanner and return total cell count- Parameters:
scanner
- the scanner to exhaust- Returns:
- the number of cells counted
- Throws:
Exception
- if there is a problem retrieving cells from the scanner
-
testPartialResultsWithColumnFilter
Test partial Result re-assembly in the presence of different filters. The Results from the partial scanner should match the Results returned from a scanner that receives all of the results in one RPC to the server. The partial scanner is tested with a variety of different result sizes (all of which are less than the size necessary to fetch an entire row)- Throws:
Exception
-
testPartialResultsWithColumnFilter
public void testPartialResultsWithColumnFilter(org.apache.hadoop.hbase.filter.Filter filter) throws Exception - Throws:
Exception
-
moveRegion
- Throws:
IOException
-
assertCell
-
testPartialResultWhenRegionMove
- Throws:
IOException
-
testReversedPartialResultWhenRegionMove
- Throws:
IOException
-
testCompleteResultWhenRegionMove
- Throws:
IOException
-
testReversedCompleteResultWhenRegionMove
- Throws:
IOException
-
testBatchingResultWhenRegionMove
- Throws:
IOException
-
testDontThrowUnknowScannerExceptionToClient
- Throws:
Exception
-
testMayHaveMoreCellsInRowReturnsTrueAndSetBatch
- Throws:
IOException
-