分享

Spring Yarn 例子及代码下载

pig2 2015-3-23 17:10:22 发表于 实操演练 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 2 33500
本帖最后由 pig2 于 2015-3-23 23:12 编辑
问题导读

1.Spring Yarn 有哪些例子?
2.如何找到Spring Yarn例子说明?
3.如何导入项目到IDE?






注意:
这个例子当前的配置适用 Spring Hadoop 2.0.0.M4 release。可以通过maven配置获取spring hadoop.当前支持Hadoop 2.2.0-alpha
  1. gradlew -Pdistro=hadoop20 clean build -x test
复制代码
下面子项目适用 Spring Hadoop 2.0或则更高版本

Yarn 例子

  • batch-amjob - 运行 Spring Batch job only 在 Application Master的例子
  • batch-files -   运行 Spring Batch partitioned带有    HDFS文件进程的例子
  • batch-partition -运行 Spring Batch partitioned job例子
  • custom-amservice - 使用 Spring Integration 作为客户端运行 Application Master 服务
  • kill-application - killing an applicatoin的例子
  • list-applications -列出已知 resource manager的应用程序列表
  • multi-context - 运行a spring application context在多个容器中的例子
  • simple-command - 运行 a command with containers的例子
  • restart-context -  custom failed container handling的例子


如何导入项目到IDE

每一个例子都可以导入Java IDE,可以使用eclipse或则SpringSource Tool Suite。在目录中可以下载这些项目
  1. gradlew eclipse
复制代码

如果你使用IDEA
  1. gradlew idea
复制代码


运行例子

对于每一个例子,都有自己的README 文件。README 文件都有简短的说明,可以复制和粘帖commands


环境要求

例子依赖的库,并不是默认的hadoop classpath 。这些依赖在构建的过程中被搜集在一起。
例如:
构建 yarn-examples-simple-command项目
  1. gradlew :yarn-examples-common:yarn-examples-simple-command:build -x test
复制代码


项目文件被搜集,在simple-command/build/libs 下和在simple-command/build/dependency-libs的依赖

每个例子都有自己的hdfs路径下的jar文件

  1. [root@centos hadoop]# hadoop/bin/hdfs dfs -ls /lib
  2. /lib/aopalliance-1.0.jar
  3. /lib/jackson-annotations-2.1.4.jar
  4. /lib/jackson-core-2.1.4.jar
  5. /lib/jackson-databind-2.1.4.jar
  6. /lib/spring-aop-3.1.3.RELEASE.jar
  7. /lib/spring-asm-3.1.3.RELEASE.jar
  8. /lib/spring-batch-core-2.1.9.RELEASE.jar
  9. /lib/spring-batch-infrastructure-2.1.9.RELEASE.jar
  10. /lib/spring-beans-3.1.3.RELEASE.jar
  11. /lib/spring-context-3.1.3.RELEASE.jar
  12. /lib/spring-context-support-3.1.3.RELEASE.jar
  13. /lib/spring-core-3.1.3.RELEASE.jar
  14. /lib/spring-data-hadoop-2.0.0.M4-hadoop22.jar
  15. /lib/spring-data-hadoop-core-2.0.0.M4-hadoop22.jar
  16. /lib/spring-expression-3.1.3.RELEASE.jar
  17. /lib/spring-integration-core-2.2.3.RELEASE.jar
  18. /lib/spring-integration-ip-2.2.3.RELEASE.jar
  19. /lib/spring-integration-stream-2.2.3.RELEASE.jar
  20. /lib/spring-jdbc-3.1.3.RELEASE.jar
  21. /lib/spring-retry-1.0.2.RELEASE.jar
  22. /lib/spring-tx-3.1.3.RELEASE.jar
  23. /lib/spring-yarn-batch-2.0.0.M4-hadoop22.jar
  24. /lib/spring-yarn-core-2.0.0.M4-hadoop22.jar
  25. /lib/spring-yarn-integration-2.0.0.M4-hadoop22.jar
  26. /lib/yarn-examples-common-2.0.0.BUILD-SNAPSHOT.jar
  27. [root@centos hadoop]# hadoop/bin/hdfs dfs -ls /app/simple-command
  28. /app/simple-command/yarn-examples-simple-command-2.0.0.BUILD-SNAPSHOT-tests.jar
  29. /app/simple-command/yarn-examples-simple-command-2.0.0.BUILD-SNAPSHOT.jar
复制代码


JUnit 测试不依赖集群,但是需要配置hadoop环境。环境变量下面是必须存在的
  1. export PATH=$PATH:/usr/local/javas/java/bin
  2. export JAVA_HOME=/usr/local/javas/java
  3. export JRE_HOME=/usr/local/javas/java/jre
  4. export HADOOP_HOME=/usr/local/hadoops/hadoop
  5. export HADOOP_MAPRED_HOME=$HADOOP_HOME
  6. export HADOOP_COMMON_HOME=$HADOOP_HOME
  7. export HADOOP_HDFS_HOME=$HADOOP_HOME
  8. export HADOOP_YARN_HOME=$HADOOP_HOME
  9. export YARN_HOME=$HADOOP_HOME
  10. export HADOOP_CONF_DIR=$HADOOP_HOME/conf
  11. export YARN_CONF_DIR=$HADOOP_HOME/conf
复制代码


源码下载https://github.com/spring-projects/spring-hadoop-samples/blob/master/yarn/README.md






已有(2)人评论

跳转到指定楼层
tempmail 发表于 2015-3-23 22:38:13


很好很强大
回复

使用道具 举报

cochou 发表于 2015-3-24 12:48:11
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条