Skip to content

Commit bfebf9e

Browse files
Minor Improvements
1 parent e03a82c commit bfebf9e

6 files changed

Lines changed: 125 additions & 87 deletions

File tree

tez-dag/src/main/java/org/apache/tez/dag/app/DAGAppMaster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2429,7 +2429,7 @@ public static void main(String[] args) {
24292429
Objects.requireNonNull(appSubmitTimeStr,
24302430
ApplicationConstants.APP_SUBMIT_TIME_ENV + " is null");
24312431

2432-
Configuration conf = new Configuration();
2432+
Configuration conf = new TezConfiguration();
24332433

24342434
AMExtensions amExtensions = getFrameworkService(conf).getAMExtensions();
24352435
DAGProtos.ConfigurationProto confProto = amExtensions.loadConfigurationProto();

tez-dist/src/docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ RUN chmod +x /entrypoint.sh
7979
USER tez
8080
WORKDIR $TEZ_HOME
8181

82-
# Expose AM RPC Ports
83-
EXPOSE 10001 10002 10003 8042 2181
82+
# Expose AM ports via -p flag in docker command
83+
# EXPOSE 10001 10002 10003 8042
8484

8585
ENTRYPOINT ["/entrypoint.sh"]

tez-dist/src/docker/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Tez AM Docker
2+
---
3+
4+
1. Building the docker image:
5+
```bash
6+
mvn clean install -DskipTests -Pdocker,tools
7+
```
8+
2. Install zookeeper in mac by
9+
```bash
10+
brew install zookeeper
11+
zkServer start
12+
```
13+
14+
3. Running the Tez AM container:
15+
```bash
16+
docker run \
17+
-p 10001:10001 -p 8042:8042 \
18+
--name tez-am \
19+
apache/tez-am:1.0.0-SNAPSHOT
20+
```
21+
22+
4. Debugging the Tez AM container:
23+
```bash
24+
docker run \
25+
-p 10001:10001 -p 8042:8042 -p 5005:5005 \
26+
-e TEZ_FRAMEWORK_MODE="STANDALONE_ZOOKEEPER" \
27+
-e JAVA_TOOL_OPTIONS='-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005' \
28+
--name tez-am \
29+
apache/tez-am:1.0.0-SNAPSHOT
30+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License");
2+
# you may not use this file except in compliance with the License.
3+
# You may obtain a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS,
9+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
# See the License for the specific language governing permissions and
11+
# limitations under the License.
12+
13+
appender.console.type = Console
14+
appender.console.name = console
15+
appender.console.target = SYSTEM_ERR
16+
appender.console.layout.type = PatternLayout
17+
appender.console.layout.pattern = %d{ISO8601} %5p [%t] %c{2}: %m%n
18+
19+
rootLogger.level = INFO
20+
rootLogger.appenderRef.console.ref = console

tez-dist/src/docker/conf/tez-site.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
<value>STANDALONE_ZOOKEEPER</value>
3434
</property>
3535

36+
<property>
37+
<name>tez.am.tez-ui.webservice.enable</name>
38+
<value>false</value>
39+
</property>
40+
3641
<property>
3742
<name>tez.am.zookeeper.quorum</name>
3843
<value>host.docker.internal:2181</value>

tez-dist/src/docker/entrypoint.sh

Lines changed: 67 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,36 @@
1818

1919
set -xeou pipefail
2020

21-
#######################
22-
# 1. PLUGIN EXTENSION #
23-
#######################
24-
# The directory /opt/tez/plugins is intended to be a volume mount point.
25-
# If custom jars are present, we add them to classpath.
21+
################################################
22+
# 1. Mocking DAGAppMaster#main() env variables #
23+
################################################
2624

27-
PLUGIN_DIR="/opt/tez/plugins"
28-
PLUGIN_CLASSPATH=""
25+
export CONTAINER_ID=${CONTAINER_ID:-"container_1700000000000_0001_01_000001"}
26+
export USER=${USER:-"tez"}
27+
export HADOOP_USER_NAME=${HADOOP_USER_NAME:-"tez"}
2928

30-
if [ -d "$PLUGIN_DIR" ]; then
31-
count=$(find "$PLUGIN_DIR" -maxdepth 1 -name "*.jar" 2>/dev/null | wc -l)
32-
if [ "$count" != "0" ]; then
33-
echo "--> Found $count custom jars in $PLUGIN_DIR. Adding to classpath..."
34-
PLUGIN_CLASSPATH="$PLUGIN_DIR/*"
35-
else
36-
echo "--> Plugin directory exists but contains no jars."
37-
fi
29+
export NM_HOST=${NM_HOST:-"localhost"}
30+
export NM_PORT=${NM_PORT:-"12345"}
31+
export NM_HTTP_PORT=${NM_HTTP_PORT:-"8042"}
32+
33+
export LOCAL_DIRS=${LOCAL_DIRS:-"/tmp"}
34+
export LOG_DIRS=${LOG_DIRS:-"/opt/tez/logs"}
35+
export APP_SUBMIT_TIME_ENV=${APP_SUBMIT_TIME_ENV:-$(($(date +%s) * 1000))}
36+
37+
export TEZ_AM_EXTERNAL_ID=${TEZ_AM_EXTERNAL_ID:-"tez-session-$(hostname)"}
38+
39+
if [ ! -f "tez-conf.pb" ]; then
40+
touch "tez-conf.pb"
41+
echo "--> Created dummy tez-conf.pb"
3842
fi
3943

40-
# =========================================================================
41-
# 2. CONFIGURATION HANDLING
42-
# =========================================================================
43-
# 1. Custom Conf Dir: If mounted, symlink it to use it directly.
44-
# 2. Templates: If not custom, use envsubst to generate configs from ENV.
44+
mkdir -p "$LOG_DIRS"
45+
46+
##########################
47+
# CONFIGURATION HANDLING #
48+
##########################
4549

46-
# Point HADOOP_CONF_DIR to TEZ_CONF_DIR, we need to populate it
47-
# with defaults from the Hadoop installation if they aren't provided by the user.
50+
# Symlink hadoop conf in tez conf dir
4851
if [ -d "$HADOOP_HOME/etc/hadoop" ]; then
4952
echo "--> Linking missing Hadoop configs to $TEZ_CONF_DIR..."
5053
for f in "$HADOOP_HOME/etc/hadoop"/*; do
@@ -63,76 +66,38 @@ fi
6366
if [ -n "${TEZ_CUSTOM_CONF_DIR:-}" ] && [ -d "$TEZ_CUSTOM_CONF_DIR" ]; then
6467
echo "--> Using custom configuration directory: $TEZ_CUSTOM_CONF_DIR"
6568
find "${TEZ_CUSTOM_CONF_DIR}" -type f -exec \
66-
ln -sfn {} "${TEZ_CONF_DIR}"/ \;
67-
else
68-
echo "--> Generating configuration from templates..."
69-
# Set defaults for template variables if not provided
70-
export TEZ_AM_RPC_PORT=${TEZ_AM_RPC_PORT:-10001}
71-
export TEZ_AM_RESOURCE_MEMORY=${TEZ_AM_RESOURCE_MEMORY:-1024}
72-
73-
# Process templates
69+
ln -sf {} "${TEZ_CONF_DIR}"/ \;
70+
71+
# Remove template keyword if it exist
7472
if [ -f "$TEZ_CONF_DIR/tez-site.xml.template" ]; then
7573
envsubst < "$TEZ_CONF_DIR/tez-site.xml.template" > "$TEZ_CONF_DIR/tez-site.xml"
7674
fi
7775
fi
7876

7977

80-
####################
81-
# Find TEZ DAG JAR #
82-
####################
83-
TEZ_DAG_JAR=$(find "$TEZ_HOME" -maxdepth 1 -name "tez-dag-*.jar" ! -name "*-tests.jar" | head -n 1)
84-
85-
if [ -z "$TEZ_DAG_JAR" ]; then
86-
echo "Error: Could not find tez-dag-*.jar in $TEZ_HOME"
87-
ls -l "$TEZ_HOME"
88-
exit 1
89-
fi
90-
91-
##############################################
92-
# YARN ENVIRONMENT SIMULATION () #
93-
##############################################
94-
export APP_SUBMIT_TIME_ENV=${APP_SUBMIT_TIME_ENV:-$(($(date +%s) * 1000))}
95-
96-
# 2. Container ID
97-
export CONTAINER_ID=${CONTAINER_ID:-"container_1700000000000_0001_01_000001"}
98-
99-
# 3. NodeManager Details
100-
export NM_HOST=${NM_HOST:-"localhost"}
101-
export NM_PORT=${NM_PORT:-"12345"}
102-
export NM_HTTP_PORT=${NM_HTTP_PORT:-"8042"}
103-
export LOCAL_DIRS=${LOCAL_DIRS:-"/tmp"}
104-
export LOG_DIRS=${LOG_DIRS:-"/opt/tez/logs"}
105-
106-
# 4. User Identity
107-
export HADOOP_USER_NAME=${HADOOP_USER_NAME:-"tez"}
108-
export USER=${HADOOP_USER_NAME}
109-
110-
export TEZ_AM_EXTERNAL_ID=${TEZ_AM_EXTERNAL_ID:-"tez-session-$(hostname)"}
111-
112-
echo "--> Mocked YARN Environment:"
113-
echo " APP_SUBMIT_TIME_ENV: $APP_SUBMIT_TIME_ENV"
114-
echo " CONTAINER_ID: $CONTAINER_ID"
115-
echo " USER: $USER"
116-
117-
mkdir -p "$LOG_DIRS"
118-
119-
if [ ! -f "tez-conf.pb" ]; then
120-
touch "tez-conf.pb"
121-
echo "--> Created dummy tez-conf.pb"
122-
fi
123-
12478
#############
125-
# EXECUTION #
79+
# CLASSPATH #
12680
#############
12781

128-
CLASSPATH="${TEZ_CONF_DIR}:${TEZ_HOME}/*:${TEZ_HOME}/lib/*"
82+
export HADOOP_USER_CLASSPATH_FIRST=true
83+
# Order is: conf -> plugins -> tez jars -> hadoop jars
84+
CLASSPATH="${TEZ_CONF_DIR}"
12985

130-
if [ -n "$PLUGIN_CLASSPATH" ]; then
131-
CLASSPATH="${CLASSPATH}:${PLUGIN_CLASSPATH}"
86+
# Custom Plugins
87+
# This allows mounting a volume at /opt/tez/plugins containing aux jars
88+
PLUGIN_DIR="/opt/tez/plugins"
89+
if [ -d "$PLUGIN_DIR" ]; then
90+
count=$(find "$PLUGIN_DIR" -maxdepth 1 -name "*.jar" 2>/dev/null | wc -l)
91+
if [ "$count" != "0" ]; then
92+
echo "--> Found $count plugin jars. Prepending to classpath."
93+
CLASSPATH="${CLASSPATH}:${PLUGIN_DIR}/*"
94+
fi
13295
fi
13396

134-
export HADOOP_USER_CLASSPATH_FIRST=true
97+
# Tez Jars
98+
CLASSPATH="${CLASSPATH}:${TEZ_HOME}/*:${TEZ_HOME}/lib/*"
13599

100+
# Hadoop Jars
136101
CLASSPATH="${CLASSPATH}:${HADOOP_HOME}/share/hadoop/common/*"
137102
CLASSPATH="${CLASSPATH}:${HADOOP_HOME}/share/hadoop/common/lib/*"
138103
CLASSPATH="${CLASSPATH}:${HADOOP_HOME}/share/hadoop/hdfs/*"
@@ -142,18 +107,36 @@ CLASSPATH="${CLASSPATH}:${HADOOP_HOME}/share/hadoop/yarn/lib/*"
142107
CLASSPATH="${CLASSPATH}:${HADOOP_HOME}/share/hadoop/mapreduce/*"
143108
CLASSPATH="${CLASSPATH}:${HADOOP_HOME}/share/hadoop/mapreduce/lib/*"
144109

145-
echo "--> Starting DAGAppMaster with JAR: $TEZ_DAG_JAR"
110+
#############
111+
# Execution #
112+
#############
113+
TEZ_DAG_JAR=$(find "$TEZ_HOME" -maxdepth 1 -name "tez-dag-*.jar" ! -name "*-tests.jar" | head -n 1)
114+
115+
if [ -z "$TEZ_DAG_JAR" ]; then
116+
echo "Error: Could not find tez-dag-*.jar in $TEZ_HOME"
117+
exit 1
118+
fi
119+
120+
echo "--> Starting DAGAppMaster..."
146121
echo "--> HADOOP_CONF_DIR: $HADOOP_CONF_DIR"
147122

148-
exec java \
149-
--add-opens java.base/java.lang=ALL-UNNAMED \
123+
# Check for Log4j2 Configuration
124+
JAVA_OPTS="${JAVA_OPTS:-"-Xmx1024m"}"
125+
LOG4J2_FILE="$TEZ_CONF_DIR/log4j2.properties"
126+
if [ -f "$LOG4J2_FILE" ]; then
127+
echo "--> [TEZ-AM] Found Log4j2 configuration: $LOG4J2_FILE"
128+
JAVA_OPTS="$JAVA_OPTS -Dlog4j.configurationFile=file:$LOG4J2_FILE"
129+
fi
130+
131+
JAVA_ADD_OPENS="--add-opens java.base/java.lang=ALL-UNNAMED \
150132
--add-opens java.base/java.util=ALL-UNNAMED \
151133
--add-opens java.base/java.lang.reflect=ALL-UNNAMED \
152134
--add-opens java.base/java.text=ALL-UNNAMED \
153135
--add-opens java.base/java.nio=ALL-UNNAMED \
154136
--add-opens java.base/sun.nio.ch=ALL-UNNAMED \
155-
--add-opens java.base/java.util.concurrent=ALL-UNNAMED \
156-
--add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED \
137+
--add-opens java.base/java.util.concurrent=ALL-UNNAMED"
138+
139+
exec java $JAVA_OPTS $JAVA_ADD_OPENS \
157140
-Duser.name="$HADOOP_USER_NAME" \
158141
-Djava.library.path="$HADOOP_HOME/lib/native" \
159142
-Dhadoop.home.dir="$HADOOP_HOME" \

0 commit comments

Comments
 (0)