Skip to content

Commit

Permalink
[FLINK-1234] Activate hadoop2 profile by default
Browse files Browse the repository at this point in the history
This closes apache#232
  • Loading branch information
rmetzger committed Nov 26, 2014
1 parent 74bc7dd commit 9656e83
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 114 deletions.
10 changes: 5 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ language: java
matrix:
include:
- jdk: "openjdk6"
env: PROFILE=
env: PROFILE="-Dhadoop.profile=1"
- jdk: "oraclejdk7"
env: PROFILE=
env: PROFILE="-Dhadoop.profile=1"
- jdk: "openjdk6"
env: PROFILE="-P!include-yarn -Dhadoop.profile=2 -Dhadoop.version=2.0.0-alpha"
env: PROFILE="-P!include-yarn -Dhadoop.version=2.0.0-alpha"
- jdk: "oraclejdk7"
env: PROFILE="-Dhadoop.profile=2 -Dhadoop.version=2.2.0"
env: PROFILE="-Dhadoop.version=2.2.0"
- jdk: "oraclejdk8"
env: PROFILE="-Dhadoop.profile=2 -Dhadoop.version=2.5.0"
env: PROFILE="-Dhadoop.version=2.5.1"


git:
Expand Down
33 changes: 19 additions & 14 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ The simplest way of building Flink is by running:

~~~bash
cd incubator-flink
mvn clean package -DskipTests
mvn clean install -DskipTests
~~~

This instructs Maven (`mvn`) to first remove all existing builds (`clean`) and then create a new Flink binary (`package`). The `-DskipTests` command prevents Maven from executing the unit tests.
This instructs Maven (`mvn`) to first remove all existing builds (`clean`) and then create a new Flink binary (`install`). The `-DskipTests` command prevents Maven from executing the unit tests.

