Class MetaBrowser
Support class for the "Meta Entries" section in resources/hbase-webapps/master/table.jsp
.
Interface. This class's intended consumer is table.jsp
. As such, it's primary
interface is the active HttpServletRequest
, from which it uses the scan_*
request
parameters. This class supports paging through an optionally filtered view of the contents of
hbase:meta
. Those filters and the pagination offset are specified via these request
parameters. It provides helper methods for constructing pagination links.
- "name" - the name of the table requested. The only table of our concern here is
hbase:meta
; any other value is effectively ignored by the giant conditional in the jsp. - "scan_limit" - specifies a limit on the number of region (replicas) rendered on
the by the table in a single request -- a limit on page size. This corresponds to the number of
RegionReplicaInfo
objects produced byMetaBrowser.Results.iterator()
. When a value forscan_limit
is invalid or not specified, the default value of 10 is used. In order to avoid excessive resource consumption, a maximum value of 10000 is enforced. - "scan_region_state" - an optional filter on
RegionState
. - "scan_start" - specifies the rowkey at which a scan should start. For usage details, see the below section on Pagination.
- "scan_table" - specifies a filter on the values returned, limiting them to
regions from a specified table. This parameter is implemented as a prefix filter on the
Scan
, so in effect it can be used for simple namespace and multi-table matches.
Pagination. A single page of results are made available via getResults()
/ an
instance of MetaBrowser.Results
. Callers use its Iterator
consume the page of
RegionReplicaInfo
instances, each of which represents a region or region replica. Helper
methods are provided for building page navigation controls preserving the user's selected filter
set: buildFirstPageUrl()
, buildNextPageUrl(byte[])
. Pagination is implemented
using a simple offset + limit system. Offset is provided by the "scan_start", limit
via "scan_limit". Under the hood, the Scan
is constructed with
Scan.setMaxResultSize(long)
set to ("scan_limit" +1), while the
MetaBrowser.Results
Iterator
honors "scan_limit". The +1 allows the caller to
know if a "next page" is available via MetaBrowser.Results.hasMoreResults()
. Note that this
pagination strategy is incomplete when it comes to region replicas and can potentially omit
rendering replicas that fall between the last rowkey offset and replicaCount % page size
.
Error Messages. Any time there's an error parsing user input, a message will be populated
in getErrorMessages()
. Any fields which produce an error will have their filter values
set to the default, except for a value of "scan_limit" that exceeds
10000, in which case 10000 is used.
-
Nested Class Summary
Modifier and TypeClassDescriptionfinal class
Encapsulates the results produced by thisMetaBrowser
instance. -
Field Summary
Modifier and TypeFieldDescriptionprivate final AsyncConnection
private final String
static final String
private final javax.servlet.http.HttpServletRequest
static final int
static final int
static final String
static final String
static final String
static final String
private final Integer
private final RegionState.State
private final byte[]
private final TableName
-
Constructor Summary
ConstructorDescriptionMetaBrowser
(AsyncConnection connection, javax.servlet.http.HttpServletRequest request) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addParam
(org.apache.hbase.thirdparty.io.netty.handler.codec.http.QueryStringEncoder encoder, String paramName, Object value) Addsvalue
toencoder
underparamName
whenvalue
is non-null.private org.apache.hbase.thirdparty.io.netty.handler.codec.http.QueryStringEncoder
buildNextPageUrl
(byte[] lastRow) private Scan
private Filter
private static String
buildScanLimitExceededErrorMessage
(int requestValue) private static String
buildScanLimitLTEQZero
(int requestValue) private static String
buildScanLimitMalformedErrorMessage
(String requestValue) private static Filter
private static String
buildScanRegionStateMalformedErrorMessage
(String requestValue) (package private) static String
buildStartParamFrom
(byte[] lastRow) private static Filter
buildTableFilter
(TableName tableName) getName()
byte[]
private static String
resolveName
(javax.servlet.http.HttpServletRequest request) private static String
resolveRequestParameter
(javax.servlet.http.HttpServletRequest request, String param) private Integer
resolveScanLimit
(javax.servlet.http.HttpServletRequest request) private RegionState.State
resolveScanRegionState
(javax.servlet.http.HttpServletRequest request) private static byte[]
resolveScanStart
(javax.servlet.http.HttpServletRequest request) private static TableName
resolveScanTable
(javax.servlet.http.HttpServletRequest request) toString()
private static Integer
tryParseInt
(String val) private static <T extends Enum<T>>
TtryValueOf
(Class<T> clazz, String value) private static String
private static String
-
Field Details
-
NAME_PARAM
- See Also:
-
SCAN_LIMIT_PARAM
- See Also:
-
SCAN_REGION_STATE_PARAM
- See Also:
-
SCAN_START_PARAM
- See Also:
-
SCAN_TABLE_PARAM
- See Also:
-
SCAN_LIMIT_DEFAULT
- See Also:
-
SCAN_LIMIT_MAX
- See Also:
-
connection
-
request
-
errorMessages
-
name
-
scanLimit
-
scanRegionState
-
scanStart
-
scanTable
-
-
Constructor Details
-
MetaBrowser
-
-
Method Details
-
getErrorMessages
-
getName
-
getScanLimit
-
getScanStart
-
getScanRegionState
-
getScanTable
-
getResults
-
toString
-
resolveName
-
resolveScanLimit
-
resolveScanRegionState
-
resolveScanStart
-
resolveScanTable
-
resolveRequestParameter
private static String resolveRequestParameter(javax.servlet.http.HttpServletRequest request, String param) -
buildTableFilter
-
buildScanRegionStateFilter
-
buildScanFilter
-
buildScan
-
addParam
private void addParam(org.apache.hbase.thirdparty.io.netty.handler.codec.http.QueryStringEncoder encoder, String paramName, Object value) Addsvalue
toencoder
underparamName
whenvalue
is non-null. -
buildFirstPageEncoder
private org.apache.hbase.thirdparty.io.netty.handler.codec.http.QueryStringEncoder buildFirstPageEncoder() -
buildFirstPageUrl
-
buildStartParamFrom
-
buildNextPageUrl
-
urlEncode
-
urlDecode
-
tryParseInt
-
tryValueOf
-
buildScanLimitExceededErrorMessage
-
buildScanLimitMalformedErrorMessage
-
buildScanLimitLTEQZero
-
buildScanRegionStateMalformedErrorMessage
-