设为首页 收藏本站
查看: 483|回复: 0

[经验分享] Build Eclipse plug-in for Hadoop

[复制链接]

尚未签到

发表于 2015-7-14 10:44:50 | 显示全部楼层 |阅读模式
  Hadoop Eclipse plug-in (installed in Eclipse IDE or Spring Tool Suite) eases the experience of Map/Reduce on Hadoop. Hadoop distribution does not include Hadoop Eclipse plug-in jar, but includes source code of that plug-in.
In this post, we'll see all the steps to build Hadoop eclipse plug-in from source code and install that plug-in in Eclipse / Spring Tool Suite to access Hadoop Environment in "Map/Reduce" perspective of the IDE.



Tools and Technologies used in this article :

  •   Hadoop 1.2.0
  •   Ant
  •   Spring Tool Suite (STS) 3.2.0
  
  Navigate to /src/contrib/eclipse-plugin. Following highlighted files will be modified.

  
1. Try Ant Build
  Lets us first see, what happens if we try to build Hadoop Eclipse plug-in from the provided source code.
Terminal


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


static-217:hadoop srccodes$ cd  /Users/srccodes/hadoop/src/contrib/eclipse-plugin
static-217:eclipse-plugin srccodes$ ant jar
Buildfile: /Users/srccodes/hadoop/src/contrib/eclipse-plugin/build.xml

check-contrib:
      [echo] eclipse.home unset: skipping eclipse plugin

init:

