2021-12-19 01:06:50 +00:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
2022-08-12 12:06:08 +00:00
|
|
|
cfg = config.services.hbase-standalone;
|
|
|
|
opt = options.services.hbase-standalone;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
|
|
|
buildProperty = configAttr:
|
|
|
|
(builtins.concatStringsSep "\n"
|
|
|
|
(lib.mapAttrsToList
|
|
|
|
(name: value: ''
|
|
|
|
<property>
|
|
|
|
<name>${name}</name>
|
|
|
|
<value>${builtins.toString value}</value>
|
|
|
|
</property>
|
|
|
|
'')
|
|
|
|
configAttr));
|
|
|
|
|
|
|
|
configFile = pkgs.writeText "hbase-site.xml"
|
|
|
|
''<configuration>
|
2021-12-19 01:06:50 +00:00
|
|
|
${buildProperty (opt.settings.default // cfg.settings)}
|
2021-12-06 16:07:01 +00:00
|
|
|
</configuration>
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
configDir = pkgs.runCommand "hbase-config-dir" { preferLocalBuild = true; } ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp ${cfg.package}/conf/* $out/
|
|
|
|
rm $out/hbase-site.xml
|
|
|
|
ln -s ${configFile} $out/hbase-site.xml
|
|
|
|
'' ;
|
|
|
|
|
|
|
|
in {
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
imports = [
|
|
|
|
(mkRenamedOptionModule [ "services" "hbase" ] [ "services" "hbase-standalone" ])
|
|
|
|
];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
2022-08-12 12:06:08 +00:00
|
|
|
services.hbase-standalone = {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = mkEnableOption ''
|
2022-08-12 12:06:08 +00:00
|
|
|
HBase master in standalone mode with embedded regionserver and zookeper.
|
2024-04-21 15:54:59 +00:00
|
|
|
Do not use this configuration for production nor for evaluating HBase performance
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
package = mkPackageOption pkgs "hbase" { };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "hbase";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
User account under which HBase runs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "hbase";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Group account under which HBase runs.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/hbase";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Specifies location of HBase database files. This location should be
|
|
|
|
writable and readable for the user the HBase service runs as
|
|
|
|
(hbase by default).
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
logDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/log/hbase";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Specifies the location of HBase log files.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
settings = mkOption {
|
|
|
|
type = with lib.types; attrsOf (oneOf [ str int bool ]);
|
2021-12-19 01:06:50 +00:00
|
|
|
default = {
|
|
|
|
"hbase.rootdir" = "file://${cfg.dataDir}/hbase";
|
|
|
|
"hbase.zookeeper.property.dataDir" = "${cfg.dataDir}/zookeeper";
|
|
|
|
};
|
|
|
|
defaultText = literalExpression ''
|
|
|
|
{
|
|
|
|
"hbase.rootdir" = "file://''${config.${opt.dataDir}}/hbase";
|
|
|
|
"hbase.zookeeper.property.dataDir" = "''${config.${opt.dataDir}}/zookeeper";
|
|
|
|
}
|
|
|
|
'';
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2022-08-12 12:06:08 +00:00
|
|
|
configurations in hbase-site.xml, see <https://github.com/apache/hbase/blob/master/hbase-server/src/test/resources/hbase-site.xml> for details.
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
config = mkIf cfg.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' - ${cfg.user} ${cfg.group} - -"
|
|
|
|
"d '${cfg.logDir}' - ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
|
|
|
systemd.services.hbase = {
|
|
|
|
description = "HBase Server";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
environment = {
|
2021-12-06 16:07:01 +00:00
|
|
|
# JRE 15 removed option `UseConcMarkSweepGC` which is needed.
|
|
|
|
JAVA_HOME = "${pkgs.jre8}";
|
2020-04-24 23:36:52 +00:00
|
|
|
HBASE_LOG_DIR = cfg.logDir;
|
|
|
|
};
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
ExecStart = "${cfg.package}/bin/hbase --config ${configDir} master start";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.hbase = {
|
|
|
|
description = "HBase Server user";
|
|
|
|
group = "hbase";
|
|
|
|
uid = config.ids.uids.hbase;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.hbase.gid = config.ids.gids.hbase;
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|