Class BinaryLoggerSinkBuilder

java.lang.Object
com.illumon.iris.db.util.logging.BinaryLoggerSinkBuilder

public class BinaryLoggerSinkBuilder extends Object
Builder to create and initialize a sink suitable for a binary logger.

In all cases, this factory will determine the internal partition (or a prefix thereof, if log-format suffixing is set) through getInternalPartitionForLogs(LoggerInfo, boolean).

If binary log files are being written directly (the LAS is not used), the process name will be prefixed to the internal partition name to help distinguish them.

  • Constructor Details

    • BinaryLoggerSinkBuilder

      public BinaryLoggerSinkBuilder()
      Construct a builder for new IntradayLoggers.
  • Method Details

    • setProcessName

      public BinaryLoggerSinkBuilder setProcessName(@NotNull String processName)
      Set property prefix to be used for log creation and initialization. Required.
      Parameters:
      processName - Property prefix to be used for log creation and initialization
      Returns:
      This builder.
    • setNamespaceSet

      public BinaryLoggerSinkBuilder setNamespaceSet(@NotNull TableIdentifier.NamespaceSet namespaceSet)
      Set the TableIdentifier.NamespaceSet (USER or SYSTEM) for the logger. Defaults to TableIdentifier.NamespaceSet.SYSTEM.
      Parameters:
      namespaceSet - The TableIdentifier.NamespaceSet for the logger
      Returns:
      This builder.
    • setNamespace

      public BinaryLoggerSinkBuilder setNamespace(@Nullable String namespace)
      Set the namespace for the new logger if the logger's default should not be used. Optional.
      Parameters:
      namespace - The namespace for the new logger
      Returns:
      This builder.
    • setTableName

      public BinaryLoggerSinkBuilder setTableName(@Nullable String tableName)
      Set the table name for the new logger, if the logger's default should not be used. Optional.
      Parameters:
      tableName - The table name for the new logger
      Returns:
      This builder.
    • setTimeZoneName

      public BinaryLoggerSinkBuilder setTimeZoneName(@Nullable String timeZoneName)
      Set the name of the time zone to be used to determine column partition values and file name date-time stamps. Optional.

      If none is provided the system default will be used.

      This is ignored for non-dynamic loggers using the log aggregator service.

      Superceded when a column partition function or a column partition value is set and used.

      Parameters:
      timeZoneName - The time zone name
      Returns:
      This builder.
    • setColumnPartitionValue

      public BinaryLoggerSinkBuilder setColumnPartitionValue(@Nullable String columnPartitionValue)
      Set the column partition value to be used. Optional.
      Parameters:
      columnPartitionValue - The column partition value
      Returns:
      This builder.
    • setForceUseLas

      public BinaryLoggerSinkBuilder setForceUseLas(boolean forceUseLas)
      Set whether to always use the log aggregator service (LAS). Defaults to false. Optional.
      Parameters:
      forceUseLas - Whether to force use of the log aggregator service (LAS)
      Returns:
      This builder.
    • setSuffixInternalPartitionWithLogFormat

      public BinaryLoggerSinkBuilder setSuffixInternalPartitionWithLogFormat(boolean suffixInternalPartitionWithLogFormat)
      Set whether to suffix internal partitions with the log format. Defaults to false. Optional.

      Example: If the internal partition would normally have been "ABC" and the logger format is version 4, the actual partition used would be: "ABC-4".

      Parameters:
      suffixInternalPartitionWithLogFormat - Whether to suffix the internal partition with logger format
      Returns:
      This builder.
    • setInternalPartitionSuffix

      public BinaryLoggerSinkBuilder setInternalPartitionSuffix(String internalPartitionSuffix)
      Set a suffix for the internal partition, defaults to no value. Optional.

      The suffix is applied after the computed internal partition, but before the log format (if suffixInternalPartitionWithLogFormat is true).

      Example: If the internal partition would normally have been "ABC", the internal partition suffix is "DEF", and the logger format is version 4, the actual partition used would be: "ABC-DEF-4". If the log format suffix is not set, then the actual partition would be "ABC-DEF".

      Parameters:
      internalPartitionSuffix - the suffix for the computed internal partition
      Returns:
      This builder.
    • setLogDirectory

      public BinaryLoggerSinkBuilder setLogDirectory(String logDirectory)
      Set an output directory for the binary logs.

      If not set, calls ConfigurationUtils.getBinaryLogDir to determine the directory based on Configuration properties.

      Parameters:
      logDirectory - the directory to write to
      Returns:
      this builder
    • makeMultiPartitionSink

      public io.deephaven.enterprise.binlog.support.MultiPartitionBufferWriter makeMultiPartitionSink(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.deephaven.enterprise.binlog.support.LoggerInfo loggerInfo) throws IOException
      Create a multi-partition log sink and initialize it according to the specified parameters on this builder.

      The logger must support dynamic partitions, otherwise call makeSinglePartitionSink(Configuration, Logger, LoggerInfo).

      • If a columnPartitionValue is provided, it will be used for all rows, regardless of any specified dynamic partition properties or provided columnPartitionFunction.
      • If a columnPartition is not provided, then the logger must provide the partition for each row.
      • The rows are written directly to binary log files unless the properties specify to use the log aggregator service (processName.useLogAggregatorService=true or loggerClass.processName.useLogAggregatorService=true) or forceUseLas is true.
      Parameters:
      configuration - Configuration instance for property lookup
      log - a text Logger to be used during IntradayLogger initialization
      loggerInfo - a LoggerInfo that describes the logger to be created.
      Returns:
      An initialized MultiPartitionBufferWriter.
      Throws:
      IOException - when the log sink cannot be initialized
    • makeSinglePartitionSink

      public io.deephaven.enterprise.binlog.support.SinglePartitionBufferWriter makeSinglePartitionSink(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull com.fishlib.io.logger.Logger log, @NotNull io.deephaven.enterprise.binlog.support.LoggerInfo loggerInfo) throws IOException
      Create a single partition log sink and initialize it according to the specified parameters on this builder.

      The logger may support dynamic partitions, otherwise call makeMultiPartitionSink(Configuration, Logger, LoggerInfo).

      • If a columnPartitionValue is provided, it is be used for all rows, regardless of any specified dynamic partition properties or provided columnPartitionFunction.
      • If a columnPartition is not provided, then each row is logged to a partition based on the time that the logger passes the buffer to the sink (this may not align with the data).
      • The rows are written directly to binary log files unless the properties specify to use the log aggregator service (processName.useLogAggregatorService=true or loggerClass.processName.useLogAggregatorService=true) or forceUseLas is true.
      Parameters:
      configuration - Configuration instance for property lookup
      log - a text Logger to be used during IntradayLogger initialization
      loggerInfo - a LoggerInfo that describes the logger to be created.
      Returns:
      An initialized SinglePartitionBufferWriter.
      Throws:
      IOException - when the log sink cannot be initialized
    • getInternalPartitionForLogs

      @NotNull public String getInternalPartitionForLogs(io.deephaven.enterprise.binlog.support.LoggerInfo loggerInfo, boolean includePid)
      Determine an appropriate internal partition that can be used for writing logs.
      Parameters:
      loggerInfo - information about the logger we are generating an internal partition for
      Returns:
      the internal partition as described above.