Example #1
0
  public static void main(String[] args)
      throws IOException, InterruptedException, ClassNotFoundException {
    if (args.length < 3) printUsage();

    // Graph job configuration
    HamaConfiguration conf = new HamaConfiguration();
    GraphJob ssspJob = new GraphJob(conf, SSSP.class);
    // Set the job name
    ssspJob.setJobName("Single Source Shortest Path");

    conf.set(START_VERTEX, args[0]);
    ssspJob.setInputPath(new Path(args[1]));
    ssspJob.setOutputPath(new Path(args[2]));

    if (args.length == 4) {
      ssspJob.setNumBspTask(Integer.parseInt(args[3]));
    }

    ssspJob.setVertexClass(ShortestPathVertex.class);
    ssspJob.setInputFormat(TextInputFormat.class);
    ssspJob.setInputKeyClass(LongWritable.class);
    ssspJob.setInputValueClass(Text.class);

    ssspJob.setPartitioner(HashPartitioner.class);
    ssspJob.setOutputFormat(TextOutputFormat.class);
    ssspJob.setVertexInputReaderClass(SSSPTextReader.class);
    ssspJob.setOutputKeyClass(IntWritable.class);
    ssspJob.setOutputValueClass(IntIntPairWritable.class);
    // Iterate until all the nodes have been reached.
    ssspJob.setMaxIteration(Integer.MAX_VALUE);

    ssspJob.setVertexIDClass(IntWritable.class);
    ssspJob.setVertexValueClass(IntIntPairWritable.class);
    ssspJob.setEdgeValueClass(IntWritable.class);

    long startTime = System.currentTimeMillis();
    if (ssspJob.waitForCompletion(true)) {
      System.out.println(
          "Job Finished in " + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
    }
  }
Example #2
0
  private static GraphJob createJob(String[] args, HamaConfiguration conf) throws IOException {
    //        conf.set("hama.graph.vertices.info", "org.apache.hama.graph.InMemoryVerticesInfo");

    conf.setInt("a", Integer.parseInt(args[0]));
    conf.setInt("b", Integer.parseInt(args[1]));

    GraphJob graphJob = new GraphJob(conf, Main.class);
    graphJob.setJobName("Propinquity Dynamics");
    graphJob.setVertexClass(PDVertex.class);
    graphJob.setJar("PropinquityDynamics-1.0-SNAPSHOT.jar");

    if (args.length == 5 && !args[4].isEmpty()) {
      graphJob.setNumBspTask(Integer.parseInt(args[4]));
    } else {
      graphJob.setNumBspTask(10);
    }

    graphJob.setInputPath(new Path(args[2]));
    graphJob.setOutputPath(new Path(args[3]));

    graphJob.setVertexIDClass(Text.class);
    graphJob.setVertexValueClass(MapWritable.class);
    graphJob.setEdgeValueClass(IntWritable.class);

    graphJob.setInputFormat(TextInputFormat.class);
    graphJob.setInputKeyClass(LongWritable.class);
    graphJob.setInputValueClass(Text.class);

    graphJob.setVertexInputReaderClass(PDVertexReader.class);
    graphJob.setPartitioner(HashPartitioner.class);

    graphJob.setVertexOutputWriterClass(PDVertexWriter.class);
    graphJob.setOutputFormat(TextOutputFormat.class);
    graphJob.setOutputKeyClass(Text.class);
    graphJob.setOutputValueClass(Text.class);

    return graphJob;
  }