Class BinaryLoggerSinkBuilder
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull StringgetInternalPartitionForLogs(LoggerInfo<?> loggerInfo, boolean includePid) Determine an appropriate internal partition that can be used for writing logs.makeMultiPartitionSink(@NotNull LoggerInfo<?> loggerInfo, @NotNull ByteBuffer header, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull com.fishlib.io.logger.Logger log) Create a multi-partition log sink and initialize it according to the specified parameters on this builder.makeSinglePartitionSink(@NotNull LoggerInfo<?> loggerInfo, @NotNull ByteBuffer header, @NotNull com.fishlib.configuration.Configuration configuration, @NotNull com.fishlib.io.logger.Logger log) Create a single partition log sink and initialize it according to the specified parameters on this builder.setColumnPartitionValue(@Nullable String columnPartitionValue) Set the column partition value to be used.setForceUseLas(boolean forceUseLas) Set whether to always use the log aggregator service (LAS).setInternalPartitionSuffix(String internalPartitionSuffix) Set a suffix for the internal partition, defaults to no value.setLogDirectory(String logDirectory) Set an output directory for the binary logs.setNamespace(@Nullable String namespace) Set the namespace for the new logger if the logger's default should not be used.setNamespaceSet(TableIdentifier.NamespaceSet namespaceSet) Set theTableIdentifier.NamespaceSet(USER or SYSTEM) for the new logger if the logger's default should not be used.setProcessName(@NotNull String processName) Set property prefix to be used for log creation and initialization.setSuffixInternalPartitionWithLogFormat(boolean suffixInternalPartitionWithLogFormat) Set whether to suffix internal partitions with the log format.setTableName(@Nullable String tableName) Set the table name for the new logger, if the logger's default should not be used.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.
-
Constructor Details
-
BinaryLoggerSinkBuilder
public BinaryLoggerSinkBuilder()Construct a builder for newIntradayLoggers.
-
-
Method Details
-
setProcessName
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
Set theTableIdentifier.NamespaceSet(USER or SYSTEM) for the new logger if the logger's default should not be used. Optional.- Parameters:
namespaceSet- TheTableIdentifier.NamespaceSetfor the logger- Returns:
- This builder.
-
setNamespace
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
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
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.
Superseded 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 @Nullable String columnPartitionValue) Set the column partition value to be used. Optional.- Parameters:
columnPartitionValue- The column partition value- Returns:
- This builder.
-
setForceUseLas
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
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
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 MultiPartitionWriter makeMultiPartitionSink(@NotNull @NotNull LoggerInfo<?> loggerInfo, @NotNull @NotNull ByteBuffer header, @NotNull @NotNull com.fishlib.configuration.Configuration configuration, @NotNull @NotNull com.fishlib.io.logger.Logger log) 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(LoggerInfo, ByteBuffer, Configuration, Logger).- If a columnPartitionValue was provided with
setColumnPartitionValue(java.lang.String), anUnsupportedOperationExceptionis thrown. - 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:
loggerInfo- aLoggerInfothat describes the logger to be created.header- the binary log header bytesconfiguration-Configurationinstance for property lookuplog- a textLoggerto be used duringIntradayLoggerinitialization- Returns:
- An initialized
MultiPartitionWriter. - Throws:
IOException- when the log sink cannot be initialized
- If a columnPartitionValue was provided with
-
makeSinglePartitionSink
public SinglePartitionWriter makeSinglePartitionSink(@NotNull @NotNull LoggerInfo<?> loggerInfo, @NotNull @NotNull ByteBuffer header, @NotNull @NotNull com.fishlib.configuration.Configuration configuration, @NotNull @NotNull com.fishlib.io.logger.Logger log) 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(LoggerInfo, ByteBuffer, Configuration, Logger).- If a columnPartitionValue was provided with
setColumnPartitionValue(java.lang.String), it is used for all rows. - If a columnPartitionValue was 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:
loggerInfo- aLoggerInfothat describes the logger to be created.header- the binary log header bytesconfiguration-Configurationinstance for property lookuplog- a textLoggerto be used duringIntradayLoggerinitialization- Returns:
- An initialized
SinglePartitionWriter. - Throws:
IOException- when the log sink cannot be initialized
- If a columnPartitionValue was provided with
-
getInternalPartitionForLogs
@NotNull public @NotNull String getInternalPartitionForLogs(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 forincludePid- if true, the process's PID is used in the internal partition- Returns:
- the internal partition as described above.
-