Class BinaryStoreAggregatorWriterMultiPartition

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

public class BinaryStoreAggregatorWriterMultiPartition
extends BinaryStoreWriterV2
implements ChannelManagerMultiPartition
Write binary rows to a log aggregation service. This implementation is for column partition values that are determined dynamically (row-based).
After construction, this will contain zero or more authenticated and accepted connections 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 appropriate connection(s) 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 connections while they are being checked.
  • Method Details

    • createBinaryRow

      protected com.illumon.iris.db.v2.logaggregator.BinaryStoreAggregatorWriterMultiPartition.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.BinaryStoreAggregatorWriterMultiPartition.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.BinaryStoreAggregatorWriterMultiPartition.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

      public GatheringByteChannel getChannel​(@NotNull String columnPartitionValue) throws IOException
      Get a channel to the Log Aggregator Service based on the supplied column partition value. If necessary, create a new one and initialize it with table identifiers and binary header.
      Specified by:
      getChannel in interface ChannelManagerMultiPartition
      Parameters:
      columnPartitionValue - the column partition value
      Returns:
      non-null, open channel to the Log Aggregator Service, else an exception
      Throws:
      IOException - if the call encounters an error
    • close

      public void close() throws IOException
      Attempt to close all open channels. For each channel, send a CLIENT_FINISHED message, poll for an ACK, and close the channel. If an IOException occurs on one or more channels, the first one will be rethrown, but the operation will still be attempted on all remaining channels. If an exception occurs that is not an IOException, that exception will be thrown and operations on remaining channels will not be attempted.
      Specified by:
      close in interface ChannelManager
      Specified by:
      close in interface TableWriter<BinaryRowV2>
      Overrides:
      close in class AbstractBinaryStoreWriter<BinaryRowV2>
      Throws:
      IOException - from the close calls
    • close

      public void close​(String columnPartitionValue) throws IOException
      Close the specified column partition value's channel. If there is no partition for the specified column partition value, then nothing is done. Send CLIENT_FINISHED message, poll for an ACK and close the channel for the specified column partition value.
      Parameters:
      columnPartitionValue - the column partition value
      Throws:
      IOException - from the channel close
    • flush

      public void flush() throws IOException
      Attempt to flush all channels. If an IOException occurs on one or more channels, the first one will be rethrown, but the operation will still be attempted on all remaining channels. If an exception occurs that is not an IOException, that exception will be thrown and operations on remaining channels will not be attempted.
      Specified by:
      flush in interface ChannelManager
      Specified by:
      flush in interface TableWriter<BinaryRowV2>
      Overrides:
      flush in class AbstractBinaryStoreWriter<BinaryRowV2>
      Throws:
      IOException - from the flush calls
    • flush

      public void flush​(String columnPartitionValue) throws IOException
      Flush the specified column partition value's channel.
      Parameters:
      columnPartitionValue - the column partition value
      Throws:
      IOException - from the channel flush
      IllegalArgumentException - if there is no channel for the specified column partition value
    • sendDeletePartition

      public void sendDeletePartition​(String columnPartitionValue) throws IOException
      Send a command message to the Log Aggregator Service for the specified column partition value, requesting that the specified partition be deleted. The connection will be closed by the server, no further data or commands are allowed.
      Parameters:
      columnPartitionValue - the column partition value
      Throws:
      IllegalArgumentException - if there is no channel for the specified column partition value
      IOException
    • isConnected

      public boolean isConnected​(String columnPartitionValue)
      Provide a way for clients to check the status of the specified column partition's writer. The server can unilaterally close the socket, as when it encounters an error. If there isn't a current open channel for the specified column partition value, this will throw an exception.
      Parameters:
      columnPartitionValue - the column partition value
      Returns:
      true if the socket is open and connected.
    • 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.