Skip to content
This repository was archived by the owner on Jan 29, 2022. It is now read-only.

Commit cee1cc9

Browse files
author
Justin Lee
committed
simplifying build (HADOOP-160)
1 parent 78e43be commit cee1cc9

File tree

7 files changed

+42
-149
lines changed

7 files changed

+42
-149
lines changed

Diff for: build.gradle

+11-44
Original file line numberDiff line numberDiff line change
@@ -8,46 +8,12 @@ apply from: 'gradle/functions.gradle'
88

99
ext.configDir = new File(rootDir, 'config')
1010
ext.hadoopBinaries = "${System.getProperty('user.home')}/hadoop-binaries"
11-
ext.branchVersion = project.getProperties().get('clusterVersion', '2.4').toLowerCase()
12-
13-
ext.hiveVersionMap = [
14-
'1.0' : '0.10.0',
15-
'1.1' : '0.10.0',
16-
'cdh4': '0.10.0-cdh4.6.0',
17-
'cdh5': '0.12.0-cdh5.0.0'
18-
].withDefault {
19-
'0.12.0'
20-
}
21-
22-
ext.hadoopClusters = [
23-
'0.23': '0.23.10',
24-
'1.0' : '1.0.4',
25-
'1.1' : '1.1.2',
26-
'1.2' : '1.2.1',
27-
'2.2' : '2.2.0',
28-
'2.3' : '2.3.0',
29-
'2.4' : '2.4.0',
30-
'cdh4': '2.0.0-cdh4.6.0',
31-
'cdh5': '2.3.0-cdh5.0.0',
32-
].withDefault {
33-
throw new GradleException("Unknown hadoop version: ${it}")
34-
}
35-
36-
ext.pigVersionMap = [
37-
'cdh4': '0.11.0-cdh4.6.0',
38-
'cdh5': '0.12.0-cdh5.0.0'
39-
].withDefault {
40-
'0.13.0'
41-
}
42-
4311
ext.javaDriverVersion = '2.12.3'
44-
45-
ext.clusterVersion = hadoopClusters[branchVersion]
46-
ext.hiveVersion = hiveVersionMap[branchVersion]
47-
ext.pigVersion = pigVersionMap[branchVersion]
12+
ext.hiveVersion = '0.12.0'
13+
ext.pigVersion = '0.13.0'
4814
ext.hadoopVersion = '2.4.1'
4915

50-
ext.hadoopHome = "${hadoopBinaries}/hadoop-${clusterVersion}"
16+
ext.hadoopHome = "${hadoopBinaries}/hadoop-${hadoopVersion}"
5117
ext.hiveHome = "${hadoopBinaries}/hive-${hiveVersion}"
5218
ext.pigHome = "${hadoopBinaries}/pig-${pigVersion}"
5319
ext.dataHome = "${hadoopBinaries}/examples/data"
@@ -76,7 +42,11 @@ buildscript {
7642
}
7743

7844
task wrapper(type: Wrapper) {
79-
gradleVersion = '1.11'
45+
gradleVersion = '1.12'
46+
}
47+
48+
if(project.hasProperty("clusterVersion")) {
49+
println "The cluster version property has been obsoleted. See https://jira.mongodb.org/browse/HADOOP-160 for details."
8050
}
8151

