Class MultiThreadedClientExample
java.lang.Object
org.apache.hadoop.conf.Configured
org.apache.hadoop.hbase.client.example.MultiThreadedClientExample
- All Implemented Interfaces:
org.apache.hadoop.conf.Configurable
,org.apache.hadoop.util.Tool
@Private
public class MultiThreadedClientExample
extends org.apache.hadoop.conf.Configured
implements org.apache.hadoop.util.Tool
Example on how to use HBase's
Connection
and Table
in a multi-threaded
environment. Each table is a light weight object that is created and thrown away. Connections are
heavy weight objects that hold on to zookeeper connections, async processes, and other state.
Usage: bin/hbase org.apache.hadoop.hbase.client.example.MultiThreadedClientExample testTableName 500000
The table should already be created before running the command. This example expects one column family named d.
This is meant to show different operations that are likely to be done in a real world application. These operations are:
- 30% of all operations performed are batch writes. 30 puts are created and sent out at a time. The response for all puts is waited on.
- 20% of all operations are single writes. A single put is sent out and the response is waited for.
- 50% of all operations are scans. These scans start at a random place and scan up to 100 rows.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class to show how to scan some rows starting at a random location.static class
Class to show how to send a single put.static class
Class that will show how to send batches of puts at the same time. -
Field Summary
Modifier and TypeFieldDescriptionprivate static final int
private static final byte[]
The name of the column family.private final ExecutorService
private static final org.slf4j.Logger
private static final byte[]
For the example we're just using one qualifier.private final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
int
private void
warmUpConnectionCache
(Connection connection, TableName tn) Methods inherited from class org.apache.hadoop.conf.Configured
getConf, setConf
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.hadoop.conf.Configurable
getConf, setConf
-
Field Details
-
LOG
-
DEFAULT_NUM_OPERATIONS
- See Also:
-
FAMILY
The name of the column family. d for default. -
QUAL
For the example we're just using one qualifier. -
internalPool
-
threads
-
-
Constructor Details
-
MultiThreadedClientExample
- Throws:
IOException
-
-
Method Details
-
run
- Specified by:
run
in interfaceorg.apache.hadoop.util.Tool
- Throws:
Exception
-
warmUpConnectionCache
- Throws:
IOException
-
main
- Throws:
Exception
-