Class BinaryStoreAggregatorWriterStandard

All Implemented Interfaces:
ChannelManager, ChannelManagerStandard, Entry, Record, Row, TableWriter<BinaryRowV2>

public class BinaryStoreAggregatorWriterStandard extends BinaryStoreWriterV2 implements ChannelManagerStandard
Write binary rows to a log aggregation service. This implementation is for column partition values that are not determined by row-level data. They may still change, for example based on the current date.
After construction, this will contain an authenticated and accepted connection to the LAS for the given identifiers. If the channel connection is broken, attempts will be made to reconnect. Once either the client or server requests/indicates termination, or the client initiates a terminating command, the connection will be permanently closed.
This object is expected to be used by a single thread. Synchronization is to ensure that multiple commands don't occur at the same time, and to ensure that we don't close and check connections at the same time.
  • Method Details

    • createBinaryRow

      protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterStandard.LogAggregatorRowWriter createBinaryRow(String[] columnNames, SupportedType[] columnTypes, Object[] typeMetadata)
      Make sure all the row writers for this class prepend a LAS message header.
      Overrides:
      createBinaryRow in class BinaryStoreWriterV2
    • createBinaryRecord

      protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterStandard.LogAggregatorRecordWriter createBinaryRecord()
      Make sure all the record writers for this class prepend a LAS message header.
      Overrides:
      createBinaryRecord in class BinaryStoreWriterV2
      Returns:
      a new BinaryRecordV2 record writer
    • getRecordWriter

      public com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterStandard.LogAggregatorRecordWriter getRecordWriter()
      Description copied from interface: TableWriter
      Get new writer for Record entries. This is likely to be newly created, so callers should cache this value. In practice, implementers generally cache the result of the first call to this method as a primary writer.
      Specified by:
      getRecordWriter in interface TableWriter<BinaryRowV2>
      Overrides:
      getRecordWriter in class BinaryStoreWriterV2
      Returns:
      a Record, likely newly created
    • init

      public void init() throws IOException
      Overrides:
      init in class BinaryStoreWriterV2
      Throws:
      IOException
    • getChannel

      @NotNull public GatheringByteChannel getChannel() throws IOException
      Open a channel to the Log Aggregator Service and initialize it with table identifiers and binary header. This getChannel implementation only works for standard-column-partition-determination instances.
      Specified by:
      getChannel in interface ChannelManagerStandard
      Returns:
      non-null, open channel to the server, else an exception
      Throws:
      IOException - if the call encounters an error
    • close

      public void close() throws IOException
      Send CLIENT_FINISHED message, poll for an ACK and close the channel.
      Specified by:
      close in interface ChannelManager
      Specified by:
      close in interface TableWriter<BinaryRowV2>
      Overrides:
      close in class AbstractBinaryStoreWriter<BinaryRowV2>
      Throws:
      IOException - problem closing the writer.
    • flush

      public void flush() throws IOException
      Description copied from interface: TableWriter
      Flushes data out.
      Specified by:
      flush in interface ChannelManager
      Specified by:
      flush in interface TableWriter<BinaryRowV2>
      Overrides:
      flush in class AbstractBinaryStoreWriter<BinaryRowV2>
      Throws:
      IOException - problem flushing data out.
    • sendDeletePartition

      public void sendDeletePartition() throws IOException
      Send a command message to the Log Aggregator, requesting that the current partition be deleted. The connection will be closed by the server, no further data or commands are allowed.
      Throws:
      IOException
    • makeColumnPartitionFactory

      protected ExpirationManager<String> makeColumnPartitionFactory(String columnPartition, ZoneId zoneid)
      Injection point for testing.
      Parameters:
      columnPartition - the column partition passed into the caller, or null if the partition should be determined by the date
      zoneid - the ZoneId needed to create a DailyExpiration
      Returns:
      an ExpirationManager appropriate to the member variables
    • flushDeferredRows

      public void flushDeferredRows(BinaryStoreWriterV2.DeferrableRowPartition part) throws IOException
      Description copied from class: BinaryStoreWriterV2
      Flush all of the deferred rows in the input collection to the underlying stream.
      Overrides:
      flushDeferredRows in class BinaryStoreWriterV2
      Parameters:
      part - The collection of deferred rows for the partitionVlaue
      Throws:
      IOException - if an error occurs during writing. Rows may be partially written, however there are no guarantees that the rows were written completely.