From dd5f004b06a16e7c291bd159f792b718b7fce0b3 Mon Sep 17 00:00:00 2001 From: illustris Date: Sat, 8 Jan 2022 14:02:32 +0530 Subject: nixos/hadoop: refactor HDFS options --- nixos/modules/services/cluster/hadoop/hdfs.nix | 69 +++++++------------------- 1 file changed, 19 insertions(+), 50 deletions(-) (limited to 'nixos/modules/services') diff --git a/nixos/modules/services/cluster/hadoop/hdfs.nix b/nixos/modules/services/cluster/hadoop/hdfs.nix index 8c373968364..9caa3d07525 100644 --- a/nixos/modules/services/cluster/hadoop/hdfs.nix +++ b/nixos/modules/services/cluster/hadoop/hdfs.nix @@ -13,71 +13,40 @@ let ''; default = false; }; + openFirewall = serviceName: mkOption { + type = types.bool; + default = true; + description = "Open firewall ports for ${serviceName}."; + }; + hadoopServiceOption = { serviceName, firewallOption ? true }: { + enable = mkEnableOption serviceName; + inherit restartIfChanged; + } // (if firewallOption then {openFirewall = openFirewall serviceName;} else {}); in { options.services.hadoop.hdfs = { - namenode = { - enable = mkEnableOption "HDFS NameNode"; + namenode = hadoopServiceOption { serviceName = "HDFS NameNode"; } // { formatOnInit = mkOption { type = types.bool; default = false; description = '' Format HDFS namenode on first start. This is useful for quickly spinning up ephemeral HDFS clusters with a single namenode. - For HA clusters, initialization involves multiple steps across multiple nodes. Follow [this guide](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HDFSHighAvailabilityWithQJM.html) - to initialize an HA cluster manually. - ''; - }; - inherit restartIfChanged; - openFirewall = mkOption { - type = types.bool; - default = true; - description = '' - Open firewall ports for namenode - ''; - }; - }; - datanode = { - enable = mkEnableOption "HDFS DataNode"; - inherit restartIfChanged; - openFirewall = mkOption { - type = types.bool; - default = true; - description = '' - Open firewall ports for datanode + For HA clusters, initialization involves multiple steps across multiple nodes. Follow this guide to initialize an HA cluster manually: + ''; }; }; - journalnode = { - enable = mkEnableOption "HDFS JournalNode"; - inherit restartIfChanged; - openFirewall = mkOption { - type = types.bool; - default = true; - description = '' - Open firewall ports for journalnode - ''; - }; - }; - zkfc = { - enable = mkEnableOption "HDFS ZooKeeper failover controller"; - inherit restartIfChanged; + datanode = hadoopServiceOption { serviceName = "HDFS DataNode"; }; + journalnode = hadoopServiceOption { serviceName = "HDFS JournalNode"; }; + zkfc = hadoopServiceOption { + serviceName = "HDFS ZooKeeper failover controller"; + firewallOption = false; }; - httpfs = { - enable = mkEnableOption "HDFS HTTPfs server"; + httpfs = hadoopServiceOption { serviceName = "HDFS JournalNode"; } // { tempPath = mkOption { type = types.path; default = "/tmp/hadoop/httpfs"; - description = '' - HTTPFS_TEMP path used by HTTPFS - ''; - }; - inherit restartIfChanged; - openFirewall = mkOption { - type = types.bool; - default = true; - description = '' - Open firewall ports for HTTPFS - ''; + description = "HTTPFS_TEMP path used by HTTPFS"; }; }; }; -- cgit 1.4.1