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 and Description
    --- | ---
    `static class` | `HiveWriter.CommitFailure`
    `static class` | `HiveWriter.ConnectFailure`
    `static class` | `HiveWriter.Failure`
    `static class` | `HiveWriter.TxnBatchFailure`
    `static class` | `HiveWriter.TxnFailure`
    `static class` | `HiveWriter.WriteFailure`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `closed`

  - ### Constructor Summary

    Constructors
    Constructor and 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 and Description
    --- | ---
    `void` | `abort()` Aborts the current Txn and switches to next Txn.
    `void` | `close()` Close the Transaction Batch and connection.
    `void` | `flush(boolean rollToNext)` Commits the current Txn if totalRecordsPerTransaction > 0 .
    `void` | `flushAndClose()` Flush and Close current transactionBatch.
    `long` | `getLastUsed()`
    `org.apache.hive.hcatalog.streaming.RecordWriter` | `getRecordWriter(HiveMapper mapper, boolean tokenAuthEnabled)`
    `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.
    `String` | `toString()`
    `void` | `write(byte[] record)` Write data.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### closed

          protected boolean closed

  - ### 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

      Throws:
        `InterruptedException`
        `HiveWriter.ConnectFailure`

  - ### Method Detail

    - #### getRecordWriter

          public org.apache.hive.hcatalog.streaming.RecordWriter getRecordWriter(HiveMapper mapper,
                                                                                 boolean tokenAuthEnabled)
                                                                          throws Exception

      Throws:
        `Exception`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### write

          public void write(byte[] record)
                     throws HiveWriter.WriteFailure,
                            org.apache.hive.hcatalog.streaming.SerializationError,
                            InterruptedException

      Write data.

      Throws:
        `HiveWriter.WriteFailure`
        `org.apache.hive.hcatalog.streaming.SerializationError`
        `InterruptedException`

    - #### flush

          public void flush(boolean rollToNext)
                     throws HiveWriter.CommitFailure,
                            HiveWriter.TxnBatchFailure,
                            HiveWriter.TxnFailure,
                            InterruptedException

      Commits 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

      Throws:
        `HiveWriter.CommitFailure`
        `HiveWriter.TxnBatchFailure`
        `HiveWriter.TxnFailure`
        `InterruptedException`

    - #### heartBeat

          public void heartBeat()
                         throws InterruptedException

      Queues 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,
                                    InterruptedException

      Flush and Close current transactionBatch.

      Throws:
        `HiveWriter.TxnBatchFailure`
        `HiveWriter.TxnFailure`
        `HiveWriter.CommitFailure`
        `IOException`
        `InterruptedException`

    - #### close

          public void close()
                     throws IOException,
                            InterruptedException

      Close the Transaction Batch and connection.

      Throws:
        `IOException`
        `InterruptedException`

    - #### abort

          public void abort()
                     throws org.apache.hive.hcatalog.streaming.StreamingException,
                            HiveWriter.TxnBatchFailure,
                            InterruptedException

      Aborts 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 Txn
        `HiveWriter.TxnBatchFailure`
        `InterruptedException`

    - #### getLastUsed

          public long getLastUsed()

Copyright © 2021 The Apache Software Foundation. All rights reserved.