ivy-download:
       [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar
       [get] To: /Users/srccodes/hadoop/ivy/ivy-2.1.0.jar
       [get] Not modified - so not downloaded

ivy-probe-antlib:

ivy-init-antlib:

ivy-init:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/  ::
[ivy:configure] :: loading settings :: file  = /Users/srccodes/hadoop/ivy/ivysettings.xml

ivy-resolve-common:

ivy-retrieve-common:
[ivy:cachepath] DEPRECATED: 'ivy.conf.file'  is deprecated, use 'ivy.settings.file'  instead
[ivy:cachepath] :: loading settings :: file  = /Users/srccodes/hadoop/ivy/ivysettings.xml

compile:

jar:

BUILD SUCCESSFUL
Total time: 2 seconds
  Above echo message indicates that eclipse.home is not set and build of the plugin is skipped.
  
2. Modify build.properties
  Open build.properties in a text editor and set eclipse.home with your Eclipse / STS installation directory. Also define version of different jars required by Hadoop Eclipse plug-in.
build.properties


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32


#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.


output.. = bin/
bin.includes = META-INF/,\
                plugin.xml,\
                resources/,\
                classes/,\
                classes/,\
                lib/

# set eclipse installation path
eclipse.home=/Users/srccodes/software/springsource/sts-3.2.0.RELEASE

# version of different jars required by Hadoop eclipse plugin
version=1.2.0
commons-cli.version=1.2
commons-configuration.version=1.6
commons-httpclient.version=3.0.1
commons-lang.version=2.4
jackson-core-asl.version=1.8.8
jackson-mapper-asl.version=1.8.8
  
3. Try Ant Build Once Again
  Now eclipse.home is set, but we are not done yet. To find out why, try ant build once again. This time we will get java compilation errors as shown below.
Terminal


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86


static-166:eclipse-plugin srccodes$ ant jar
Buildfile: /Users/srccodes/hadoop/src/contrib/eclipse-plugin/build.xml

check-contrib:

init:
      [echo] contrib: eclipse-plugin

init-contrib:

ivy-download:
       [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar
       [get] To: /Users/srccodes/hadoop/ivy/ivy-2.1.0.jar
       [get] Not modified - so not downloaded

ivy-probe-antlib:

ivy-init-antlib:

ivy-init:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/  ::
[ivy:configure] :: loading settings :: file  = /Users/srccodes/hadoop/ivy/ivysettings.xml

ivy-resolve-common:

ivy-retrieve-common:
[ivy:cachepath] DEPRECATED: 'ivy.conf.file'  is deprecated, use 'ivy.settings.file'  instead
[ivy:cachepath] :: loading settings :: file  = /Users/srccodes/hadoop/ivy/ivysettings.xml

compile:
      [echo] contrib: eclipse-plugin
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/build.xml:62: warning: 'includeantruntime'  was not set, defaulting to build.sysclasspath=last; set  to false  for  repeatable builds
     [javac] Compiling 45 source  files to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/classes
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSFolder.java:28: package org.apache.hadoop.fs does not exist
     [javac] import  org.apache.hadoop.fs.FileStatus;
     [javac]                            ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSFolder.java:29: package org.apache.hadoop.fs does not exist
     [javac] import  org.apache.hadoop.fs.Path;
     [javac]                            ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSPath.java:25: package org.apache.hadoop.hdfs does not exist
     [javac] import  org.apache.hadoop.hdfs.DistributedFileSystem;
     [javac]                              ^
                                                         :
                                                         :
                                                         :
                                                         :
     [javac]                                ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopServer.java:291: cannot find  symbol
     [javac] symbol  : class Configuration
     [javac] location: class org.apache.hadoop.eclipse.server.HadoopServer
     [javac]   public Configuration getConfiguration() {
     [javac]          ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/ConfProp.java:24: package org.apache.hadoop.conf does not exist
     [javac] import  org.apache.hadoop.conf.Configuration;
     [javac]                              ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopServer.java:468: cannot find  symbol
     [javac] symbol  : class FileSystem
     [javac] location: class org.apache.hadoop.eclipse.server.HadoopServer
     [javac]   public FileSystem getDFS() throws IOException {
     [javac]          ^
                                                         :
                                                         :
                                                         :
                                                         :

     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopJob.java:302: package Counters does not exist
     [javac]       Counters.Group group = counters.getGroup(groupName);
     [javac]               ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/server/HadoopJob.java:305: package Counters does not exist
     [javac]       for  (Counters.Counter counter : group) {
     [javac]                    ^
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/src/java/org/apache/hadoop/eclipse/dfs/DFSFile.java:74: cannot find  symbol
     [javac] symbol  : class FileStatus
     [javac] location: class org.apache.hadoop.eclipse.dfs.DFSFile
     [javac]       FileStatus fs = getDFS().getFileStatus(path);
     [javac]       ^
     [javac] Note: Some input files use or override a deprecated API.
     [javac] Note: Recompile with -Xlint:deprecation for  details.
     [javac] Note: Some input files use unchecked or unsafe operations.
     [javac] Note: Recompile with -Xlint:unchecked for  details.
     [javac] 100 errors

BUILD FAILED
/Users/srccodes/hadoop/src/contrib/eclipse-plugin/build.xml:62: Compile failed; see the compiler error output for  details.

Total time: 3 seconds
  
4. Modify build.xml
  Open build.xml and modify path (id="classpath") and target (name="jar") as highlighted below.
build.xml


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87








   

   
     
      
      
      
      
      
      
      
      

      
      
      
   

   
   
     
     
     
     
         
     
   

   
   
     
     
   

  
     
     
           
     
   

   
   
     
     
     
     
     
     
     
     
     
      
      
     
   


Note : Hadoop Eclipse Plug-in code is dependent on Hadoop jars. So it is required to add those in classpath of 'compile' target. Also we need to include jars required by the eclipse plugin in 'jar' target.  
5. Modify MANIFEST.MF
  Open MANIFEST.MF in text editor and modify Bundle-ClassPath as highlighted below to incorporate the changes made in build.xml.
META-INF/MANIFEST.MF


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34


Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: MapReduce Tools for  Eclipse
Bundle-SymbolicName: org.apache.hadoop.eclipse;singleton:=true
Bundle-Version: 0.18
Bundle-Activator: org.apache.hadoop.eclipse.Activator
Bundle-Localization: plugin
Require-Bundle: org.eclipse.ui,
  org.eclipse.core.runtime,
  org.eclipse.jdt.launching,
  org.eclipse.debug.core,
  org.eclipse.jdt,
  org.eclipse.jdt.core,
  org.eclipse.core.resources,
  org.eclipse.ui.ide,
  org.eclipse.jdt.ui,
  org.eclipse.debug.ui,
  org.eclipse.jdt.debug.ui,
  org.eclipse.core.expressions,
  org.eclipse.ui.cheatsheets,
  org.eclipse.ui.console,
  org.eclipse.ui.navigator,
  org.eclipse.core.filesystem,
  org.apache.commons.logging
Eclipse-LazyStart: true
Bundle-ClassPath: classes/,
  lib/hadoop-core.jar,
  lib/commons-cli-1.2.jar,
  lib/commons-configuration-1.6.jar,
  lib/jackson-core-asl-1.8.8.jar,
  lib/commons-httpclient-3.0.1.jar,
  lib/jackson-mapper-asl-1.8.8.jar,
  lib/commons-lang-2.4.jar
Bundle-Vendor: Apache Hadoop
  
6. Build Hadoop Eclipse Plug-in
  Execute ant jar or ant clean package. On successful build, Hadoop Eclipse Plug-in jar (hadoop-eclipse-plugin-1.2.0.jar) will be created inside /build/contrib/eclipse-plugin/
Terminal


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65


static-217:eclipse-plugin srccodes$ ant jar
Buildfile: /Users/srccodes/hadoop/src/contrib/eclipse-plugin/build.xml

check-contrib:

init:
      [echo] contrib: eclipse-plugin
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/classes
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/test
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/system
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/system/classes
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/examples
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/test/logs

init-contrib:

ivy-download:
       [get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.1.0/ivy-2.1.0.jar
       [get] To: /Users/srccodes/hadoop/ivy/ivy-2.1.0.jar
       [get] Not modified - so not downloaded

ivy-probe-antlib:

ivy-init-antlib:

ivy-init:
[ivy:configure] :: Ivy 2.1.0 - 20090925235825 :: http://ant.apache.org/ivy/  ::
[ivy:configure] :: loading settings :: file  = /Users/srccodes/hadoop/ivy/ivysettings.xml

ivy-resolve-common:

ivy-retrieve-common:
[ivy:cachepath] DEPRECATED: 'ivy.conf.file'  is deprecated, use 'ivy.settings.file'  instead
[ivy:cachepath] :: loading settings :: file  = /Users/srccodes/hadoop/ivy/ivysettings.xml

compile:
      [echo] contrib: eclipse-plugin
     [javac] /Users/srccodes/hadoop/src/contrib/eclipse-plugin/build.xml:64: warning: 'includeantruntime'  was not set, defaulting to build.sysclasspath=last; set  to false  for  repeatable builds
     [javac] Compiling 45 source  files to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/classes
     [javac] Note: Some input files use or override a deprecated API.
     [javac] Note: Recompile with -Xlint:deprecation for  details.
     [javac] Note: Some input files use unchecked or unsafe operations.
     [javac] Note: Recompile with -Xlint:unchecked for  details.

jar:
     [mkdir] Created dir: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/hadoop-core-1.2.0.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/hadoop-core.jar
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/lib/commons-cli-1.2.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/commons-cli-1.2.jar
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/lib/commons-configuration-1.6.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/commons-configuration-1.6.jar
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/lib/commons-httpclient-3.0.1.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/commons-httpclient-3.0.1.jar
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/lib/commons-lang-2.4.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/commons-lang-2.4.jar
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/lib/jackson-core-asl-1.8.8.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/jackson-core-asl-1.8.8.jar
      [copy] Copying 1 file  to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib
      [copy] Copying /Users/srccodes/hadoop/lib/jackson-mapper-asl-1.8.8.jar to /Users/srccodes/hadoop/build/contrib/eclipse-plugin/lib/jackson-mapper-asl-1.8.8.jar
       [jar] Building jar: /Users/srccodes/hadoop/build/contrib/eclipse-plugin/hadoop-eclipse-plugin-1.2.0.jar

BUILD SUCCESSFUL
Total time: 4 seconds
  
7. Install Hadoop Eclipse Plug-in
  Copy Hadoop Eclipse Plug-in jar (hadoop-eclipse-plugin-1.2.0.jar) and paste it to /plugins directory. Start / Restart (if already running) Eclipse / Spring Tool Suite IDE.
  
8. Check Hadoop Eclipse Plug-in
  Navigate Window --> Open Perspective --> Other and select Map/ReduceOpen perspective. You'll be able to seeMap/Reduce Locations window where New Hadoop Location can be added.



  Now, Eclipse environment for Hadoop is ready for you to explore.
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-86612-1-1.html 上篇帖子: 最近跑hadoop遇到的一些问题 下篇帖子: 【Java 学习笔记】 Hadoop学习笔记
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表