Class LogAggregatorWriterMultiPartition

java.lang.Object
com.illumon.iris.db.v2.logaggregator.LogAggregatorWriterMultiPartition
All Implemented Interfaces:
io.deephaven.enterprise.binlog.channels.ChannelManager, io.deephaven.enterprise.binlog.channels.ChannelManagerMultiPartition, io.deephaven.enterprise.binlog.support.MultiPartitionBufferWriter

public class LogAggregatorWriterMultiPartition extends Object implements io.deephaven.enterprise.binlog.channels.ChannelManagerMultiPartition, io.deephaven.enterprise.binlog.support.MultiPartitionBufferWriter
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.
  • Field Details

    • primaryRecordWriter

      protected com.illumon.iris.db.v2.logaggregator.LogAggregatorWriterMultiPartition.WithCurrentLogAggregatorRecordWriter primaryRecordWriter
  • Constructor Details

    • LogAggregatorWriterMultiPartition

      public LogAggregatorWriterMultiPartition(@NotNull com.fishlib.io.logger.Logger log, @NotNull InetSocketAddress serverAddress, @NotNull String namespace, @NotNull String tableName, @NotNull TableIdentifier.NamespaceSet namespaceSet, @NotNull String internalPartition, TokenFactoryFactory tokenFactorySource)
      This guy existing is a pretty good hint that the interface hierarchy here is NFG.
      Parameters:
      log - the Logger instance
      serverAddress - the LAS server's address
      namespace - the namespace
      tableName - the table name
      namespaceSet - the namespace set
      internalPartition - the internal partition
      tokenFactorySource - a token source for authentication
      Throws:
      IOException - from initialization
  • Method Details

    • setHeader

      public void setHeader(ByteBuffer headerBuffer)
      Specified by:
      setHeader in interface io.deephaven.enterprise.binlog.support.MultiPartitionBufferWriter
    • getChannel

      @NotNull 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 io.deephaven.enterprise.binlog.channels.ChannelManagerMultiPartition
      Parameters:
      columnPartitionValue - the column partition value
      Returns:
      non-null, open channel to the Log Aggregator Service, else an exception
      Throws:
      IOException
    • 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 io.deephaven.enterprise.binlog.channels.ChannelManager
      Specified by:
      close in interface io.deephaven.enterprise.binlog.support.MultiPartitionBufferWriter
      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 io.deephaven.enterprise.binlog.channels.ChannelManager
      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:
      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.
    • writeDataToPartition

      public void writeDataToPartition(String columnPartition, ByteBuffer bufferToWrite) throws IOException
      Specified by:
      writeDataToPartition in interface io.deephaven.enterprise.binlog.support.MultiPartitionBufferWriter
      Throws:
      IOException