Apache Hadoop and Java 9 (Part 1)

Overview

At Apache: Big Data North America in May 2017, I'll show you how much the situation has changed since I talked about Apache Hadoop not currently supporting Java 9 and that's a lot of work.

Apache: Big Data Presentation

Presentation material at Hadoop source code reading in March 2017 (Japanese)

Through Hadoop compilation in Java 9

Let's compile it on your MacBook Pro (High Sierra). Try with the following version.

mbpaa:hadoop$ java -version
java version "9.0.1"
Java(TM) SE Runtime Environment (build 9.0.1+11)
Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

It's my first time to touch Java 9 after its official release.

Revert HADOOP-14986

Hmmm, I was falling like I had never seen before ...

mbpaa:hadoop$ mvn install -DskipTests
[INFO] Scanning for projects...

(snip)

[INFO] --- animal-sniffer-maven-plugin:1.16:check (signature-check) @ hadoop-annotations ---
[INFO] Checking unresolved references to org.codehaus.mojo.signature:java18:1.0
[ERROR] /Users/ajisaka/git/hadoop/hadoop-common-project/hadoop-annotations/src/main/java/org/apache/hadoop/classification/tools/RootDocProcessor.java:56: Undefined reference: com.sun.javadoc.RootDoc
[ERROR] /Users/ajisaka/git/hadoop/hadoop-common-project/hadoop-annotations/src/main/java/org/apache/hadoop/classification/tools/RootDocProcessor.java:104: Undefined reference: com.sun.javadoc.Doc
[ERROR] /Users/ajisaka/git/hadoop/hadoop-common-project/hadoop-annotations/src/main/java/org/apache/hadoop/classification/tools/RootDocProcessor.java:106: Undefined reference: com.sun.javadoc.Doc

Apparently, the animal-sniffer-maven-plugin added in HADOOP-14986. Enforce JDK limitations doesn't work in Java 9. I will try to revert at hand for the time being.

mbpaa:hadoop$ git revert b50def36970e0afa65bd3fd3f40d8c4f81119200

Apply HADOOP-12760

The next error is here.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hadoop-common: Compilation failure: Compilation failure:
[ERROR] /Users/ajisaka/git/hadoop/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java:[333,17] cannot find symbol
[ERROR] symbol:   class Cleaner
[ERROR] location: package sun.misc
[ERROR] /Users/ajisaka/git/hadoop/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoStreamUtils.java:[40,21] cannot find symbol
[ERROR] symbol:   class Cleaner
[ERROR] location: package sun.misc

This is a familiar error. HADOOP-12760. sun.misc.Cleaner has moved to a new location in OpenJDK 9 can be solved by applying the patch. Let's do it. dev-support / bin / smart-apply-patch is useful. I'm adding dev-support / bin to PATH.

mbpaa:hadoop$ smart-apply-patch HADOOP-12760
Processing: HADOOP-12760
HADOOP-12760 patch is being downloaded at Sat Dec  2 23:19:19 JST 2017 from
  https://issues.apache.org/jira/secure/attachment/12850964/HADOOP-12760.03.patch -> Downloaded
Applying the patch:
Sat Dec  2 23:19:20 JST 2017
cd /Users/ajisaka/git/hadoop
patch -p1 -E
patching file hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/crypto/CryptoStreamUtils.java
patching file hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/nativeio/NativeIO.java
Hunk #1 succeeded at 38 with fuzz 1 (offset 1 line).
Hunk #2 succeeded at 316 (offset 3 lines).
Hunk #3 succeeded at 330 (offset 3 lines).
patching file hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/CleanerUtil.java

Apply HDFS-11610

The next error is here.

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project hadoop-hdfs: Compilation failure: Compilation failure:
[ERROR] /Users/ajisaka/git/hadoop/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSClientFailover.java:[66,31] package sun.net.spi.nameservice does not exist

