当前位置: 首页>>代码示例>>Java>>正文


Java GiraphConfiguration.get方法代码示例

本文整理汇总了Java中org.apache.giraph.conf.GiraphConfiguration.get方法的典型用法代码示例。如果您正苦于以下问题:Java GiraphConfiguration.get方法的具体用法?Java GiraphConfiguration.get怎么用?Java GiraphConfiguration.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.giraph.conf.GiraphConfiguration的用法示例。


在下文中一共展示了GiraphConfiguration.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import org.apache.giraph.conf.GiraphConfiguration; //导入方法依赖的package包/类
/**
 * Attempts to run the vertex internally in the current JVM, reading from and
 * writing to a temporary folder on local disk. Will start its own zookeeper
 * instance.
 *
 * @param conf           GiraphClasses specifying which types to use
 * @param checkpointsDir if set, will use this folder
 *                       for storing checkpoints.
 * @param tmpDir         file path for storing temporary files.
 * @return linewise output data, or null if job fails
 * @throws Exception if anything goes wrong
 */
public static Iterable<String> run(
        GiraphConfiguration conf,
        String checkpointsDir,
        File tmpDir) throws Exception {

    String ns = conf.get(HBaseGraphConfiguration.Keys.GRAPH_NAMESPACE);
    String prefix = conf.get(HBaseGraphConfiguration.Keys.GRAPH_TABLE_PREFIX);
    String tablePrefix = (ns != null ? ns + TableName.NAMESPACE_DELIM : "") + (prefix != null ? prefix : "");
    conf.set(Constants.EDGE_INPUT_TABLE, tablePrefix + Constants.EDGES);
    conf.set(Constants.VERTEX_INPUT_TABLE, tablePrefix + Constants.VERTICES);

    File outputDir = FileUtils.createTempDir(tmpDir, "output");
    File zkDir = FileUtils.createTempDir(tmpDir, "_bspZooKeeper");
    File zkMgrDir = FileUtils.createTempDir(tmpDir, "_defaultZkManagerDir");

    conf.setWorkerConfiguration(1, 1, 100.0f);
    GiraphConstants.SPLIT_MASTER_WORKER.set(conf, false);
    GiraphConstants.LOCAL_TEST_MODE.set(conf, true);

    conf.set(GiraphConstants.ZOOKEEPER_DIR, zkDir.toString());
    GiraphConstants.ZOOKEEPER_MANAGER_DIRECTORY.set(conf,
            zkMgrDir.toString());

    if (checkpointsDir == null) {
        checkpointsDir = FileUtils.createTempDir(
                tmpDir, "_checkpoints").toString();
    }
    GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, checkpointsDir);

    // Create and configure the job to run the vertex
    GiraphJob job = new GiraphJob(conf, conf.getComputationName());

    Job internalJob = job.getInternalJob();
    //FileOutputFormatUtil.setOutputPath(job.getInternalJob(),
    //        new Path(outputDir.toString()));
    internalJob.getConfiguration().set("mapred.output.dir", outputDir.toString());

    // Configure a local zookeeper instance
    ZookeeperConfig qpConfig = configLocalZooKeeper(zkDir);

    boolean success = runZooKeeperAndJob(qpConfig, job);
    if (!success) {
        return null;
    }

    File outFile = new File(outputDir, "part-m-00000");
    if (conf.hasVertexOutputFormat() && outFile.canRead()) {
        return Files.readLines(outFile, Charsets.UTF_8);
    } else {
        return ImmutableList.of();
    }

}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:66,代码来源:InternalHBaseVertexRunner.java


注:本文中的org.apache.giraph.conf.GiraphConfiguration.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。