public class HiveWriter extends Object
| Modifier and Type | Class and Description |
|---|---|
private static interface |
HiveWriter.CallRunner<T>
Simple interface whose call method is called by
{#callWithTimeout} in a new thread inside a
PrivilegedExceptionAction.run() call.
|
static class |
HiveWriter.CommitFailure |
static class |
HiveWriter.ConnectFailure |
static class |
HiveWriter.Failure |
static class |
HiveWriter.TxnBatchFailure |
static class |
HiveWriter.TxnFailure |
static class |
HiveWriter.WriteFailure |
| Modifier and Type | Field and Description |
|---|---|
private long |
callTimeout |
private ExecutorService |
callTimeoutPool |
protected boolean |
closed |
private org.apache.hive.hcatalog.streaming.StreamingConnection |
connection |
private org.apache.hive.hcatalog.streaming.HiveEndPoint |
endPoint |
private long |
lastUsed |
private static org.slf4j.Logger |
LOG |
private org.apache.hive.hcatalog.streaming.RecordWriter |
recordWriter |
private int |
totalRecords |
private org.apache.hive.hcatalog.streaming.TransactionBatch |
txnBatch |
private Object |
txnBatchLock |
private int |
txnsPerBatch |
private org.apache.hadoop.security.UserGroupInformation |
ugi |
| Constructor and Description |
|---|
HiveWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
int txnsPerBatch,
boolean autoCreatePartitions,
long callTimeout,
ExecutorService callTimeoutPool,
org.apache.hadoop.security.UserGroupInformation ugi,
org.apache.hadoop.hive.conf.HiveConf hiveConf) |
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Aborts the current Txn and switches to next Txn.
|
protected void |
abortTxn()
Aborts current Txn in the txnBatch.
|
private <T> T |
callWithTimeout(HiveWriter.CallRunner<T> callRunner)
Execute the callable on a separate thread and wait for the completion
for the specified amount of time in milliseconds.
|
protected static void |
checkAndThrowInterruptedException()
If the current thread has been interrupted, then throws an
exception.
|
void |
close()
Close the Transaction Batch and connection
|
protected void |
closeConnection() |
protected void |
closeTxnBatch() |
protected void |
commitTxn() |
void |
flush(boolean rollToNext)
Commits the current Txn if totalRecordsPerTransaction > 0 .
|
void |
flushAndClose()
Flush and Close current transactionBatch.
|
private byte[] |
generateRecord(List<String> tuple) |
long |
getLastUsed() |
protected org.apache.hive.hcatalog.streaming.RecordWriter |
getRecordWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
org.apache.hadoop.security.UserGroupInformation ugi,
org.apache.hadoop.hive.conf.HiveConf hiveConf) |
int |
getTotalRecords()
Returns totalRecords written so far in a transaction
|
void |
heartBeat()
Queues up a heartbeat request on the current and remaining txns using the
heartbeatThdPool and returns immediately
|
protected org.apache.hive.hcatalog.streaming.StreamingConnection |
newConnection(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
boolean autoCreatePartitions,
org.apache.hadoop.hive.conf.HiveConf conf,
org.apache.hadoop.security.UserGroupInformation ugi) |
protected void |
nextTxn(boolean rollToNext)
if there are remainingTransactions in current txnBatch, begins nextTransactions
otherwise creates new txnBatch.
|
protected org.apache.hive.hcatalog.streaming.TransactionBatch |
nextTxnBatch(org.apache.hive.hcatalog.streaming.RecordWriter recordWriter) |
String |
toString() |
void |
write(byte[] record)
Write the record data to Hive
|
private static final org.slf4j.Logger LOG
private final org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint
private final org.apache.hive.hcatalog.streaming.StreamingConnection connection
private final int txnsPerBatch
private final org.apache.hive.hcatalog.streaming.RecordWriter recordWriter
private final ExecutorService callTimeoutPool
private final long callTimeout
private final Object txnBatchLock
private final org.apache.hadoop.security.UserGroupInformation ugi
private org.apache.hive.hcatalog.streaming.TransactionBatch txnBatch
private long lastUsed
protected boolean closed
private int totalRecords
public HiveWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
int txnsPerBatch,
boolean autoCreatePartitions,
long callTimeout,
ExecutorService callTimeoutPool,
org.apache.hadoop.security.UserGroupInformation ugi,
org.apache.hadoop.hive.conf.HiveConf hiveConf)
throws InterruptedException,
HiveWriter.ConnectFailure
protected org.apache.hive.hcatalog.streaming.RecordWriter getRecordWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
org.apache.hadoop.security.UserGroupInformation ugi,
org.apache.hadoop.hive.conf.HiveConf hiveConf)
throws org.apache.hive.hcatalog.streaming.StreamingException,
IOException,
InterruptedException
org.apache.hive.hcatalog.streaming.StreamingExceptionIOExceptionInterruptedExceptionpublic void write(byte[] record)
throws HiveWriter.WriteFailure,
org.apache.hive.hcatalog.streaming.SerializationError,
InterruptedException
IOException - if an error occurs during the writeInterruptedException - if the write operation is interruptedHiveWriter.WriteFailureorg.apache.hive.hcatalog.streaming.SerializationErrorpublic void flush(boolean rollToNext)
throws HiveWriter.CommitFailure,
HiveWriter.TxnBatchFailure,
HiveWriter.TxnFailure,
InterruptedException
public void heartBeat()
throws InterruptedException
InterruptedExceptionpublic int getTotalRecords()
public void flushAndClose()
throws HiveWriter.TxnBatchFailure,
HiveWriter.TxnFailure,
HiveWriter.CommitFailure,
IOException,
InterruptedException
public void close()
throws IOException,
InterruptedException
IOException - if an error occurs during closeInterruptedException - if the close operation is interruptedprotected void closeConnection()
throws InterruptedException
InterruptedExceptionprotected void commitTxn()
throws HiveWriter.CommitFailure,
InterruptedException
protected org.apache.hive.hcatalog.streaming.StreamingConnection newConnection(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint,
boolean autoCreatePartitions,
org.apache.hadoop.hive.conf.HiveConf conf,
org.apache.hadoop.security.UserGroupInformation ugi)
throws InterruptedException,
HiveWriter.ConnectFailure
protected org.apache.hive.hcatalog.streaming.TransactionBatch nextTxnBatch(org.apache.hive.hcatalog.streaming.RecordWriter recordWriter)
throws InterruptedException,
HiveWriter.TxnBatchFailure
protected void closeTxnBatch()
throws InterruptedException
InterruptedExceptionpublic void abort()
throws org.apache.hive.hcatalog.streaming.StreamingException,
HiveWriter.TxnBatchFailure,
InterruptedException
org.apache.hive.hcatalog.streaming.StreamingException - if could not get new Transaction Batch, or switch to next TxnHiveWriter.TxnBatchFailureInterruptedExceptionprotected void abortTxn()
throws InterruptedException
InterruptedExceptionprotected void nextTxn(boolean rollToNext)
throws org.apache.hive.hcatalog.streaming.StreamingException,
InterruptedException,
HiveWriter.TxnBatchFailure
rollToNext - Whether to roll to the next transaction batchorg.apache.hive.hcatalog.streaming.StreamingExceptionInterruptedExceptionHiveWriter.TxnBatchFailureprotected static void checkAndThrowInterruptedException()
throws InterruptedException
InterruptedException - uf the current thread has been interruptedprivate <T> T callWithTimeout(HiveWriter.CallRunner<T> callRunner) throws TimeoutException, org.apache.hive.hcatalog.streaming.StreamingException, InterruptedException
TimeoutExceptionorg.apache.hive.hcatalog.streaming.StreamingExceptionInterruptedExceptionpublic long getLastUsed()
Copyright © 2023 Apache NiFi Project. All rights reserved.