mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(emr): run a MapReduce JobHistory server on a cluster's primary node (#8662)
EMR's primary node runs one (a release's mapred-site classification "Restarts Hadoop MapReduce-HistoryServer"); Floci's did not, so a client asking about a MapReduce job whose application master had ended, for its counters or task reports, waited about 30 seconds a call on 0.0.0.0:10020 and got nothing. Pig asks after each of its MapReduce jobs, so #8636 turned its task reports off and gave its client one try. A cluster that runs YARN now starts `mapred historyserver` beside the ResourceManager, on Hadoop's own ports and where HDFS listens, from the jobs' history in the cluster's HDFS, and its primary node is ready once the server answers. A step's MapReduce settings name it, and so do a Hive step's, for a query run on MapReduce; an emr-spark-* node runs it from the Hadoop it keeps apart. The node scripts' readiness waits share one helper. Pig's workaround goes: its MapReduce jobs' counters come from the server, as on EMR.
This commit is contained in:
1 parent
5ea7186549
commit
6e30baf46c
9 files changed
+127
-81
No files matched your search
+12
-16
@@ -289,7 +289,9 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
service", as the Management Guide puts it, in the primary node's container, with a NodeManager beside it on a cluster
|
||||
created with no core node, which keeps it, and its DataNode, as core nodes are added, the blocks it holds staying in
|
||||
reach, and the cluster's Spark, MapReduce (see **Hadoop streaming and MapReduce**) and Hive's Tez (see **Hive steps**)
|
||||
run on them. A
|
||||
run on them. Beside them runs the MapReduce JobHistory server EMR's primary node runs too (a release's `mapred-site`
|
||||
classification "Restarts Hadoop MapReduce-HistoryServer"), on Hadoop's own ports, 10020 and 19888 for its web
|
||||
pages, from the jobs' history in the cluster's HDFS, and the node is ready once it answers. A
|
||||
Spark step or custom JAR step submits to it, with `--master yarn` unless it names another master, and in the deploy
|
||||
mode it asks for, `client` when it names none, and so does a `spark-submit` a command or script starts. In client
|
||||
mode the driver stays in the step's container and its output in the step's logs, and the executors run in YARN's
|
||||
@@ -335,8 +337,10 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
application master and tasks in YARN's containers on the cluster's nodes. A step's `hadoop` command, and so
|
||||
`hadoop-streaming`, a `hadoop jar` and `hdfs dfs`, run from the nodes' Hadoop (`/usr/lib`, or the one an `emr-spark-*`
|
||||
release keeps in `/opt`), with a `mapred-site.xml` that names YARN, the nodes' folders and the step's AWS environment,
|
||||
and an application master of 1 GB and tasks of 768 MB, which the cluster's `mapred-site` replaces. A custom JAR step's
|
||||
MapReduce gets the same. Where the cluster runs no YARN, a step's `hadoop` command runs MapReduce in local mode, in
|
||||
and an application master of 1 GB and tasks of 768 MB, which the cluster's `mapred-site` replaces, and that names the
|
||||
JobHistory server, which a client asks about a job once its application master has ended, for its counters and
|
||||
task reports as Pig does after each of its MapReduce jobs. A custom JAR step's MapReduce gets the same, and a Hive
|
||||
step's settings name the server too, for a query whose `hive.execution.engine` is `mr`. Where the cluster runs no YARN, a step's `hadoop` command runs MapReduce in local mode, in
|
||||
its own JVM: the image has MapReduce only in Spark's shaded Hadoop client, which
|
||||
Floci makes the
|
||||
command's MapReduce home (`HADOOP_MAPRED_HOME`, unless a `spark-env` export names one), so it is on the
|
||||
@@ -444,15 +448,11 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
`mapreduce.job.working.dir=/user/${user.name}`, then the cluster's `tez-site` and `pig-properties`, a later key
|
||||
winning, Pig passing the Hadoop and Tez ones on to its jobs. Pig sets the working directory of each input's file
|
||||
system to it, which S3A, Floci's `s3://`, refuses when it names another file system, as Hadoop's own default, the
|
||||
HDFS home with its scheme, does; without a scheme, it is the same HDFS folder. The cluster runs no MapReduce
|
||||
JobHistory server, which a job client asks about a job whose application master has ended, as Pig does for each
|
||||
MapReduce job's task reports and counters, so Floci's lines also set `pig.stats.notaskreport=true` and
|
||||
`yarn.app.mapreduce.client.max-retries=1`: Pig asks for no task reports, and asks once for the counters, which costs
|
||||
about ten seconds a job. A `pig-log4j` adds its lines to the `log4j.properties` Pig then reads, and the exports of
|
||||
`pig-env` start its `pig-env.sh`. Any command a step runs on such a cluster, `command-runner.jar pig ...` or a
|
||||
script's, gets the same. With `pig.enabled` off, a Pig step on a cluster whose `Applications` name Pig is `FAILED`
|
||||
without running ("Floci does not run this step: Pig is not in the image steps run in. floci.services.emr.pig.enabled
|
||||
adds Apache Pig to it.").
|
||||
HDFS home with its scheme, does; without a scheme, it is the same HDFS folder. A `pig-log4j` adds its lines to the
|
||||
`log4j.properties` Pig then reads, and the exports of `pig-env` start its `pig-env.sh`. Any command a step runs on
|
||||
such a cluster, `command-runner.jar pig ...` or a script's, gets the same. With `pig.enabled` off, a Pig step on a
|
||||
cluster whose `Applications` name Pig is `FAILED` without running ("Floci does not run this step: Pig is not in the
|
||||
image steps run in. floci.services.emr.pig.enabled adds Apache Pig to it.").
|
||||
* **S3DistCp**: the image has no `s3-dist-cp`, so a `command-runner.jar` step whose
|
||||
first argument is `s3-dist-cp`, the Release Guide's form, runs Floci's own program instead, through
|
||||
`spark-submit` in the step's container, copying through Hadoop's file systems: `--src` and `--dest` take
|
||||
@@ -660,10 +660,6 @@ holding the driver and its executors, or a command or a script. The cluster itse
|
||||
- **MapReduce and Tez in local mode where there is no YARN.** Only a cluster that runs YARN (see **YARN**) runs them on
|
||||
it; on any other, `hadoop-streaming`, a custom JAR's MapReduce and Hive's and Pig's Tez run in the step's
|
||||
container.
|
||||
- **No MapReduce JobHistory server.** EMR runs one (a release's `mapred-site` classification "Restarts Hadoop
|
||||
MapReduce-HistoryServer"); Floci's primary node does not, so a client asking about a MapReduce job whose application
|
||||
master has ended waits for it, and gets no counters or task reports. Pig, which asks after each of its MapReduce
|
||||
jobs, is set to ask once (see **Pig steps**).
|
||||
- **Pig is Apache's 0.18.0, and only with `pig.enabled`.** EMR's 7.x releases ship Pig 0.17.0, whose Apache build is
|
||||
for Hadoop 2; no AWS image carries Pig, so Floci downloads Apache's 0.18.0, for Hadoop 3, when it is enabled, and
|
||||
runs it on the image's Tez (see **Pig steps**).
|
||||
|
||||
@@ -134,6 +134,9 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
// The ResourceManager's cluster metrics on its web port, which say when the NodeManager has registered.
|
||||
private static final String RESOURCE_MANAGER_METRICS = "http://" + BIND + ":8088/ws/v1/cluster/metrics";
|
||||
private static final String RESOURCE_MANAGER_NODES = "http://" + BIND + ":8088/ws/v1/cluster/nodes?states=";
|
||||
// The MapReduce JobHistory server's information on its web port, which says it has started.
|
||||
private static final String JOB_HISTORY_INFO = "http://" + BIND + ":"
|
||||
+ EmrServerlessSparkRunner.JOB_HISTORY_WEB_PORT + "/ws/v1/history/info";
|
||||
// Where a NodeManager keeps its containers' logs, on the node's volume, as <application>/<container>/<file>.
|
||||
private static final String YARN_LOGS = "/mnt/yarn/logs";
|
||||
private static final int LOG_LISTING_SECONDS = 30;
|
||||
@@ -166,7 +169,8 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
" h=$" + HADOOP_FOLDER_VARIABLE,
|
||||
" export HADOOP_HOME=$h/hadoop HADOOP_COMMON_HOME=$h/hadoop HADOOP_LIBEXEC_DIR=$h/hadoop/libexec"
|
||||
+ " HADOOP_HDFS_HOME=$h/hadoop-hdfs HADOOP_MAPRED_HOME=$h/hadoop-mapreduce"
|
||||
+ " HADOOP_YARN_HOME=$h/hadoop-yarn PATH=$h/hadoop-hdfs/bin:$h/hadoop-yarn/bin:$h/hadoop/bin:$PATH",
|
||||
+ " HADOOP_YARN_HOME=$h/hadoop-yarn"
|
||||
+ " PATH=$h/hadoop-hdfs/bin:$h/hadoop-yarn/bin:$h/hadoop-mapreduce/bin:$h/hadoop/bin:$PATH",
|
||||
"fi");
|
||||
// What every node of a cluster writes before its daemons start: the files that say which node it is, the Hadoop
|
||||
// configuration, its name among the nodes in HDFS's when it is given one, and the empty files listing the nodes
|
||||
@@ -227,6 +231,13 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
"yarn.scheduler.capacity.root.default.maximum-capacity", "100",
|
||||
"yarn.scheduler.capacity.maximum-am-resource-percent", "0.5"))
|
||||
+ " '</configuration>' > " + HDFS_CONF + "/capacity-scheduler.xml || exit",
|
||||
" printf '%s\\n' '<configuration>'" + yarnProperties(List.of(
|
||||
"mapreduce.jobhistory.address", "$FLOCI_HDFS_HOST:" + EmrServerlessSparkRunner.JOB_HISTORY_PORT,
|
||||
"mapreduce.jobhistory.webapp.address",
|
||||
"$FLOCI_HDFS_HOST:" + EmrServerlessSparkRunner.JOB_HISTORY_WEB_PORT,
|
||||
"mapreduce.jobhistory.admin.address", "$FLOCI_HDFS_HOST:10033",
|
||||
"mapreduce.jobhistory.bind-host", "$FLOCI_HDFS_BIND"))
|
||||
+ " '</configuration>' > " + HDFS_CONF + "/mapred-site.xml || exit",
|
||||
"fi",
|
||||
"printf '%s\\n' 'log4j.rootLogger=WARN,console' 'log4j.appender.console=org.apache.log4j.ConsoleAppender'"
|
||||
+ " 'log4j.appender.console.layout=org.apache.log4j.PatternLayout'"
|
||||
@@ -239,26 +250,28 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
// and a DataNode with their data in it, the NameNode formatted the first time, with one copy of each block and
|
||||
// without permissions, listening on FLOCI_HDFS_BIND: every address of the container, on the cluster's own network,
|
||||
// or, in a namespace the steps share, the host's or a container's, only its loopback, which its name leads to, so
|
||||
// no other interface serves files anyone could change; in a container's, the hosts file the name goes in is the
|
||||
// one the namespace's containers share, the steps' too. The other daemons start with them, as none needs the HDFS
|
||||
// to start. With HIVE_METASTORE_VARIABLE set, Hive's metastore service does, with the Hive image's Hadoop
|
||||
// no other interface serves files anyone could change; in a container's, the hosts file the name goes in is the one
|
||||
// the namespace's containers share, the steps' too. The other daemons start with them, as none needs the HDFS to
|
||||
// start. With HIVE_METASTORE_VARIABLE set, Hive's metastore service does, with the Hive image's Hadoop
|
||||
// configuration, which the node's image keeps at HIVE_HADOOP_CONF, as Hive steps run, its settings after it: "Hive
|
||||
// records metastore information in a MySQL database on the primary node's file system", kept as a Derby database
|
||||
// in /mnt, which only the service opens, so any number of steps share it, its log in /tmp, and its warehouse in
|
||||
// the HDFS; the cluster's core-site and hive-site, last, replace any of them, as on EMR's primary node. With
|
||||
// records metastore information in a MySQL database on the primary node's file system", kept as a Derby database in
|
||||
// /mnt, which only the service opens, so any number of steps share it, its log in /tmp, and its warehouse in the
|
||||
// HDFS; the cluster's core-site and hive-site, last, replace any of them, as on EMR's primary node. With
|
||||
// YARN_MEMORY_VARIABLE set, YARN does, as "the primary node runs the YARN ResourceManager service": a
|
||||
// ResourceManager and, as on a cluster of one node, a NodeManager, which offers that much memory and
|
||||
// YARN_VCORES_VARIABLE's cores to the containers it runs the steps' Spark executors in, its local and log folders
|
||||
// in /mnt, Java 17 opening to both the packages they reach into. Where the cluster's core nodes hold them
|
||||
// (NODE_WORKERS_VARIABLE), the node runs no DataNode or NodeManager, but a DataNode on a volume that holds one's
|
||||
// data, so the blocks it kept stay in reach. Once the NameNode on its port is this container's own, its ClusterId
|
||||
// the one its format gave it, rather than another cluster's in that namespace, the DataNode has joined and the
|
||||
// NameNode has left safe mode, which on a restart waits for the blocks the volume holds, the folders EMR's HDFS has
|
||||
// for steps, /tmp and the hadoop user's home, are made, and the metastore's warehouse and HIVE_JARS, which Hive's
|
||||
// exec jar goes in. HDFS_READY then says the node is ready, once the metastore takes connections and the
|
||||
// NodeManager has registered. A daemon that exits, before or after, the metastore among them, ends the container,
|
||||
// its readiness gone, so the next step starts it again on its data. With HADOOP_FOLDER_VARIABLE set, every daemon
|
||||
// runs from the Hadoop in that folder.
|
||||
// in /mnt, and the MapReduce JobHistory server EMR runs too (a release's mapred-site "Restarts Hadoop
|
||||
// MapReduce-HistoryServer"), which a client asks about a MapReduce job whose application master has ended, the
|
||||
// jobs' history in the HDFS; Java 17 opening to each the packages they reach into. Where the cluster's core nodes
|
||||
// hold them (NODE_WORKERS_VARIABLE), the node runs no DataNode or NodeManager, but a DataNode on a volume that
|
||||
// holds one's data, so the blocks it kept stay in reach. Once the NameNode on its port is this container's own, its
|
||||
// ClusterId the one its format gave it, rather than another cluster's in that namespace, the DataNode has joined
|
||||
// and the NameNode has left safe mode, which on a restart waits for the blocks the volume holds, the folders EMR's
|
||||
// HDFS has for steps, /tmp and the hadoop user's home, are made, and the metastore's warehouse and HIVE_JARS, which
|
||||
// Hive's exec jar goes in. HDFS_READY then says the node is ready, once the metastore takes connections, the
|
||||
// NodeManager has registered and the JobHistory server answers. A daemon that exits, before or after, the metastore
|
||||
// among them, ends the container, its readiness gone, so the next step starts it again on its data. With
|
||||
// HADOOP_FOLDER_VARIABLE set, every daemon runs from the Hadoop in that folder.
|
||||
// Where a node's daemons listen: FLOCI_HDFS_BIND, or, with SUBNET_VARIABLE set, the node's own address in that subnet,
|
||||
// its cluster's network, alone, so another network it joins does not reach its HDFS or its YARN; written to
|
||||
// BIND_FILE. Hive 3's metastore has no setting for the address it listens on, so it takes every one.
|
||||
@@ -309,28 +322,25 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
+ "JDK_JAVA_OPTIONS=\"" + yarnOpens() + "\" yarn resourcemanager & n=$((n + 1)); "
|
||||
+ "if [ -z \"$" + NODE_WORKERS_VARIABLE + "\" ]; then "
|
||||
+ "JDK_JAVA_OPTIONS=\"" + yarnOpens() + "\" yarn nodemanager & n=$((n + 1)); fi; "
|
||||
+ "JDK_JAVA_OPTIONS=\"" + yarnOpens() + "\" mapred historyserver & n=$((n + 1)); "
|
||||
+ "fi; "
|
||||
+ "until curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"ClusterId\\\" : \\\"$cid\\\"\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "until curl -sf -m 5 \"" + NAMENODE_JMX + "FSNamesystemState\""
|
||||
+ " | grep -q \"\\\"NumLiveDataNodes\\\" : [1-9]\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ "until curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"Safemode\\\" : \\\"\\\"\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ untilReady("curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"ClusterId\\\" : \\\"$cid\\\"\"")
|
||||
+ untilReady("curl -sf -m 5 \"" + NAMENODE_JMX + "FSNamesystemState\""
|
||||
+ " | grep -q \"\\\"NumLiveDataNodes\\\" : [1-9]\"")
|
||||
+ untilReady("curl -sf -m 5 \"" + NAMENODE_JMX + "NameNodeInfo\""
|
||||
+ " | grep -q \"\\\"Safemode\\\" : \\\"\\\"\"")
|
||||
+ "hdfs dfs -mkdir -p $dirs || exit 1; "
|
||||
+ "if [ -n \"$" + HIVE_METASTORE_VARIABLE + "\" ]; then "
|
||||
+ "jar=$(ls /usr/lib/hive/lib/hive-exec-[0-9]*.jar | head -1); "
|
||||
+ "hdfs dfs -put -f \"$jar\" " + HIVE_JARS
|
||||
+ "/$(basename \"$jar\" .jar)-$(sha256sum \"$jar\" | cut -d\" \" -f1).jar || exit 1; "
|
||||
+ "until (exec 3<>/dev/tcp/127.0.0.1/" + HIVE_METASTORE_PORT + ") 2>/dev/null; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ untilReady("(exec 3<>/dev/tcp/127.0.0.1/" + HIVE_METASTORE_PORT + ") 2>/dev/null")
|
||||
+ "fi; "
|
||||
+ "if [ -n \"$" + YARN_MEMORY_VARIABLE + "\" ]; then "
|
||||
+ "until curl -sf -m 5 " + RESOURCE_MANAGER_METRICS
|
||||
+ " | grep -q \"\\\"activeNodes\\\":[1-9]\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ untilReady("curl -sf -m 5 " + RESOURCE_MANAGER_METRICS
|
||||
+ " | grep -q \"\\\"activeNodes\\\":[1-9]\"")
|
||||
+ untilReady("curl -sf -m 5 " + JOB_HISTORY_INFO + " | grep -q historyInfo")
|
||||
+ "fi; "
|
||||
+ "touch " + HDFS_READY + "; "
|
||||
// Not wait -n: an emr-6.x image's bash, 4.2, does not have it.
|
||||
@@ -346,13 +356,12 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
"exec setpriv --reuid=hadoop --regid=hadoop --clear-groups bash -c '"
|
||||
+ "n=1; if [ -n \"$" + NODE_CORE_VARIABLE + "\" ]; then hdfs datanode & n=2; fi; "
|
||||
+ "JDK_JAVA_OPTIONS=\"" + yarnOpens() + "\" yarn nodemanager & "
|
||||
+ "until curl -sf -m 5 \"http://$FLOCI_HDFS_HOST:8088/ws/v1/cluster/nodes?states=RUNNING\""
|
||||
+ " | grep -q \"\\\"nodeHostName\\\":\\\"$" + NODE_HOST_VARIABLE + "\\\"\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; "
|
||||
+ untilReady("curl -sf -m 5 \"http://$FLOCI_HDFS_HOST:8088/ws/v1/cluster/nodes?states=RUNNING\""
|
||||
+ " | grep -q \"\\\"nodeHostName\\\":\\\"$" + NODE_HOST_VARIABLE + "\\\"\"")
|
||||
+ "if [ -n \"$" + NODE_CORE_VARIABLE + "\" ]; then "
|
||||
+ "until curl -sf -m 5 \"http://$FLOCI_HDFS_HOST:9870/jmx?qry=Hadoop:service=NameNode,"
|
||||
+ "name=NameNodeInfo\" | grep -q \"$" + NODE_HOST_VARIABLE + ":9866\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; fi; "
|
||||
+ untilReady("curl -sf -m 5 \"http://$FLOCI_HDFS_HOST:9870/jmx?qry=Hadoop:service=NameNode,"
|
||||
+ "name=NameNodeInfo\" | grep -q \"$" + NODE_HOST_VARIABLE + ":9866\"")
|
||||
+ "fi; "
|
||||
+ "touch " + HDFS_READY + "; "
|
||||
+ "while [ \"$(jobs -rp | wc -l)\" = $n ]; do sleep 1; done; rm -f " + HDFS_READY
|
||||
+ "; kill $(jobs -rp) 2>/dev/null; exit 1'");
|
||||
@@ -1216,6 +1225,11 @@ public class EmrClusterStorage implements ClusterStorage, ContainerTeardown {
|
||||
return properties.toString();
|
||||
}
|
||||
|
||||
// A node script's wait until condition holds, polled; one of its n daemons exiting meanwhile ends the node.
|
||||
private static String untilReady(String condition) {
|
||||
return "until " + condition + "; do [ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; ";
|
||||
}
|
||||
|
||||
// The JVM options that open to Hadoop's classes the packages its daemons reach into.
|
||||
private static String yarnOpens() {
|
||||
return EmrServerlessSparkRunner.yarnJavaOptions();
|
||||
|
||||
@@ -90,11 +90,6 @@ final class EmrSparkSteps {
|
||||
// one, it is the same folder in HDFS, and Hadoop fills in the user.
|
||||
private static final String WORKING_DIR = "mapreduce.job.working.dir";
|
||||
private static final String USER_HOME = "/user/${user.name}";
|
||||
// A cluster runs no MapReduce JobHistory server, which a job client asks for a job once its application master has
|
||||
// gone, as Pig does for each MapReduce job's task reports and counters: Pig asks for no task reports, and its
|
||||
// client asks the server once rather than three times, each attempt waiting about ten seconds to connect.
|
||||
private static final String PIG_NO_TASK_REPORT = "pig.stats.notaskreport";
|
||||
private static final String CLIENT_RETRIES = "yarn.app.mapreduce.client.max-retries";
|
||||
// The AWS CLI's Hive step on a release is command-runner.jar running "hive-script --run-hive-script --args"
|
||||
// and the step's arguments, the ones the image's hive-script runs hive with; a step can also run hive itself.
|
||||
private static final String HIVE_SCRIPT = "hive-script";
|
||||
@@ -295,8 +290,7 @@ final class EmrSparkSteps {
|
||||
/**
|
||||
* The variables a step's command gets on a cluster with Floci's Pig, which make its {@code pig} read a Pig
|
||||
* configuration of its own: {@code pig.properties} lines that run Pig on Tez, as EMR's does, from a working
|
||||
* directory S3A takes, with no wait on a JobHistory server the cluster does not run, then the cluster's
|
||||
* {@code tez-site} and {@code pig-properties}, a later one winning, and,
|
||||
* directory S3A takes, then the cluster's {@code tez-site} and {@code pig-properties}, a later one winning, and,
|
||||
* with a {@code pig-log4j}, Pig's setting to read the {@code log4j.properties} that gets its lines;
|
||||
* {@code pig-env}'s exports start its {@code pig-env.sh}.
|
||||
*/
|
||||
@@ -304,8 +298,6 @@ final class EmrSparkSteps {
|
||||
Map<String, String> properties = new LinkedHashMap<>();
|
||||
properties.put(PIG_EXECTYPE, PIG_TEZ);
|
||||
properties.put(WORKING_DIR, USER_HOME);
|
||||
properties.put(PIG_NO_TASK_REPORT, "true");
|
||||
properties.put(CLIENT_RETRIES, "1");
|
||||
Map<String, String> log4j = properties(configurations, objectMapper, PIG_LOG4J);
|
||||
if (!log4j.isEmpty()) {
|
||||
properties.put(PIG_LOG4J_CONF, EmrServerlessSparkRunner.PIG_CONF + "/log4j.properties");
|
||||
|
||||
@@ -122,6 +122,9 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
// The port of a cluster's NameNode, HDFS's own default, which hdfs:// paths and those without a scheme
|
||||
// ("hdfs:// (or no prefix)") reach through the cluster's primary node.
|
||||
private static final int HDFS_PORT = 8020;
|
||||
/** The ports of a cluster's MapReduce JobHistory server on its primary node, Hadoop's own defaults. */
|
||||
public static final int JOB_HISTORY_PORT = 10020;
|
||||
public static final int JOB_HISTORY_WEB_PORT = 19888;
|
||||
// Spark's default checkpoint manager goes through Hadoop's FileContext, which refuses an hdfs:// path without a
|
||||
// host, though "hdfs:///path-to-data" and "/path-to-data" "would resolve to the same location in HDFS", as the
|
||||
// Management Guide puts it; so a streaming query keeps its checkpoints through the file system instead.
|
||||
@@ -1254,7 +1257,7 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
// A MapReduce job on the cluster's YARN: its application master and tasks find Hadoop in the nodes' layout, which
|
||||
// yarn.application.classpath's default does not name, and S3A's AWS SDK, reach Floci with the step's AWS environment,
|
||||
// and are sized for a NodeManager as Spark's executors are. The image's core-site.xml names the LZO codec, so its
|
||||
// jars come too.
|
||||
// jars come too. Its client asks the cluster's JobHistory server about it once its application master has ended.
|
||||
private static List<SparkSetting> yarnMapReduceSettings(Job job, List<String> executorEnvironment) {
|
||||
String root = hadoopRoot(job);
|
||||
List<String> classPath = new ArrayList<>(hadoopLayout(root));
|
||||
@@ -1269,7 +1272,20 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
new SparkSetting("mapreduce.reduce.env", environment),
|
||||
new SparkSetting("yarn.app.mapreduce.am.resource.mb", "1024"),
|
||||
new SparkSetting("mapreduce.map.memory.mb", "768"),
|
||||
new SparkSetting("mapreduce.reduce.memory.mb", "768"));
|
||||
new SparkSetting("mapreduce.reduce.memory.mb", "768"),
|
||||
jobHistory(job), jobHistoryWeb(job));
|
||||
}
|
||||
|
||||
// The cluster's MapReduce JobHistory server on its primary node, which a MapReduce job's client asks about it once
|
||||
// its application master has ended, and its web pages.
|
||||
private static SparkSetting jobHistory(Job job) {
|
||||
return new SparkSetting("mapreduce.jobhistory.address",
|
||||
job.storage().resourceManager() + ":" + JOB_HISTORY_PORT);
|
||||
}
|
||||
|
||||
private static SparkSetting jobHistoryWeb(Job job) {
|
||||
return new SparkSetting("mapreduce.jobhistory.webapp.address",
|
||||
job.storage().resourceManager() + ":" + JOB_HISTORY_WEB_PORT);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1291,13 +1307,16 @@ public class EmrServerlessSparkRunner implements SparkJobRunner, ContainerTeardo
|
||||
}
|
||||
|
||||
// Hive's Tez on the cluster's YARN, sized as its tasks are by Hive's own settings: a task's two virtual cores never
|
||||
// match the one YARN's default scheduler grants, so Tez would give each container back.
|
||||
// match the one YARN's default scheduler grants, so Tez would give each container back. A query that runs MapReduce
|
||||
// instead, its hive.execution.engine set to mr, asks the cluster's JobHistory server about its jobs.
|
||||
private static List<SparkSetting> hiveOnYarnSettings(Job job, List<String> executorEnvironment) {
|
||||
String root = hadoopRoot(job);
|
||||
List<SparkSetting> settings = new ArrayList<>(tezOnYarnSettings(job, executorEnvironment,
|
||||
List.of(root + "/hive/lib/hive-exec.jar"), "HIVE_HOME=" + root + "/hive"));
|
||||
settings.add(new SparkSetting("hive.tez.container.size", "768"));
|
||||
settings.add(new SparkSetting("hive.tez.cpu.vcores", "1"));
|
||||
settings.add(jobHistory(job));
|
||||
settings.add(jobHistoryWeb(job));
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
@@ -376,6 +376,11 @@ class EmrClusterStorageTest {
|
||||
assertEquals("0.0.0.0", Files.readString(bind).strip());
|
||||
}
|
||||
|
||||
// A node script's wait until condition holds, which ends the node if one of its daemons exits meanwhile.
|
||||
private static String waitUntil(String condition) {
|
||||
return "until " + condition + "; do [ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; ";
|
||||
}
|
||||
|
||||
// bash running script with FLOCI_HDFS_BIND at 0.0.0.0, and FLOCI_HDFS_SUBNET at subnet unless it is null.
|
||||
private static ProcessBuilder shell(String script, String subnet) {
|
||||
ProcessBuilder shell = new ProcessBuilder("bash", "-c", script);
|
||||
@@ -1335,16 +1340,28 @@ class EmrClusterStorageTest {
|
||||
+ " yarn resourcemanager & n=\\$\\(\\(n \\+ 1\\)\\); if \\[ -z \"\\$FLOCI_NODE_WORKERS\" \\]; then "
|
||||
+ "JDK_JAVA_OPTIONS=\"--add-opens=java\\.base/java\\.lang=ALL-UNNAMED[^\"]*\""
|
||||
+ " yarn nodemanager &").matcher(entrypoint.get(2)).find()));
|
||||
// Started with the NameNode, as neither needs the HDFS to start; ready once the NodeManager has registered,
|
||||
// and the node gone if either daemon exits while starting.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(
|
||||
"yarn nodemanager & n=$((n + 1)); fi; fi; "
|
||||
+ "until curl -sf -m 5 \"http://$(cat /tmp/floci-hdfs-bind):9870/jmx?qry=Hadoop:service=NameNode,name=NameNodeInfo\"")
|
||||
// The MapReduce JobHistory server EMR's primary node runs too, a client asking it about a job whose application
|
||||
// master has ended, on Hadoop's own ports and listening where HDFS does.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> entrypoint.get(2).contains(String.join(" ",
|
||||
"\"<property><name>mapreduce.jobhistory.address</name><value>$FLOCI_HDFS_HOST:10020</value></property>\"",
|
||||
"\"<property><name>mapreduce.jobhistory.webapp.address</name>"
|
||||
+ "<value>$FLOCI_HDFS_HOST:19888</value></property>\"",
|
||||
"\"<property><name>mapreduce.jobhistory.admin.address</name>"
|
||||
+ "<value>$FLOCI_HDFS_HOST:10033</value></property>\"",
|
||||
"\"<property><name>mapreduce.jobhistory.bind-host</name><value>$FLOCI_HDFS_BIND</value></property>\"",
|
||||
"'</configuration>' > /tmp/floci-hdfs-conf/mapred-site.xml || exit"))));
|
||||
// Started with the NameNode, as none needs the HDFS to start; ready once the NodeManager has registered and the
|
||||
// JobHistory server answers, and the node gone if any daemon exits while starting.
|
||||
verify(spec).withEntrypoint(argThat(entrypoint -> Pattern.compile("yarn nodemanager & n=\\$\\(\\(n \\+ 1\\)\\); fi; "
|
||||
+ "JDK_JAVA_OPTIONS=\"--add-opens=java\\.base/java\\.lang=ALL-UNNAMED[^\"]*\" mapred historyserver & "
|
||||
+ "n=\\$\\(\\(n \\+ 1\\)\\); fi; until curl -sf -m 5 \"http://\\$\\(cat /tmp/floci-hdfs-bind\\):9870/jmx")
|
||||
.matcher(entrypoint.get(2)).find()
|
||||
&& entrypoint.get(2).contains("if [ -n \"$FLOCI_YARN_MEMORY_MB\" ]; then "
|
||||
+ "until curl -sf -m 5 http://$(cat /tmp/floci-hdfs-bind):8088/ws/v1/cluster/metrics"
|
||||
+ " | grep -q \"\\\"activeNodes\\\":[1-9]\"; do "
|
||||
+ "[ \"$(jobs -rp | wc -l)\" = $n ] || exit 1; sleep 0.2; done; fi;"
|
||||
+ " touch /tmp/floci-hdfs-ready")));
|
||||
+ waitUntil("curl -sf -m 5 http://$(cat /tmp/floci-hdfs-bind):8088/ws/v1/cluster/metrics"
|
||||
+ " | grep -q \"\\\"activeNodes\\\":[1-9]\"")
|
||||
+ waitUntil("curl -sf -m 5 http://$(cat /tmp/floci-hdfs-bind):19888/ws/v1/history/info"
|
||||
+ " | grep -q historyInfo")
|
||||
+ "fi; touch /tmp/floci-hdfs-ready")));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1366,7 +1383,7 @@ class EmrClusterStorageTest {
|
||||
int export = script.indexOf("export HADOOP_HOME=$h/hadoop HADOOP_COMMON_HOME=$h/hadoop"
|
||||
+ " HADOOP_LIBEXEC_DIR=$h/hadoop/libexec HADOOP_HDFS_HOME=$h/hadoop-hdfs"
|
||||
+ " HADOOP_MAPRED_HOME=$h/hadoop-mapreduce HADOOP_YARN_HOME=$h/hadoop-yarn"
|
||||
+ " PATH=$h/hadoop-hdfs/bin:$h/hadoop-yarn/bin:$h/hadoop/bin:$PATH");
|
||||
+ " PATH=$h/hadoop-hdfs/bin:$h/hadoop-yarn/bin:$h/hadoop-mapreduce/bin:$h/hadoop/bin:$PATH");
|
||||
return script.contains(" h=$FLOCI_HADOOP_FOLDER") && export > 0 && export < script.indexOf("exec setpriv");
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -118,6 +118,9 @@ class EmrPigStepsNightlyIntegrationTest {
|
||||
assertEquals("COMPLETED", state(mapReduce), () -> logs(mapReduce));
|
||||
assertEquals(SUMS, objects("out/mapreduce/"));
|
||||
assertTrue(logs(mapReduce).contains("MapReduceLauncher"), () -> logs(mapReduce));
|
||||
// Its counters, which Pig's client gets from the cluster's JobHistory server once each job's application master
|
||||
// has ended.
|
||||
assertTrue(logs(mapReduce).contains("Successfully read 4 records"), () -> logs(mapReduce));
|
||||
}
|
||||
|
||||
private void startCluster() {
|
||||
|
||||
@@ -1068,8 +1068,7 @@ class EmrServiceContainerStepsTest {
|
||||
SparkJobRunner.Job job = runner.jobs.get(0);
|
||||
assertEquals(args, job.command());
|
||||
assertEquals(EmrServiceFixture.RecordingReleaseImages.IMAGE, job.imageTemplate());
|
||||
assertEquals("exectype = tez\nmapreduce.job.working.dir = /user/${user.name}\npig.stats.notaskreport = true\n"
|
||||
+ "yarn.app.mapreduce.client.max-retries = 1\npig.exec.reducers.max = 8",
|
||||
assertEquals("exectype = tez\nmapreduce.job.working.dir = /user/${user.name}\npig.exec.reducers.max = 8",
|
||||
job.environment().get("FLOCI_PIG_PROPERTIES"));
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ class EmrSparkStepsTest {
|
||||
private static final String HIVE_AND_SPARK = "[{\"Name\": \"Spark\"}, {\"Name\": \"hive\"}]";
|
||||
private static final String RELEASE = "emr-7.5.0";
|
||||
// The pig.properties lines Floci gives every Pig after its exectype, ahead of the cluster's.
|
||||
private static final String FLOCIS_PIG_LINES = "mapreduce.job.working.dir = /user/${user.name}\n"
|
||||
+ "pig.stats.notaskreport = true\nyarn.app.mapreduce.client.max-retries = 1";
|
||||
private static final String FLOCIS_PIG_LINES = "mapreduce.job.working.dir = /user/${user.name}";
|
||||
|
||||
private final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
@@ -199,7 +198,6 @@ class EmrSparkStepsTest {
|
||||
// Tez, as EMR's Pig 0.16.0 and later, from a working directory S3A takes as HDFS does, then tez-site's, then
|
||||
// pig-properties', a later line winning.
|
||||
assertEquals(String.join("\n", "exectype = tez", "mapreduce.job.working.dir = /user/${user.name}",
|
||||
"pig.stats.notaskreport = true", "yarn.app.mapreduce.client.max-retries = 1",
|
||||
"tez.grouping.max-size = 268435456",
|
||||
"tez.am.resource.memory.mb = 1536", "pig.exec.reducers.max = 8"),
|
||||
variables.get("FLOCI_PIG_PROPERTIES"));
|
||||
|
||||
@@ -1104,6 +1104,11 @@ class EmrServerlessSparkRunnerTest {
|
||||
assertTrue(site.contains("<name>yarn.app.mapreduce.am.resource.mb</name><value>1024</value>"), site);
|
||||
assertTrue(site.contains("<name>mapreduce.map.memory.mb</name><value>768</value>"), site);
|
||||
assertTrue(site.contains("<name>mapreduce.reduce.memory.mb</name><value>768</value>"), site);
|
||||
// The cluster's JobHistory server, which the job's client asks about it once its application master has ended.
|
||||
assertTrue(site.contains("<name>mapreduce.jobhistory.address</name>"
|
||||
+ "<value>ip-10-0-0-1.ec2.internal:10020</value>"), site);
|
||||
assertTrue(site.contains("<name>mapreduce.jobhistory.webapp.address</name>"
|
||||
+ "<value>ip-10-0-0-1.ec2.internal:19888</value>"), site);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -1265,7 +1270,10 @@ class EmrServerlessSparkRunnerTest {
|
||||
// A task's two would never match the one YARN's default scheduler grants.
|
||||
"hive.tez.cpu.vcores=1",
|
||||
"tez.runtime.intermediate-output.should-compress=false",
|
||||
"tez.runtime.intermediate-input.is-compressed=false")) {
|
||||
"tez.runtime.intermediate-input.is-compressed=false",
|
||||
// The cluster's JobHistory server, for a query whose hive.execution.engine is mr.
|
||||
"mapreduce.jobhistory.address=ip-10-0-0-1.ec2.internal:10020",
|
||||
"mapreduce.jobhistory.webapp.address=ip-10-0-0-1.ec2.internal:19888")) {
|
||||
assertTrue(arguments.contains(setting), setting + " in " + arguments);
|
||||
}
|
||||
assertTrue(arguments.contains("tez.cluster.additional.classpath.prefix=$PWD/*:/usr/lib/hive/lib/hive-exec.jar:"
|
||||
|
||||
Reference in new issue
Block a user