Package org.apache.hama.bsp

Examples of org.apache.hama.bsp.ClusterStatus


    LOG.info("Client configuration start ..");

    HamaConfiguration clientConf = controller.getConfiguration();
    BSPJobClient jobClient = new BSPJobClient(clientConf);
    ClusterStatus cluster = jobClient.getClusterStatus(true);
    assertNotNull(cluster);
    assertTrue(cluster.getGroomServers() > 0);
    assertTrue(cluster.getMaxTasks() > 1);
    bsp.setNumBspTask(cluster.getMaxTasks());

    LOG.info("Client conf: "
        + clientConf.get("hadoop.rpc.socket.factory.class.default"));

    RunningJob rJob = jobClient.submitJob(bsp);
View Full Code Here


  public final void testWriteAndReadFields() throws IOException {
    DataOutputBuffer out = new DataOutputBuffer();
    DataInputBuffer in = new DataInputBuffer();

    ClusterStatus status1;
    Map<String, String> grooms = new HashMap<String, String>();

    for (int i = 0; i < 10; i++) {
      int num = rnd.nextInt();
      String groomName = "groom_" + num;
      String peerName = "peerhost:" + num;
      grooms.put(groomName, peerName);
    }

    int tasks = rnd.nextInt(100);
    int maxTasks = rnd.nextInt(100);
    BSPMaster.State state = BSPMaster.State.RUNNING;

    status1 = new ClusterStatus(grooms, tasks, maxTasks, state);
    status1.write(out);

    in.reset(out.getData(), out.getLength());

    ClusterStatus status2 = new ClusterStatus();
    status2.readFields(in);

    Map<String, String> grooms_s = new HashMap<String, String>(status1
        .getActiveGroomNames());
    Map<String, String> grooms_o = new HashMap<String, String>(status2
        .getActiveGroomNames());

    assertEquals(status1.getGroomServers(), status2.getGroomServers());

    assertTrue(grooms_s.entrySet().containsAll(grooms_o.entrySet()));
    assertTrue(grooms_o.entrySet().containsAll(grooms_s.entrySet()));

    assertEquals(status1.getTasks(), status2.getTasks());
    assertEquals(status1.getMaxTasks(), status2.getMaxTasks());
  }
