Class IntradayLoggerBuilder<LOGGER_TYPE extends com.illumon.intradaylogger.IntradayLogger>
IntradayLogger
instances, with static helpers for some specific logger
types.
In all cases, this factory will determine the internal partition (or a prefix thereof, if log-format suffixing is
set) through getInternalPartitionForLogs(IntradayLogger, String)
.
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.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIntradayLoggerBuilder
(Class<LOGGER_TYPE> loggerClass) Construct a builder for newIntradayLogger
s. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getInternalPartitionForLogs
(LOGGER_TYPE logger, String pidstr) Determine an appropriate internal partition that can be used for writing logs.static String
Gets theLOCAL_INTERNAL_PARTITION_PROPERTY
from theConfiguration
if it is defined.static String
Get the identifier for the local node if it is availablestatic String
getNodeIdentifier
(boolean legalize) Get the identifier for the local host by callingInetAddress.getLocalHost().getHostName()
if it is available, optionally legalizing it for use as a partition identifier by replacing dots with underscores.makeLogger
(com.fishlib.configuration.Configuration configuration, com.fishlib.io.logger.Logger log) Create anIntradayLogger
and initialize it according to the specified parameters on this builder.setColumnPartitionFunction
(Function<?, String> columnPartitionFunction) Set a function to be used to compute the column partition value for function-based column partition determination.setColumnPartitionValue
(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.setNamespace
(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 logger.setProcessName
(String processName) Set property prefix to be used for log creation and initialization.setStandalone
(boolean standalone) Set whether to skip logger checksum verification, appropriate for logging processes that cannot contact a remote schema service.setSuffixInternalPartitionWithLogFormat
(boolean suffixInternalPartitionWithLogFormat) Set whether to suffix internal partitions with the log format.setTableName
(String tableName) Set the table name for the new logger, if the logger's default should not be used.setTimeZoneName
(String timeZoneName) Set the name of the time zone to be used to determine column partition values and file name date-time stamps.
-
Field Details
-
FAILOVER_FROM_LAS_ALLOWED_PROP
If this is true, then makeLogger will try to create a non-LAS logger if the LAS isn't working.- See Also:
-
LOCAL_INTERNAL_PARTITION_PROPERTY
If defined, the value of this property determines the internal partition. SeegetInternalPartitionForLogs(IntradayLogger, String)
for further details.- See Also:
-
-
Constructor Details
-
IntradayLoggerBuilder
Construct a builder for newIntradayLogger
s.- Parameters:
loggerClass
- TheIntradayLogger
Class
to be instantiated
-
-
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
public IntradayLoggerBuilder<LOGGER_TYPE> setNamespaceSet(@NotNull TableIdentifier.NamespaceSet namespaceSet) Set theTableIdentifier.NamespaceSet
(USER or SYSTEM) for the logger. Defaults toTableIdentifier.NamespaceSet.SYSTEM
Required.- Parameters:
namespaceSet
- TheTableIdentifier.NamespaceSet
for 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.
Superceded when a column partition function or a column partition value is set and used.
- Parameters:
timeZoneName
- The time zone name- Returns:
- This builder.
-
setColumnPartitionFunction
public IntradayLoggerBuilder<LOGGER_TYPE> setColumnPartitionFunction(@Nullable Function<?, String> columnPartitionFunction) Set a function to be used to compute the column partition value for function-based column partition determination. Optional.Superceded when a column partition value is set and used.
- Parameters:
columnPartitionFunction
- The column partition function- Returns:
- This builder.
-
setColumnPartitionValue
public IntradayLoggerBuilder<LOGGER_TYPE> setColumnPartitionValue(@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.
-
setStandalone
Set whether to skip logger checksum verification, appropriate for logging processes that cannot contact a remote schema service. Defaults to false. Optional.- Parameters:
standalone
- Whether to skip logger checksum verification- Returns:
- This builder.
-
setSuffixInternalPartitionWithLogFormat
public IntradayLoggerBuilder<LOGGER_TYPE> 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 IntradayLoggerBuilder<LOGGER_TYPE> 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.
-
makeLogger
public LOGGER_TYPE makeLogger(@NotNull com.fishlib.configuration.Configuration configuration, @NotNull com.fishlib.io.logger.Logger log) Create anIntradayLogger
and initialize it according to the specified parameters on this builder.- If a columnPartitionValue is provided, it will be used for all rows, regardless of any specified dynamic partition properties or provided columnPartitionFunction.
- If no columnPartitionValue is provided, the column partition value will be determined either by the date when the logged row is written using the specified time zone, or determined dynamically from the schema and data if the properties specify this (loggerClass.useDynamicPartitions, or processName.useDynamicPartitions=true, or loggerClass.processName.useDynamicPartitions=true).
- The rows will be 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 lookuplog
-Logger
to be used duringIntradayLogger
initialization- Returns:
- An initialized
IntradayLogger
.
-
getNodeIdentifier
Get the identifier for the local host by callingInetAddress.getLocalHost().getHostName()
if it is available, optionally legalizing it for use as a partition identifier by replacing dots with underscores. This will return a Pod name if deployed in a Kubernetes environment.- Parameters:
legalize
- if true, modify the return value to be a legal partition string- Returns:
- the local host name, or "UndeterminedHost" if it can't be determined
-
getNodeIdentifier
Get the identifier for the local node if it is available- Returns:
- the local host name, or "UndeterminedHost" if it can't be determined
-
getInternalPartitionFromConfig
Gets theLOCAL_INTERNAL_PARTITION_PROPERTY
from theConfiguration
if it is defined. If the property value starts withenv:
then the part of the property after that prefix will be used to look up and return an environment variable. For example, if configuring a property value ofenv:NODE_IP
this method will return the value of the NODE_IP environment variable, with all '.' characters replaced with a '_'. Will return null if property is not present, or if there is no environment variable whose name matches the part of the property afterenv:
prefix.- Returns:
- The value to be used as the internal partition. Will be null if
LOCAL_INTERNAL_PARTITION_PROPERTY
is not defined, or the environment variable it references is not defined.
-
getInternalPartitionForLogs
Determine an appropriate internal partition that can be used for writing logs. CallsgetInternalPartitionFromConfig()
and uses that value, if a config value is present. If not, then the partition will be the value obtained by callinggetNodeIdentifier()
, with any period characters replaced with underscores.- Returns:
- the internal partition as described above.
-
getInternalPartitionForLogs
-