[Read more](http:https://maven.apache.org/) about Apache Maven.



## Build Flink for a specific Hadoop Version

This section covers building Flink for a specific Hadoop version. Most users do not need to do this manually.
This section covers building Flink for a specific Hadoop version. Most users do not need to do this manually. The download page of Flink contains binary packages for common setups.

The problem is that Flink uses HDFS and YARN which are both dependencies from Apache Hadoop. There exist many different versions of Hadoop (from both the upstream project and the different Hadoop distributions). If a user is using a wrong combination of versions, exceptions like this one occur:

Expand All @@ -39,45 +41,48 @@ There are two main versions of Hadoop that we need to differentiate:
- Hadoop 2, with all versions starting with 2, like 2.2.0.
The main differentiation between Hadoop 1 and Hadoop 2 is the availability of Hadoop YARN (Hadoops cluster resource manager).

**To build Flink for Hadoop 2**, issue the following command:
By default, Flink is using the Hadoop 2 dependencies.

**To build Flink for Hadoop 1**, issue the following command:

~~~bash
mvn clean package -DskipTests -Dhadoop.profile=2
mvn clean install -DskipTests -Dhadoop.profile=1
~~~

The `-Dhadoop.profile=2` flag instructs Maven to build Flink with YARN support and the Hadoop 2 HDFS client.
The `-Dhadoop.profile=1` flag instructs Maven to build Flink for Hadoop 1. Note that the features included in Flink change when using a different Hadoop profile. In particular the support for YARN and the build-in HBase support are not available in Hadoop 1 builds.

Usually, this flag is sufficient for full support of Flink for Hadoop 2-versions.
However, you can also **specify a specific Hadoop version to build against**:

You can also **specify a specific Hadoop version to build against**:

~~~bash
mvn clean package -DskipTests -Dhadoop.profile=2 -Dhadoop.version=2.4.1
mvn clean install -DskipTests -Dhadoop.version=2.4.1
~~~


**To build Flink against a vendor specific Hadoop version**, issue the following command:

~~~bash
mvn clean package -DskipTests -Pvendor-repos -Dhadoop.profile=2 -Dhadoop.version=2.2.0-cdh5.0.0-beta-2
mvn clean install -DskipTests -Pvendor-repos -Dhadoop.version=2.2.0-cdh5.0.0-beta-2
~~~

The `-Pvendor-repos` activates a Maven [build profile](http:https://maven.apache.org/guides/introduction/introduction-to-profiles.html) that includes the repositories of popular Hadoop vendors such as Cloudera, Hortonworks, or MapR.

**Build Flink for `hadoop2` versions before 2.2.0**

Maven will automatically build Flink with its YARN client if the `-Dhadoop.profile=2` is set. But there were some changes in Hadoop versions before the 2.2.0 Hadoop release that are not supported by Flink's YARN client. Therefore, you can disable building the YARN client with the following string: `-P\!include-yarn`.
Maven will automatically build Flink with its YARN client. But there were some changes in Hadoop versions before the 2.2.0 Hadoop release that are not supported by Flink's YARN client. Therefore, you can disable building the YARN client with the following string: `-P\!include-yarn`.

So if you are building Flink for Hadoop `2.0.0-alpha`, use the following command:

~~~bash
-P\!include-yarn -Dhadoop.profile=2 -Dhadoop.version=2.0.0-alpha
-P\!include-yarn -Dhadoop.version=2.0.0-alpha
~~~

## Background

The builds with Maven are controlled by [properties](http:https://maven.apache.org/pom.html#Properties) and <a href="http:https://maven.apache.org/guides/introduction/introduction-to-profiles.html">build profiles</a>.
There are two profiles, one for hadoop1 and one for hadoop2. When the hadoop2 profile is enabled, the system will also build the YARN client.
The hadoop1 profile is used by default. To enable the hadoop2 profile, set `-Dhadoop.profile=2` when building.
There are two profiles, one for hadoop1 and one for hadoop2. When the hadoop2 profile is enabled (default), the system will also build the YARN client.

To enable the hadoop1 profile, set `-Dhadoop.profile=1` when building.
Depending on the profile, there are two Hadoop versions, set via properties. For "hadoop1", we use 1.2.1 by default, for "hadoop2" it is 2.2.0.

You can change these versions with the `hadoop-two.version` (or `hadoop-one.version`) property. For example `-Dhadoop-two.version=2.4.0`.
Expand Down
5 changes: 2 additions & 3 deletions flink-addons/flink-hadoop-compatibility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ under the License.
<id>hadoop-2</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
Expand Down
5 changes: 0 additions & 5 deletions flink-addons/flink-yarn/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ under the License.
<packaging>jar</packaging>

<dependencies>

<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-runtime</artifactId>
Expand Down Expand Up @@ -62,7 +61,6 @@ under the License.
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-client</artifactId>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
Expand Down Expand Up @@ -102,7 +100,6 @@ under the License.
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
Expand Down Expand Up @@ -142,7 +139,6 @@ under the License.
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
Expand Down Expand Up @@ -182,7 +178,6 @@ under the License.
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>${hadoop.version}</version>
<exclusions>
<exclusion>
<groupId>asm</groupId>
Expand Down
10 changes: 5 additions & 5 deletions flink-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ under the License.
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop1--><name>!hadoop.profile</name>
<!--hadoop1--><name>hadoop.profile</name><value>1</value>
</property>
</activation>
<modules>
Expand All @@ -59,8 +59,8 @@ under the License.
<id>hadoop-2</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<modules>
Expand All @@ -71,8 +71,8 @@ under the License.
<id>include-yarn</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<modules>
Expand Down
15 changes: 8 additions & 7 deletions flink-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ under the License.
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop1--><name>!hadoop.profile</name>
<!--hadoop1--><name>hadoop.profile</name><value>1</value>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-one.version}</hadoop.version>
</properties>
<dependencies>
<!-- No extra dependencies: flink-hbase is currently not compatible with Hadoop v1 -->
</dependencies>
Expand All @@ -145,8 +148,8 @@ under the License.
<id>include-yarn</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
Expand Down Expand Up @@ -214,8 +217,8 @@ under the License.
<id>hadoop-2</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
Expand Down Expand Up @@ -357,8 +360,6 @@ under the License.
</profile>
</profiles>



<build>
<plugins>
<plugin>
Expand Down
6 changes: 3 additions & 3 deletions flink-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ under the License.
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop1--><name>!hadoop.profile</name>
<!--hadoop1--><name>hadoop.profile</name><value>1</value>
</property>
</activation>
<dependencies>
Expand Down Expand Up @@ -227,8 +227,8 @@ under the License.
<id>hadoop-2</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<dependencies>
Expand Down
78 changes: 40 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ under the License.
<flink.reuseForks>true</flink.reuseForks>
<slf4j.version>1.7.7</slf4j.version>
<guava.version>17.0</guava.version>
<scala.version>2.10.4</scala.version>
<scala.binary.version>2.10</scala.binary.version>
<scala.macros.version>2.0.1</scala.macros.version>
<scala.version>2.10.4</scala.version>
<scala.binary.version>2.10</scala.binary.version>
<scala.macros.version>2.0.1</scala.macros.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -202,7 +202,7 @@ under the License.
<version>3.2.1</version>
</dependency>

<!-- Managed dependency required for HBase in flink-hbase -->
<!-- Managed dependency required for HBase in flink-hbase -->
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
Expand All @@ -222,6 +222,39 @@ under the License.
<artifactId>stax-api</artifactId>
<version>1.0.1</version>
</dependency>

<!-- "Old" stable Hadoop = MapReduce v1 -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
<!-- YARN -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-mapreduce-client-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-yarn-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand All @@ -231,54 +264,24 @@ under the License.
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop1--><name>!hadoop.profile</name>
<!--hadoop1--><name>hadoop.profile</name><value>1</value>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-one.version}</hadoop.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- "Old" stable Hadoop = MapReduce v1 -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>hadoop-2</id>
<activation>
<property>
<!-- Please do not remove the 'hadoop1' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>hadoop.profile</name><value>2</value>
<!-- Please do not remove the 'hadoop2' comment. See ./tools/generate_specific_pom.sh -->
<!--hadoop2--><name>!hadoop.profile</name>
</property>
</activation>
<properties>
<hadoop.version>${hadoop-two.version}</hadoop.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- YARN -->
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-hdfs</artifactId>
<version>${hadoop.version}</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>

<profile>
Expand Down Expand Up @@ -498,7 +501,6 @@ under the License.
</relocations>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.rat</groupId>
<artifactId>apache-rat-plugin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tools/change-version
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
# limitations under the License.
################################################################################

find .. -name 'pom.xml' -type f -exec sed -i 's#<version>0.7-incubating-SNAPSHOT</version>#<version>0.8-incubating-SNAPSHOT</version>#' {} \;
find .. -name 'pom.xml' -type f -exec sed -i 's#<version>0.8-hadoop2-incubating-SNAPSHOT</version>#<version>0.8-incubating-SNAPSHOT</version>#' {} \;
Loading

0 comments on commit 9656e83

Please sign in to comment.