@InterfaceAudience.Private public class MultiThreadedClientExample extends org.apache.hadoop.conf.Configured implements org.apache.hadoop.util.Tool
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:
Modifier and Type | Class and Description |
---|---|
static class |
MultiThreadedClientExample.ReadExampleCallable
Class to show how to scan some rows starting at a random location.
|
static class |
MultiThreadedClientExample.SingleWriteExampleCallable
Class to show how to send a single put.
|
static class |
MultiThreadedClientExample.WriteExampleCallable
Class that will show how to send batches of puts at the same time.
|
Modifier and Type | Field and Description |
---|---|
private static int |
DEFAULT_NUM_OPERATIONS |
private static byte[] |
FAMILY
The name of the column family.
|
private ExecutorService |
internalPool |
private static org.slf4j.Logger |
LOG |
private static byte[] |
QUAL
For the example we're just using one qualifier.
|
private int |
threads |
Constructor and Description |
---|
MultiThreadedClientExample() |
Modifier and Type | Method and Description |
---|---|
static void |
main(String[] args) |
int |
run(String[] args) |
private void |
warmUpConnectionCache(Connection connection,
TableName tn) |
private static final org.slf4j.Logger LOG
private static final int DEFAULT_NUM_OPERATIONS
private static final byte[] FAMILY
private static final byte[] QUAL
private final ExecutorService internalPool
private final int threads
public MultiThreadedClientExample() throws IOException
IOException
public int run(String[] args) throws Exception
run
in interface org.apache.hadoop.util.Tool
Exception
private void warmUpConnectionCache(Connection connection, TableName tn) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.