diff options
author | illustris <rharikrishnan95@gmail.com> | 2022-03-02 12:50:01 +0530 |
---|---|---|
committer | illustris <rharikrishnan95@gmail.com> | 2022-03-11 14:26:57 +0530 |
commit | e1017adb328da98e7942ec08354dd686653370a4 (patch) | |
tree | 68fd5d43f6119bb9198b10cc4d1cb1dcb9a7a9f3 /nixos/modules/services/cluster/hadoop/hdfs.nix | |
parent | bef71d7c530aeecdcfb66290e6c0b4948d1fb223 (diff) | |
download | nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.tar nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.tar.gz nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.tar.bz2 nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.tar.lz nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.tar.xz nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.tar.zst nixpkgs-e1017adb328da98e7942ec08354dd686653370a4.zip |
nixos/hadoop: add module options for commonly used service configs
Diffstat (limited to 'nixos/modules/services/cluster/hadoop/hdfs.nix')
-rw-r--r-- | nixos/modules/services/cluster/hadoop/hdfs.nix | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/nixos/modules/services/cluster/hadoop/hdfs.nix b/nixos/modules/services/cluster/hadoop/hdfs.nix index 1725dc62d0c..325a002ad32 100644 --- a/nixos/modules/services/cluster/hadoop/hdfs.nix +++ b/nixos/modules/services/cluster/hadoop/hdfs.nix @@ -7,7 +7,7 @@ let hadoopConf = "${import ./conf.nix { inherit cfg pkgs lib; }}/"; # Generator for HDFS service options - hadoopServiceOption = { serviceName, firewallOption ? true }: { + hadoopServiceOption = { serviceName, firewallOption ? true, extraOpts ? null }: { enable = mkEnableOption serviceName; restartIfChanged = mkOption { type = types.bool; @@ -19,13 +19,27 @@ let ''; default = false; }; + extraFlags = mkOption{ + type = with types; listOf str; + default = []; + description = "Extra command line flags to pass to ${serviceName}"; + example = [ + "-Dcom.sun.management.jmxremote" + "-Dcom.sun.management.jmxremote.port=8010" + ]; + }; + extraEnv = mkOption{ + type = with types; attrsOf str; + default = {}; + description = "Extra environment variables for ${serviceName}"; + }; } // (optionalAttrs firewallOption { openFirewall = mkOption { type = types.bool; default = false; description = "Open firewall ports for ${serviceName}."; }; - }); + }) // (optionalAttrs (extraOpts != null) extraOpts); # Generator for HDFS service configs hadoopServiceConfig = @@ -36,17 +50,19 @@ let , allowedTCPPorts ? [ ] , preStart ? "" , environment ? { } + , extraConfig ? { } }: ( - mkIf serviceOptions.enable { + mkIf serviceOptions.enable ( mkMerge [{ systemd.services."hdfs-${toLower name}" = { - inherit description preStart environment; + inherit description preStart; + environment = environment // serviceOptions.extraEnv; wantedBy = [ "multi-user.target" ]; inherit (serviceOptions) restartIfChanged; serviceConfig = { inherit User; SyslogIdentifier = "hdfs-${toLower name}"; - ExecStart = "${cfg.package}/bin/hdfs --config ${hadoopConf} ${toLower name}"; + ExecStart = "${cfg.package}/bin/hdfs --config ${hadoopConf} ${toLower name} ${escapeShellArgs serviceOptions.extraFlags}"; Restart = "always"; }; }; @@ -56,7 +72,7 @@ let networking.firewall.allowedTCPPorts = mkIf ((builtins.hasAttr "openFirewall" serviceOptions) && serviceOptions.openFirewall) allowedTCPPorts; - } + } extraConfig]) ); in @@ -77,7 +93,27 @@ in }; }; - datanode = hadoopServiceOption { serviceName = "HDFS DataNode"; }; + datanode = hadoopServiceOption { serviceName = "HDFS DataNode"; } // { + dataDirs = mkOption { + default = null; + description = "Tier and path definitions for datanode storage."; + type = with types; nullOr (listOf (submodule { + options = { + type = mkOption { + type = enum [ "SSD" "DISK" "ARCHIVE" "RAM_DISK" ]; + description = '' + Storage types ([SSD]/[DISK]/[ARCHIVE]/[RAM_DISK]) for HDFS storage policies. + ''; + }; + path = mkOption { + type = path; + example = [ "/var/lib/hadoop/hdfs/dn" ]; + description = "Determines where on the local filesystem a data node should store its blocks."; + }; + }; + })); + }; + }; journalnode = hadoopServiceOption { serviceName = "HDFS JournalNode"; }; @@ -122,6 +158,8 @@ in 50010 # datanode.address 50020 # datanode.ipc.address ]; + extraConfig.services.hadoop.hdfsSiteInternal."dfs.datanode.data.dir" = let d = cfg.hdfs.datanode.dataDirs; in + if (d!= null) then (concatMapStringsSep "," (x: "["+x.type+"]file://"+x.path) cfg.hdfs.datanode.dataDirs) else d; }) (hadoopServiceConfig { |