Skip to content

apache/spark

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

…path if active hadoop-provided

### What changes were proposed in this pull request?

This PR adds `log4j-1.2-api` and `log4j-slf4j2-impl` to classpath if active `hadoop-provided`.

### Why are the changes needed?

To fix log issue.

How to reproduce this issue:
1. Build Spark:
   ```
   ./dev/make-distribution.sh --name provided --tgz -Phive -Phive-thriftserver -Pyarn -Phadoop-provided
   tar -zxf spark-3.5.0-SNAPSHOT-bin-provided.tgz
   ```
2. Copy the following jars to spark-3.5.0-SNAPSHOT-bin-provided/jars:
   ```
   guava-14.0.1.jar
   hadoop-client-api-3.3.5.jar
   hadoop-client-runtime-3.3.5.jar
   hadoop-shaded-guava-1.1.1.jar
   hadoop-yarn-server-web-proxy-3.3.5.jar
   slf4j-api-2.0.7.jar
   ```
3. Add a new log4j2.properties to spark-3.5.0-SNAPSHOT-bin-provided/conf:
   ```
   rootLogger.level = info
   rootLogger.appenderRef.file.ref = File
   rootLogger.appenderRef.stderr.ref = console

   appender.console.type = Console
   appender.console.name = console
   appender.console.target = SYSTEM_ERR
   appender.console.layout.type = PatternLayout
   appender.console.layout.pattern = %d{yy/MM/dd HH:mm:ss,SSS} %p [%t] %c{2}:%L : %m%n

   appender.file.type = RollingFile
   appender.file.name = File
   appender.file.fileName = /tmp/spark/logs/spark.log
   appender.file.filePattern = /tmp/spark/logs/spark.%d{yyyyMMdd-HH}.log
   appender.file.append = true
   appender.file.layout.type = PatternLayout
   appender.file.layout.pattern = %d{yy/MM/dd HH:mm:ss,SSS} %p [%t] %c{2}:%L : %m%n
   appender.file.policies.type = Policies
   appender.file.policies.time.type = TimeBasedTriggeringPolicy
   appender.file.policies.time.interval = 1
   appender.file.policies.time.modulate = true
   appender.file.policies.size.type = SizeBasedTriggeringPolicy
   appender.file.policies.size.size = 256M
   appender.file.strategy.type = DefaultRolloverStrategy
   appender.file.strategy.max = 100
   ```
4. Start Spark thriftserver: `sbin/start-thriftserver.sh`.

5. The log file is empty: `cat /tmp/spark/logs/spark.log`.

6. Copy the following jars to spark-3.5.0-SNAPSHOT-bin-provided/jars:
   ```
   log4j-1.2-api-2.20.0.jar
   log4j-slf4j2-impl-2.20.0.jar
   ```
7. Restart Spark thriftserver: `sbin/start-thriftserver.sh`.

8. The log file is not empty: `cat /tmp/spark/logs/spark.log`.

This is because hadoop classpath does not contain these jars. So these jars are needed even if `hadoop-provided` is activated
![image](https://github.com/apache/spark/assets/5399861/d53ff28c-05d7-40d7-891f-069449315217)

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Manual test.

Closes #41195 from wangyum/SPARK-43534.

Lead-authored-by: Yuming Wang <wgyumg@gmail.com>
Co-authored-by: Yuming Wang <yumwang@ebay.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
5d03950

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time

Apache Spark

Spark is a unified analytics engine for large-scale data processing. It provides high-level APIs in Scala, Java, Python, and R, and an optimized engine that supports general computation graphs for data analysis. It also supports a rich set of higher-level tools including Spark SQL for SQL and DataFrames, pandas API on Spark for pandas workloads, MLlib for machine learning, GraphX for graph processing, and Structured Streaming for stream processing.

https://spark.apache.org/

GitHub Actions Build AppVeyor Build PySpark Coverage PyPI Downloads

Online Documentation

You can find the latest Spark documentation, including a programming guide, on the project web page. This README file only contains basic setup instructions.

Building Spark

Spark is built using Apache Maven. To build Spark and its example programs, run:

./build/mvn -DskipTests clean package

(You do not need to do this if you downloaded a pre-built package.)

More detailed documentation is available from the project site, at "Building Spark".

For general development tips, including info on developing Spark using an IDE, see "Useful Developer Tools".

Interactive Scala Shell

The easiest way to start using Spark is through the Scala shell:

./bin/spark-shell

Try the following command, which should return 1,000,000,000:

scala> spark.range(1000 * 1000 * 1000).count()

Interactive Python Shell

Alternatively, if you prefer Python, you can use the Python shell:

./bin/pyspark

And run the following command, which should also return 1,000,000,000:

>>> spark.range(1000 * 1000 * 1000).count()

Example Programs

Spark also comes with several sample programs in the examples directory. To run one of them, use ./bin/run-example <class> [params]. For example:

./bin/run-example SparkPi

will run the Pi example locally.

You can set the MASTER environment variable when running examples to submit examples to a cluster. This can be a mesos:// or spark:// URL, "yarn" to run on YARN, and "local" to run locally with one thread, or "local[N]" to run locally with N threads. You can also use an abbreviated class name if the class is in the examples package. For instance:

MASTER=spark://host:7077 ./bin/run-example SparkPi

Many of the example programs print usage help if no params are given.

Running Tests

Testing first requires building Spark. Once Spark is built, tests can be run using:

./dev/run-tests

Please see the guidance on how to run tests for a module, or individual tests.

There is also a Kubernetes integration test, see resource-managers/kubernetes/integration-tests/README.md

A Note About Hadoop Versions

Spark uses the Hadoop core library to talk to HDFS and other Hadoop-supported storage systems. Because the protocols have changed in different versions of Hadoop, you must build Spark against the same version that your cluster runs.

Please refer to the build documentation at "Specifying the Hadoop Version and Enabling YARN" for detailed guidance on building for a particular distribution of Hadoop, including building for particular Hive and Hive Thriftserver distributions.

Configuration

Please refer to the Configuration Guide in the online documentation for an overview on how to configure Spark.

Contributing

Please review the Contribution to Spark guide for information on how to get started contributing to the project.