首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从简单的java程序调用Giraph作业

从简单的java程序调用Giraph作业
EN

Stack Overflow用户
提问于 2018-01-26 00:05:23
回答 1查看 108关注 0票数 0

我是Giraph和Hadoop Yarn的新手。通过Giraph的quick start,我可以从命令行运行jar build from source的示例作业。

我想从简单的java程序运行作业。这个问题的灵感来自于之前类似的MapReduce job question。寻找java依赖项的类似答案,这将是需要的。

我有纱线设置在本地-需要有一种方式,从java程序馈送作业。

很明显:https://giraph.apache.org/apidocs/org/apache/giraph/job/GiraphJob.html肯定有办法做到这一点--但我发现很难找到Yarn的例子。

EN

回答 1

Stack Overflow用户

发布于 2018-01-31 22:57:05

在GiraphRunner的源代码中找到了这样做的方法:

代码语言:javascript
复制
@Test
public void testPageRank() throws IOException, ClassNotFoundException, InterruptedException {

    GiraphConfiguration giraphConf = new GiraphConfiguration(getConf());
    giraphConf.setWorkerConfiguration(1,1,100);
    GiraphConstants.SPLIT_MASTER_WORKER.set(giraphConf, false);

    giraphConf.setVertexInputFormatClass(JsonLongDoubleFloatDoubleVertexInputFormat.class);
    GiraphFileInputFormat.setVertexInputPath(giraphConf,
                                             new Path("/input/tiny-graph.txt"));
    giraphConf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class);

    giraphConf.setComputationClass(PageRankComputation.class);

    GiraphJob giraphJob = new GiraphJob(giraphConf, "page-rank");       

    FileOutputFormat.setOutputPath(giraphJob.getInternalJob(),
                                   new Path("/output/page-rank2"));
    giraphJob.run(true);
}

private Configuration getConf() {
    Configuration conf = new Configuration();
    conf.set("fs.defaultFS", "hdfs://localhost:9000");

    conf.set("yarn.resourcemanager.address", "localhost:8032");
    conf.set("yarn.resourcemanager.hostname", "localhost");

    // framework is now "yarn", should be defined like this in mapred-site.xm
    conf.set("mapreduce.framework.name", "yarn");
    return conf;
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48447198

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档