@InterfaceAudience.Private public class MultiHConnection extends Object
Modifier and Type | Field and Description |
---|---|
private ExecutorService |
batchPool |
private Connection[] |
connections |
private Object |
connectionsLock |
private static org.slf4j.Logger |
LOG |
private int |
noOfConnections |
Constructor and Description |
---|
MultiHConnection(org.apache.hadoop.conf.Configuration conf,
int noOfConnections)
Create multiple Connection instances and initialize a thread pool executor
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the open connections and shutdown the batchpool
|
private void |
createBatchPool(org.apache.hadoop.conf.Configuration conf) |
<R> void |
processBatchCallback(List<? extends Row> actions,
TableName tableName,
Object[] results,
Batch.Callback<R> callback)
Randomly pick a connection and process the batch of actions for a given table
|
private static final org.slf4j.Logger LOG
private Connection[] connections
private final Object connectionsLock
private final int noOfConnections
private ExecutorService batchPool
public MultiHConnection(org.apache.hadoop.conf.Configuration conf, int noOfConnections) throws IOException
conf
- configurationnoOfConnections
- total no of Connections to createIOException
- if IO failure occurspublic void close()
public <R> void processBatchCallback(List<? extends Row> actions, TableName tableName, Object[] results, Batch.Callback<R> callback) throws IOException
actions
- the actionstableName
- table nameresults
- the results arraycallback
- to run when results are inIOException
- If IO failure occursprivate void createBatchPool(org.apache.hadoop.conf.Configuration conf)
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.