This is also a familiar error. Apply the patch HDFS-11610. Sun.net.spi.nameservice.NameService has moved to a new location.

mbpaa:hadoop$ smart-apply-patch HDFS-11610
Processing: HDFS-11610
HDFS-11610 patch is being downloaded at Sat Dec  2 23:27:05 JST 2017 from
  https://issues.apache.org/jira/secure/attachment/12879343/HDFS-11610.001.patch -> Downloaded
Applying the patch:
Sat Dec  2 23:27:06 JST 2017
cd /Users/ajisaka/git/hadoop
git apply --binary -v --stat --apply -p1 /tmp/yetus-30092.22999/patch
Hunk #1 succeeded at 600 (offset 5 lines).
Applied patch hadoop-hdfs-project/hadoop-hdfs/pom.xml cleanly.
 hadoop-hdfs-project/hadoop-hdfs/pom.xml |   19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

I was able to compile successfully.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 08:05 min
[INFO] Finished at: 2017-12-02T23:35:42+09:00
[INFO] Final Memory: 185M/616M
[INFO] ------------------------------------------------------------------------

Difference from before

Merge HADOOP-11875. Add a second copy of Hamlet without _ as a one-character identifier or some Maven plugins Thanks to the version upgrade, there are fewer steps to compile.

Also, thanks to the update on the Java side, it is no longer necessary to add the compile option --add-opens.

Future outlook

I would like to merge the above three fixes into the community as soon as possible. Also update the library. Log4J and JUnit are especially hard. Lately, I've been busy with work other than activities in the Apache Hadoop community and haven't had time. .. ..

Finally

For busy people, I've put a patch of these three on gist.

Next, I would like to run Apache Hadoop.

Recommended Posts

Apache Hadoop and Java 9 (Part 1)
Apache and tomcat
Java and JavaScript
XXE and Java
[Java] The confusing part of String and StringBuilder
JSON with Java and Jackson Part 2 XSS measures
Getters and setters (Java)
[Java] Thread and Runnable
Java true and false
[Java] String comparison and && and ||
Java --Serialization and Deserialization
[Java] Arguments and parameters
Studying Java ~ Part 8 ~ Cast
timedatectl and Java TimeZone
[Java] Branch and repeat
Class and instant part2
[Java] Variables and types
Apache Shiro Quickstart Part 2
java (classes and instances)
[Java] Overload and override
Study Java # 2 (\ mark and operator)
45 Java Performance Optimization Techniques (Part 1)
Java version 8 and later features
JSON in Java and Jackson Part 1 Return JSON from the server
Window aggregation of sensor data with Apache Flink and Java 8
[Java] Difference between == and equals
[Java] Stack area and static area
[Java] Generics classes and generics methods
Java programming (variables and data)
Java encryption and decryption PDF
What I learned in Java (Part 4) Conditional branching and repetition
Java class definition and instantiation
[Java] About String and StringBuilder
[Java] HashCode and equals overrides
☾ Java / Iterative statement and iterative control statement
Java methods and method overloads
java Generics T and? Difference
Advantages and disadvantages of Java
java (conditional branching and repetition)
About Java Packages and imports
[Java] Upload images and base64
C # and Java Overrides Story
Java abstract methods and classes
Java while and for statements
Java encapsulation and getters and setters
Solving with Ruby, Perl and Java AtCoder ABC 129 C (Part 1)
Java Beginner Escape Boot Camp Part 2 Understanding Java Classes and Encapsulation
What I have learned in Java (Part 1) Java development flow and overview
About Java static and non-static methods
Java Servlet / JSP Request Scope Part 1
I compared PHP and Java constructors
Java to learn with ramen [Part 1]
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
[Java] Difference between Hashmap and HashTable
Java variable declaration, initialization, and types
Java Excel Insertion and Image Extraction
Install Java and Tomcat with Ansible
AWS SDK for Java 1.11.x and 2.x
[Java] Basic types and instruction notes
Java release date and EOL summary