8252
configure(subprojects) {
@@ -146,8 +116,8 @@ configure(subprojects) {
146116
tasks.withType(Test) {
147117
maxParallelForks = 1
148118
systemProperty 'project.version', project.version
149-
systemProperty 'cluster.version', hadoopClusters[branchVersion]
150-
systemProperty 'hadoop.version', branchVersion
119+
systemProperty 'cluster.version', hadoopVersion
120+
systemProperty 'hadoop.version', hadoopVersion
151121
systemProperty 'hive.version', hiveVersion
152122
systemProperty 'pig.version', pigVersion
153123
systemProperties << System.getProperties()
@@ -158,7 +128,7 @@ configure(subprojects) {
158128

159129
finalizedBy ':shutdownCluster'
160130
}
161-
131+
162132
test.dependsOn ':configureCluster'
163133
compileJava.dependsOn ':generateScripts'
164134
clean.dependsOn ':cleanHadoop'
@@ -433,9 +403,6 @@ def hadoop(jar, className, args) {
433403
}
434404
println "Executing hadoop job:\n ${line.join(' \\\n\t')}"
435405
def hadoopEnv = [:]
436-
if (clusterVersion.contains("cdh")) {
437-
hadoopEnv.MAPRED_DIR = 'share/hadoop/mapreduce2'
438-
}
439406
hadoopEnv.HADOOP_PREFIX=''
440407
exec() {
441408
environment << hadoopEnv

Diff for: core/src/test/java/com/mongodb/hadoop/testutils/BaseHadoopTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ public abstract class BaseHadoopTest {
4242

4343
public static final String HADOOP_HOME;
4444
public static final String PROJECT_VERSION = loadProperty("project.version", "1.4.0-SNAPSHOT");
45-
public static final String HADOOP_VERSION = loadProperty("hadoop.version", "2.4");
46-
public static final String CLUSTER_VERSION = loadProperty("cluster.version", "2.4.0");
45+
public static final String HADOOP_VERSION = loadProperty("hadoop.version", "2.4.1");
46+
@Deprecated
47+
public static final String CLUSTER_VERSION = loadProperty("cluster.version", HADOOP_VERSION);
4748
public static final String HIVE_VERSION = loadProperty("hive.version", "0.12.0");
4849

4950
public static final String HIVE_HOME;
@@ -75,7 +76,7 @@ public abstract class BaseHadoopTest {
7576
HADOOP_BINARIES = new File(String.format("%s/hadoop-binaries/", System.getProperty("user.home"))).getCanonicalPath();
7677
EXAMPLE_DATA_HOME = new File(HADOOP_BINARIES, "examples/data").getCanonicalPath();
7778

78-
HADOOP_HOME = new File(HADOOP_BINARIES, String.format("hadoop-%s/", CLUSTER_VERSION)).getCanonicalPath();
79+
HADOOP_HOME = new File(HADOOP_BINARIES, String.format("hadoop-%s/", HADOOP_VERSION)).getCanonicalPath();
7980
HIVE_HOME = new File(HADOOP_BINARIES, String.format("hive-%s/", HIVE_VERSION)).getCanonicalPath();
8081

8182
File current = new File(".").getCanonicalFile();

Diff for: examples/treasury_yield/src/test/java/com/mongodb/hadoop/StreamingJob.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
import java.util.TreeMap;
2626
import java.util.concurrent.TimeoutException;
2727

28+
import static com.mongodb.hadoop.testutils.BaseHadoopTest.HADOOP_HOME;
29+
import static com.mongodb.hadoop.testutils.BaseHadoopTest.HADOOP_VERSION;
2830
import static com.mongodb.hadoop.util.MongoConfigUtil.INPUT_URI;
2931
import static com.mongodb.hadoop.util.MongoConfigUtil.OUTPUT_URI;
3032
import static java.lang.String.format;
31-
import static com.mongodb.hadoop.testutils.BaseHadoopTest.HADOOP_HOME;
32-
import static com.mongodb.hadoop.testutils.BaseHadoopTest.CLUSTER_VERSION;
33-
import static com.mongodb.hadoop.testutils.BaseHadoopTest.HADOOP_VERSION;
3433

3534
public class StreamingJob {
3635
private static final String STREAMING_JAR;
@@ -77,11 +76,11 @@ public StreamingJob() {
7776
if (HADOOP_VERSION.startsWith("1.1")) {
7877
cmd.add(String.format("%s/contrib/streaming/hadoop-streaming-%s.jar",
7978
HADOOP_HOME,
80-
CLUSTER_VERSION));
79+
HADOOP_VERSION));
8180
} else {
8281
cmd.add(String.format("%s/share/hadoop/tools/lib/hadoop-streaming-%s.jar",
8382
HADOOP_HOME,
84-
CLUSTER_VERSION));
83+
HADOOP_VERSION));
8584
}
8685
// add("-libjars", STREAMING_JAR);
8786
add("-io", "mongodb");

Diff for: gradle/functions.gradle

+10-50
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ task generateScripts() << {
1212
filter ReplaceTokens, tokens: [
1313
PROJECT_HOME : project.rootDir.getAbsolutePath(),
1414

15-
HADOOP_HOME : "${hadoopBinaries}/hadoop-${clusterVersion}".toString(),
15+
HADOOP_HOME : "${hadoopBinaries}/hadoop-${hadoopVersion}".toString(),
1616
HIVE_HOME : "${hadoopBinaries}/hive-${hiveVersion}".toString(),
1717
PIG_HOME : "${hadoopBinaries}/pig-${pigVersion}".toString(),
1818

1919

20-
HADOOP_VERSION : clusterVersion.toString(),
20+
HADOOP_VERSION : hadoopVersion.toString(),
2121
HIVE_VERSION : hiveVersion.toString(),
2222

2323
HADOOP_BINARIES: hadoopBinaries.toString(),
24-
BIN : branchVersion.startsWith("1.") ? 'hadoop' : 'hdfs',
24+
BIN : hadoopVersion.startsWith("1.") ? 'hadoop' : 'hdfs',
2525
PYTHON_BIN : python
2626
]
2727
into "build/"
@@ -34,19 +34,8 @@ task generateScripts() << {
3434
task installHadoop() << {
3535
new File(hadoopHome).getParentFile().mkdirs()
3636

37-
def url
38-
switch (branchVersion) {
39-
case ("cdh4"):
40-
url = "http://archive.cloudera.com/cdh4/cdh/4/hadoop-${clusterVersion}.tar.gz"
41-
break
42-
case ("cdh5"):
43-
url = "http://archive.cloudera.com/cdh5/cdh/5/hadoop-${clusterVersion}.tar.gz"
44-
break
45-
default:
46-
url = "http://archive.apache.org/dist/hadoop/common/hadoop-${clusterVersion}/hadoop-${clusterVersion}.tar.gz"
47-
break
48-
}
49-
37+
def url = "http://archive.apache.org/dist/hadoop/common/hadoop-${hadoopVersion}/hadoop-${hadoopVersion}.tar.gz"
38+
5039
download(url, hadoopBinaries, hadoopHome)
5140
}
5241

@@ -85,50 +74,21 @@ def download(url, destination, target) {
8574
}
8675

8776
task installHive() << {
88-
def url
89-
switch (branchVersion) {
90-
case ("cdh4"):
91-
url = "http://archive.cloudera.com/cdh4/cdh/4/hive-${hiveVersion}.tar.gz"
92-
break
93-
case ("cdh5"):
94-
url = "http://archive.cloudera.com/cdh5/cdh/5/hive-${hiveVersion}.tar.gz"
95-
break
96-
default:
97-
url = "https://archive.apache.org/dist/hive/hive-${hiveVersion}/hive-${hiveVersion}.tar.gz"
98-
break
99-
}
77+
def url = "https://archive.apache.org/dist/hive/hive-${hiveVersion}/hive-${hiveVersion}.tar.gz"
10078

10179
download(url, hadoopBinaries, hiveHome)
10280

10381
}
10482

10583
task installPig() << {
106-
def url
107-
switch (branchVersion) {
108-
case ("cdh4"):
109-
url = "http://archive.cloudera.com/cdh4/cdh/4/pig-${pigVersion}.tar.gz"
110-
break
111-
case ("cdh5"):
112-
url = "http://archive.cloudera.com/cdh5/cdh/5/pig-${pigVersion}.tar.gz"
113-
break
114-
default:
115-
url = "https://archive.apache.org/dist/pig/pig-${pigVersion}/pig-${pigVersion}.tar.gz"
116-
break
117-
}
84+
def url = "https://archive.apache.org/dist/pig/pig-${pigVersion}/pig-${pigVersion}.tar.gz"
11885

11986
download(url, hadoopBinaries, pigHome)
12087
}
12188

12289
task copyFiles(dependsOn: [installHadoop, installHive, installPig]) << {
123-
def hadoopEtc
124-
def hadoopLib
125-
if (clusterVersion.startsWith("1")) {
126-
hadoopLib = "${hadoopHome}/lib"
127-
hadoopEtc = "${hadoopHome}/conf"
128-
} else {
129-
hadoopLib = "${hadoopHome}/share/hadoop/common"
130-
hadoopEtc = "${hadoopHome}/etc/hadoop"
131-
}
90+
def hadoopEtc = "${hadoopHome}/etc/hadoop"
91+
def hadoopLib = "${hadoopHome}/share/hadoop/common"
13292

13393
println "Updating mongo jars"
13494

@@ -149,7 +109,7 @@ def findJar(String proj, String filter) {
149109
}
150110

151111
task configureCluster(dependsOn: copyFiles) << {
152-
println "Configuring ${branchVersion} hadoop cluster"
112+
println "Configuring ${hadoopVersion} hadoop cluster"
153113
exec {
154114
commandLine 'build/hadoop.py'
155115
args 'start', '-format'

Diff for: gradle/wrapper/gradle-wrapper.jar

242 Bytes
Binary file not shown.

Diff for: gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Sun Jul 27 12:12:18 CEST 2014
1+
#Thu Aug 28 09:21:33 EDT 2014
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-1.12-bin.zip

Diff for: test.sh

+11-45
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,22 @@
22

33
alias g="./gradlew --daemon"
44

5-
VERSIONS=(0.23 1.0 1.1 2.2 2.3 2.4 cdh4 cdh5)
65
OPTS=test
7-
#VERSIONS=(0.23 cdh4 cdh5 2.2 2.3 2.4)
86

97
while [ "$1" ]
108
do
11-
if [[ " ${VERSIONS[*]} " == *" $1 "* ]]
12-
then
13-
HV=$1
14-
else
15-
case $1 in
16-
"examples")
17-
OPTS="historicalYield sensorData enronEmails"
18-
;;
19-
"all")
20-
HV="all"
21-
;;
22-
esac
23-
fi
9+
case $1 in
10+
"examples")
11+
OPTS="historicalYield sensorData enronEmails"
12+
;;
13+
"all")
14+
HV="all"
15+
;;
16+
esac
2417
shift
2518
done
2619

27-
echo Running \"$OPTS\" against \"${HV}\"
28-
29-
function choose() {
30-
if [ -z "${HV}" ]
31-
then
32-
echo Choose a hadoop version
33-
select HV in ${VERSIONS[@]}
34-
do
35-
break
36-
done
37-
else
38-
shift
39-
fi
40-
}
20+
echo Running \"$OPTS\"
4121

4222
function browser() {
4323
while [ "$1" ]
@@ -50,7 +30,7 @@ function browser() {
5030
function run() {
5131
#g clean jar testJar configureCluster test historicalYield sensorData enronEmails \
5232
#-PclusterVersion=${HV} 2>&1 | tee -a test-${HV}.out
53-
g clean jar testJar configureCluster $OPTS -PclusterVersion=${HV} --stacktrace 2>&1 | tee -a test-${HV}.out
33+
g clean jar testJar $OPTS --stacktrace 2>&1 | tee -a build/test.out
5434

5535

5636
for i in "*/build/reports/tests/index.html"
@@ -69,18 +49,4 @@ function run() {
6949
done
7050
}
7151

72-
if [ "$HV" == "all" ]
73-
then
74-
shift
75-
for HV in ${VERSIONS[@]}
76-
do
77-
> test-${HV}.out
78-
done
79-
for HV in ${VERSIONS[@]}
80-
do
81-
run $*
82-
done
83-
else
84-
choose
85-
run $*
86-
fi
52+
run

0 commit comments

Comments
 (0)