public class UnManagedSingleTransaction extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
currentTxnIndex |
protected AtomicBoolean |
isTxnClosed
once any operation on this batch encounters a system exception
(e.g.
|
protected RecordWriter |
recordWriter
This variable should be initialized by the children.
|
protected HiveStreamingConnection.TxnState |
state |
protected List<TxnToWriteId> |
txnToWriteIds
This variable should be initialized by the children.
|
Constructor and Description |
---|
UnManagedSingleTransaction(HiveStreamingConnection conn) |
Modifier and Type | Method and Description |
---|---|
void |
abort()
Abort a transaction.
|
void |
beginNextTransaction()
get ready for the next transaction.
|
protected void |
beginNextTransactionImpl(String errorMessage) |
protected void |
checkIsClosed() |
void |
close()
Free/close resources used by the streaming transaction.
|
void |
commit()
commit transaction.
|
void |
commit(Set<String> partitions)
Commit transaction and sent to the metastore the created partitions
in the process.
|
void |
commit(Set<String> partitions,
String key,
String value)
Commits atomically together with a key and a value.
|
HiveStreamingConnection.TxnState |
getCurrentTransactionState() |
long |
getCurrentTxnId() |
long |
getCurrentWriteId() |
Set<String> |
getPartitions()
Get the partitions that were used in this transaction.
|
List<TxnToWriteId> |
getTxnToWriteIds() |
boolean |
isClosed() |
protected void |
markDead(boolean success)
A transaction batch opens a single HDFS file and writes multiple transaction to it.
|
int |
remainingTransactions() |
String |
toString() |
void |
write(byte[] record)
Write data withing a transaction.
|
void |
write(InputStream inputStream)
Write data within a transaction.
|
protected RecordWriter recordWriter
protected List<TxnToWriteId> txnToWriteIds
protected final AtomicBoolean isTxnClosed
protected int currentTxnIndex
protected HiveStreamingConnection.TxnState state
public UnManagedSingleTransaction(HiveStreamingConnection conn) throws StreamingException
StreamingException
public void beginNextTransaction() throws StreamingException
StreamingTransaction
StreamingException
public void commit(Set<String> partitions, String key, String value) throws StreamingException
StreamingTransaction
partitions
- to commit.key
- to commit.value
- to commit.StreamingException
public void abort()
StreamingTransaction
public void close() throws StreamingException
StreamingTransaction
StreamingException
public Set<String> getPartitions()
StreamingTransaction
protected void checkIsClosed() throws StreamingException
StreamingException
protected void beginNextTransactionImpl(String errorMessage) throws StreamingException
StreamingException
public void write(byte[] record) throws StreamingException
StreamingTransaction
write
in interface StreamingTransaction
record
- bytes to write.StreamingException
public void write(InputStream inputStream) throws StreamingException
StreamingTransaction
write
in interface StreamingTransaction
inputStream
- stream to write.StreamingException
protected void markDead(boolean success) throws StreamingException
StreamingException
public long getCurrentWriteId()
getCurrentWriteId
in interface StreamingTransaction
public int remainingTransactions()
remainingTransactions
in interface StreamingTransaction
public boolean isClosed()
isClosed
in interface StreamingTransaction
public HiveStreamingConnection.TxnState getCurrentTransactionState()
getCurrentTransactionState
in interface StreamingTransaction
public long getCurrentTxnId()
getCurrentTxnId
in interface StreamingTransaction
public List<TxnToWriteId> getTxnToWriteIds()
getTxnToWriteIds
in interface StreamingTransaction
public void commit() throws StreamingException
StreamingTransaction
commit
in interface StreamingTransaction
StreamingException
public void commit(Set<String> partitions) throws StreamingException
StreamingTransaction
commit
in interface StreamingTransaction
partitions
- to commit.StreamingException
Copyright © 2022 The Apache Software Foundation. All rights reserved.