HBASE-26512 Make timestamp format configurable in HBase shell scan output

Signed-off-by: Josh Elser <elserj@apache.org
Signed-off-by: Peter Somogyi <psomogyi@apache.org>
This commit is contained in:
Istvan Toth 2021-11-29 11:34:24 +01:00 committed by Josh Elser
parent ea824df571
commit 7845d006e6
2 changed files with 14 additions and 2 deletions

View File

@ -1602,6 +1602,11 @@ public final class HConstants {
"hbase.regionserver.slowlog.systable.enabled";
public static final boolean DEFAULT_SLOW_LOG_SYS_TABLE_ENABLED_KEY = false;
public static final String SHELL_TIMESTAMP_FORMAT_EPOCH_KEY =
"hbase.shell.timestamp.format.epoch";
public static final boolean DEFAULT_SHELL_TIMESTAMP_FORMAT_EPOCH = false;
/**
* Number of rows in a batch operation above which a warning will be logged.
*/

View File

@ -119,6 +119,9 @@ EOF
@name = @table.getName.getNameAsString
@shell = shell
@converters = {}
@timestamp_format_epoch = table.getConfiguration.getBoolean(
HConstants::SHELL_TIMESTAMP_FORMAT_EPOCH_KEY,
HConstants::DEFAULT_SHELL_TIMESTAMP_FORMAT_EPOCH)
end
def close
@ -751,9 +754,13 @@ EOF
end
def toLocalDateTime(millis)
if @timestamp_format_epoch
return millis
else
instant = java.time.Instant.ofEpochMilli(millis)
return java.time.LocalDateTime.ofInstant(instant, java.time.ZoneId.systemDefault()).toString
end
end
# Make a String of the passed kv
# Intercept cells whose format we know such as the info:regioninfo in hbase:meta