Package org.apache.hadoop.hbase.client
Class TestClientNoCluster
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hbase.client.TestClientNoCluster
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable,org.apache.hadoop.util.Tool
public class TestClientNoCluster
extends org.apache.hadoop.conf.Configured
implements org.apache.hadoop.util.Tool
Test client behavior w/o setting up a cluster. Mock up cluster emissions. See below for a method
that tests retries/timeouts currently commented out.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classFake 'server'.(package private) static classFake many regionservers and many regions on a connection implementation.private static classComparator for meta row keys.(package private) static classOverride to shutdown going to zookeeper for cluster id and meta location.(package private) static classOverride to check we are setting rpc timeout right.(package private) static classOverride to check we are setting rpc timeout right.(package private) static classSimple cluster registry inserted in place of our usual zookeeper based one. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]private static final org.apache.hbase.thirdparty.com.google.protobuf.ByteStringstatic final HBaseClassTestRuleprivate org.apache.hadoop.conf.Configurationprivate static final org.slf4j.Loggerstatic final org.apache.hadoop.hbase.ServerNameA server that does not exist.private static final org.apache.hbase.thirdparty.com.google.protobuf.ByteStringprivate static final org.apache.hbase.thirdparty.com.google.protobuf.ByteString -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static voidcycle(int id, org.apache.hadoop.conf.Configuration c, org.apache.hadoop.hbase.client.Connection sharedConnection) Code for each 'client' to run.(package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetResponsedoMetaGetResponse(SortedMap<byte[], org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> meta, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest request) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponsedoMetaScanResponse(SortedMap<byte[], org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> meta, AtomicLong sequenceids, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest request) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiResponsedoMultiResponse(SortedMap<byte[], org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> meta, AtomicLong sequenceids, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest request) private static byte[]format(long number) Format passed integer.(package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.Cell.BuildergetBaseCellBuilder(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.CellgetRegionInfo(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row, org.apache.hadoop.hbase.HRegionInfo hri) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.CellgetServer(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row, org.apache.hadoop.hbase.ServerName sn) (package private) static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.CellgetStartCode(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row) (package private) static booleanisMetaRegion(byte[] name, org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType type) static voidRun a client instance against a faked up server.private static org.apache.hadoop.hbase.HRegionInfo[]makeHRegionInfos(byte[] tableName, int count, long namespaceSpan) Returnscountregions(package private) static SortedMap<byte[],org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> makeMeta(byte[] tableName, int regionCount, long namespaceSpan, int serverCount) Create up a map that is keyed by meta row name and whose value is the HRegionInfo and ServerName to return for this row.private static org.apache.hadoop.hbase.ServerName[]makeServerNames(int count) Returns Returncountservernames.intvoidsetUp()voidRemove the @Ignore to try out timeout and retry settingsvoidvoidvoidvoidvoidTest that operation timeout prevails over rpc default timeout and retries, etc.voidRemove the @Ignore to try out timeout and retry settingsMethods inherited from class org.apache.hadoop.conf.Configured
getConf, setConfMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
-
Field Details
-
CLASS_RULE
-
LOG
-
conf
-
META_SERVERNAME
A server that does not exist. I've changed the server in the below to 'localhost' so we have a servername that resolves -- otherwise, we just fail on server name lookup with UnknownHost... With localhost, was able to reproduce stack traces that looked like production stack traces. Was useful figuring out how retry/timeouts are functioning. -
CATALOG_FAMILY_BYTESTRING
private static final org.apache.hbase.thirdparty.com.google.protobuf.ByteString CATALOG_FAMILY_BYTESTRING -
REGIONINFO_QUALIFIER_BYTESTRING
private static final org.apache.hbase.thirdparty.com.google.protobuf.ByteString REGIONINFO_QUALIFIER_BYTESTRING -
SERVER_QUALIFIER_BYTESTRING
private static final org.apache.hbase.thirdparty.com.google.protobuf.ByteString SERVER_QUALIFIER_BYTESTRING -
BIG_USER_TABLE
-
-
Constructor Details
-
TestClientNoCluster
public TestClientNoCluster()
-
-
Method Details
-
setUp
- Throws:
Exception
-
testTimeoutAndRetries
Remove the @Ignore to try out timeout and retry settings- Throws:
IOException
-
testAsyncTimeoutAndRetries
public void testAsyncTimeoutAndRetries() throws IOException, ExecutionException, InterruptedExceptionRemove the @Ignore to try out timeout and retry settings -
testRpcTimeout
Test that operation timeout prevails over rpc default timeout and retries, etc.- Throws:
IOException
-
testDoNotRetryMetaTableAccessor
- Throws:
IOException
-
testDoNotRetryOnScanNext
- Throws:
IOException
-
testRegionServerStoppedOnScannerOpen
- Throws:
IOException
-
testConnectionClosedOnRegionLocate
- Throws:
IOException
-
doMultiResponse
static org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiResponse doMultiResponse(SortedMap<byte[], org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> meta, AtomicLong sequenceids, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest request) -
doMetaScanResponse
static org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse doMetaScanResponse(SortedMap<byte[], org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> meta, AtomicLong sequenceids, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest request) -
doMetaGetResponse
static org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetResponse doMetaGetResponse(SortedMap<byte[], org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, org.apache.hadoop.hbase.ServerName>> meta, org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest request) -
isMetaRegion
static boolean isMetaRegion(byte[] name, org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType type) - Parameters:
name- region name or encoded region name.- Returns:
- True if we are dealing with a hbase:meta region.
-
getBaseCellBuilder
static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.Cell.Builder getBaseCellBuilder(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row) -
getRegionInfo
static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.Cell getRegionInfo(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row, org.apache.hadoop.hbase.HRegionInfo hri) -
getServer
static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.Cell getServer(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row, org.apache.hadoop.hbase.ServerName sn) -
getStartCode
static org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos.Cell getStartCode(org.apache.hbase.thirdparty.com.google.protobuf.ByteString row) -
format
Format passed integer. Zero-pad. Copied from hbase-server PE class and small amendment. Make them share.- Returns:
- Returns zero-prefixed 10-byte wide decimal version of passed number (Does absolute in case number is negative).
-
makeHRegionInfos
private static org.apache.hadoop.hbase.HRegionInfo[] makeHRegionInfos(byte[] tableName, int count, long namespaceSpan) Returnscountregions -
makeServerNames
Returns Returncountservernames. -
makeMeta
static SortedMap<byte[],org.apache.hadoop.hbase.util.Pair<org.apache.hadoop.hbase.HRegionInfo, makeMetaorg.apache.hadoop.hbase.ServerName>> (byte[] tableName, int regionCount, long namespaceSpan, int serverCount) Create up a map that is keyed by meta row name and whose value is the HRegionInfo and ServerName to return for this row.- Returns:
- Map with faked hbase:meta content in it.
-
cycle
static void cycle(int id, org.apache.hadoop.conf.Configuration c, org.apache.hadoop.hbase.client.Connection sharedConnection) throws IOException Code for each 'client' to run.- Throws:
IOException
-
run
- Specified by:
runin interfaceorg.apache.hadoop.util.Tool- Throws:
Exception
-
main
Run a client instance against a faked up server.- Parameters:
args- TODO- Throws:
Exception
-