Package org.apache.storm.hive.common
Class HiveWriter
- java.lang.Object
-
- org.apache.storm.hive.common.HiveWriter
-
public class HiveWriter extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classHiveWriter.CommitFailurestatic classHiveWriter.ConnectFailurestatic classHiveWriter.Failurestatic classHiveWriter.TxnBatchFailurestatic classHiveWriter.TxnFailurestatic classHiveWriter.WriteFailure
-
Field Summary
Fields Modifier and Type Field Description protected booleanclosed
-
Constructor Summary
Constructors Constructor Description HiveWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint, int txnsPerBatch, boolean autoCreatePartitions, long callTimeout, ExecutorService callTimeoutPool, HiveMapper mapper, org.apache.hadoop.security.UserGroupInformation ugi, boolean tokenAuthEnabled)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidabort()Aborts the current Txn and switches to next Txn.voidclose()Close the Transaction Batch and connection.voidflush(boolean rollToNext)Commits the current Txn if totalRecordsPerTransaction > 0 .voidflushAndClose()Flush and Close current transactionBatch.longgetLastUsed()org.apache.hive.hcatalog.streaming.RecordWritergetRecordWriter(HiveMapper mapper, boolean tokenAuthEnabled)intgetTotalRecords()returns totalRecords written so far in a transaction.voidheartBeat()Queues up a heartbeat request on the current and remaining txns using the heartbeatThdPool and returns immediately.StringtoString()voidwrite(byte[] record)Write data.
-
-
-
Constructor Detail
-
HiveWriter
public HiveWriter(org.apache.hive.hcatalog.streaming.HiveEndPoint endPoint, int txnsPerBatch, boolean autoCreatePartitions, long callTimeout, ExecutorService callTimeoutPool, HiveMapper mapper, org.apache.hadoop.security.UserGroupInformation ugi, boolean tokenAuthEnabled) throws InterruptedException, HiveWriter.ConnectFailure
-
-
Method Detail
-
getRecordWriter
public org.apache.hive.hcatalog.streaming.RecordWriter getRecordWriter(HiveMapper mapper, boolean tokenAuthEnabled) throws Exception
- Throws:
Exception
-
write
public void write(byte[] record) throws HiveWriter.WriteFailure, org.apache.hive.hcatalog.streaming.SerializationError, InterruptedExceptionWrite data.- Throws:
HiveWriter.WriteFailureorg.apache.hive.hcatalog.streaming.SerializationErrorInterruptedException
-
flush
public void flush(boolean rollToNext) throws HiveWriter.CommitFailure, HiveWriter.TxnBatchFailure, HiveWriter.TxnFailure, InterruptedExceptionCommits the current Txn if totalRecordsPerTransaction > 0 . If 'rollToNext' is true, will switch to next Txn in batch or to a new TxnBatch if current Txn batch is exhausted
-
heartBeat
public void heartBeat() throws InterruptedExceptionQueues up a heartbeat request on the current and remaining txns using the heartbeatThdPool and returns immediately.- Throws:
InterruptedException
-
getTotalRecords
public int getTotalRecords()
returns totalRecords written so far in a transaction.
-
flushAndClose
public void flushAndClose() throws HiveWriter.TxnBatchFailure, HiveWriter.TxnFailure, HiveWriter.CommitFailure, IOException, InterruptedExceptionFlush and Close current transactionBatch.
-
close
public void close() throws IOException, InterruptedExceptionClose the Transaction Batch and connection.- Throws:
IOExceptionInterruptedException
-
abort
public void abort() throws org.apache.hive.hcatalog.streaming.StreamingException, HiveWriter.TxnBatchFailure, InterruptedExceptionAborts the current Txn and switches to next Txn.- Throws:
org.apache.hive.hcatalog.streaming.StreamingException- if could not get new Transaction Batch, or switch to next TxnHiveWriter.TxnBatchFailureInterruptedException
-
getLastUsed
public long getLastUsed()
-
-