View Full Code Here

        LOG.info("Set output path to default of pagerank/output!");
      }
    }

    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(true);
    StringBuilder sb = new StringBuilder();
    for (String peerName : cluster.getActiveGroomNames().values()) {
      conf.set(MASTER_TASK, peerName);
      sb.append(peerName + ";");
    }

    // put every peer into the configuration
    conf.set(ShortestPaths.BSP_PEERS, sb.toString());
    // leave the iterations on default
    conf.set("max.iterations", "0");

    if (conf.get("in.path") == null) {
      conf = PageRankBase
          .partitionExample(new Path(conf.get("out.path")), conf);
    } else {
      conf = PageRankBase
          .partitionTextFile(new Path(conf.get("in.path")), conf);
    }

    BSPJob job = new BSPJob(conf);
    job.setNumBspTask(cluster.getGroomServers());
    job.setBspClass(PageRank.class);
    job.setJarByClass(PageRank.class);
    job.setJobName("Pagerank");
    if (job.waitForCompletion(true)) {
      PageRankBase.printOutput(FileSystem.get(conf), conf);
View Full Code Here

    bsp.setJobName("Single Source Shortest Path");
    bsp.setBspClass(ShortestPaths.class);

    // Set the task size as a number of GroomServer
    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(true);
    StringBuilder sb = new StringBuilder();
    for (String peerName : cluster.getActiveGroomNames().values()) {
      conf.set(MASTER_TASK, peerName);
      sb.append(peerName);
      sb.append(";");
    }
    LOG.info("Master is: " + conf.get(MASTER_TASK));
    conf.set(BSP_PEERS, sb.toString());
    LOG.info("Starting data partitioning...");
    if (adjacencyList == null)
      conf = partition(adjacencyListPath, conf, skipPartitioning);
    else
      conf = partition(adjacencyList, conf);
    LOG.info("Finished!");

    bsp.setNumBspTask(cluster.getGroomServers());

    long startTime = System.currentTimeMillis();
    if (bsp.waitForCompletion(true)) {
      System.out.println("Job Finished in "
          + (double) (System.currentTimeMillis() - startTime) / 1000.0
View Full Code Here

    // Set the job name
    bsp.setJobName("Pi Estimation Example");
    bsp.setBspClass(MyEstimator.class);

    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(true);

    if (args.length > 0) {
      bsp.setNumBspTask(Integer.parseInt(args[0]));
    } else {
      // Set to maximum
      bsp.setNumBspTask(cluster.getGroomServers());
    }

    // Choose one as a master
    for (String peerName : cluster.getActiveGroomNames().values()) {
      conf.set(MASTER_TASK, peerName);
      break;
    }

    FileSystem fileSys = FileSystem.get(conf);
View Full Code Here

    bsp.setJobName("Serialize Printing");
    bsp.setBspClass(HelloBSP.class);

    // Set the task size as a number of GroomServer
    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(false);
    bsp.setNumBspTask(cluster.getGroomServers());

    FileSystem fileSys = FileSystem.get(conf);
    initTempDir(fileSys);

    if (bsp.waitForCompletion(true)) {
View Full Code Here

    bsp.setJobName("Random Communication Benchmark");
    bsp.setBspClass(RandBSP.class);

    // Set the task size as a number of GroomServer
    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(false);
    bsp.setNumBspTask(cluster.getGroomServers());

    long startTime = System.currentTimeMillis();
    bsp.waitForCompletion(true);
    System.out.println("Job Finished in "
        + (double) (System.currentTimeMillis() - startTime) / 1000.0
View Full Code Here

    bsp.setInputFormat(NullInputFormat.class);
    bsp.setOutputFormat(NullOutputFormat.class);

    // Set the task size as a number of GroomServer
    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(false);
    bsp.setNumBspTask(cluster.getMaxTasks());

    long startTime = System.currentTimeMillis();
    if (bsp.waitForCompletion(true)) {
      System.out.println("Job Finished in "
          + (System.currentTimeMillis() - startTime) / 1000.0 + " seconds");
View Full Code Here

    GraphJob bsp = new GraphJob(configuration, PageRank.class);
    bsp.setInputPath(new Path(INPUT));
    bsp.setOutputPath(new Path(OUTPUT));
    BSPJobClient jobClient = new BSPJobClient(configuration);
    configuration.setInt(Constants.ZOOKEEPER_SESSION_TIMEOUT, 6000);
    ClusterStatus cluster = jobClient.getClusterStatus(false);
    assertEquals(this.numOfGroom, cluster.getGroomServers());
    bsp.setNumBspTask(2);
    LOG.info("Client finishes execution job.");
    bsp.setJobName("Pagerank");
    bsp.setVertexClass(PageRank.PageRankVertex.class);
    // set the defaults
View Full Code Here

    bsp.setOutputValueClass(DoubleWritable.class);
    bsp.setOutputFormat(TextOutputFormat.class);
    FileOutputFormat.setOutputPath(bsp, TMP_OUTPUT);

    BSPJobClient jobClient = new BSPJobClient(conf);
    ClusterStatus cluster = jobClient.getClusterStatus(true);

    if (args.length > 0) {
      bsp.setNumBspTask(Integer.parseInt(args[0]));
    } else {
      // Set to maximum
      bsp.setNumBspTask(cluster.getMaxTasks());
    }

    long startTime = System.currentTimeMillis();
    if (bsp.waitForCompletion(true)) {
      printOutput(conf);
View Full Code Here

TOP

Related Classes of org.apache.hama.bsp.ClusterStatus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.