Examples of GiraphJob


Examples of org.apache.giraph.graph.GiraphJob

        if (getJobTracker() == null) {
            System.out.println(
                "testNotEnoughMapTasks: Ignore this test in local mode.");
            return;
        }
        GiraphJob job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        // An unlikely impossible number of workers to achieve
        final int unlikelyWorkers = Short.MAX_VALUE;
        job.setWorkerConfiguration(
            unlikelyWorkers, unlikelyWorkers, 100.0f);
        // Only one poll attempt of one second to make failure faster
        job.getConfiguration().setInt(GiraphJob.POLL_ATTEMPTS, 1);
        job.getConfiguration().setInt(GiraphJob.POLL_MSECS, 1);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        Path outputPath = new Path("/tmp/" + getCallingMethodName());
        removeAndSetOutput(job, outputPath);
        assertFalse(job.run(false));
    }
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

     * @throws ClassNotFoundException
     * @throws InterruptedException
     */
    public void testBspCheckpoint()
            throws IOException, InterruptedException, ClassNotFoundException {
        GiraphJob job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.getConfiguration().set(GiraphJob.CHECKPOINT_DIRECTORY,
                                   HDFS_CHECKPOINT_DIR);
        job.getConfiguration().setBoolean(
            GiraphJob.CLEANUP_CHECKPOINTS_AFTER_SUCCESS, false);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setWorkerContextClass(
            SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        Path outputPath = new Path("/tmp/" + getCallingMethodName());
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
        long fileLen = 0;
        long idSum = 0;
        if (getJobTracker() == null) {
            FileStatus fileStatus = getSinglePartFileStatus(job, outputPath);
            fileLen = fileStatus.getLen();
            idSum =
              SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.finalSum;
            System.out.println("testBspCheckpoint: idSum = " + idSum +
                               " fileLen = " + fileLen);
        }

        // Restart the test from superstep 2
        System.out.println(
            "testBspCheckpoint: Restarting from superstep 2" +
            " with checkpoint path = " + HDFS_CHECKPOINT_DIR);
        GiraphJob restartedJob = new GiraphJob(getCallingMethodName() +
                                               "Restarted");
        setupConfiguration(restartedJob);
        restartedJob.getConfiguration().set(GiraphJob.CHECKPOINT_DIRECTORY,
                                            HDFS_CHECKPOINT_DIR);
        restartedJob.getConfiguration().setLong(GiraphJob.RESTART_SUPERSTEP, 2);
        restartedJob.setVertexClass(SimpleCheckpointVertex.class);
        restartedJob.setWorkerContextClass(
          SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        restartedJob.setVertexInputFormatClass(
            SimpleSuperstepVertexInputFormat.class);
        restartedJob.setVertexOutputFormatClass(
            SimpleSuperstepVertexOutputFormat.class);
        outputPath = new Path("/tmp/" + getCallingMethodName() + "Restarted");
        removeAndSetOutput(restartedJob, outputPath);
        assertTrue(restartedJob.run(true));
        if (getJobTracker() == null) {
            FileStatus fileStatus = getSinglePartFileStatus(job, outputPath);
            fileLen = fileStatus.getLen();
            assertTrue(fileStatus.getLen() == fileLen);
            long idSumRestarted =
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

        return -1;
      }
    }

    int workers = Integer.parseInt(cmd.getOptionValue('w'));
    GiraphJob job = new GiraphJob(getConf(), "Giraph: " + vertexClassName);
    job.setVertexClass(Class.forName(vertexClassName));
    job.setVertexInputFormatClass(Class.forName(cmd.getOptionValue("if")));
    job.setVertexOutputFormatClass(Class.forName(cmd.getOptionValue("of")));

    if(cmd.hasOption("ip")) {
      FileInputFormat.addInputPath(job, new Path(cmd.getOptionValue("ip")));
    } else {
      LOG.info("No input path specified. Ensure your InputFormat does not " +
              "require one.");
    }

    if(cmd.hasOption("op")) {
      FileOutputFormat.setOutputPath(job, new Path(cmd.getOptionValue("op")));
    } else {
      LOG.info("No output path specified. Ensure your OutputFormat does not " +
              "require one.");
    }

    if (cmd.hasOption("c")) {
        job.setVertexCombinerClass(Class.forName(cmd.getOptionValue("c")));
    }

    if (cmd.hasOption("wc")) {
        job.setWorkerContextClass(Class.forName(cmd.getOptionValue("wc")));
    }

    if (cmd.hasOption("aw")) {
        job.setAggregatorWriterClass(Class.forName(cmd.getOptionValue("aw")));
    }

    job.setWorkerConfiguration(workers, workers, 100.0f);

    boolean isQuiet = !cmd.hasOption('q');

    return job.run(isQuiet) ? 0 : -1;
  }
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

    if (BenchmarkOption.HELP.optionTurnedOn(cmd)) {
      formatter.printHelp(getClass().getName(), options, true);
      return 0;
    }

    GiraphJob job = new GiraphJob(getConf(), getClass().getName());
    int workers = Integer.parseInt(BenchmarkOption.WORKERS.getOptionValue(cmd));
    job.getConfiguration().setWorkerConfiguration(workers, workers, 100.0f);
    prepareConfiguration(job.getConfiguration(), cmd);

    boolean isVerbose = false;
    if (BenchmarkOption.VERBOSE.optionTurnedOn(cmd)) {
      isVerbose = true;
    }
    if (job.run(isVerbose)) {
      return 0;
    } else {
      return -1;
    }
  }
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

      GiraphConstants.ZOOKEEPER_MANAGER_DIRECTORY.set(conf,
          zkMgrDir.toString());
      GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, checkpointsDir.toString());

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

      Job internalJob = job.getInternalJob();
      if (conf.hasVertexInputFormat()) {
        GiraphFileInputFormat.setVertexInputPath(internalJob.getConfiguration(),
            new Path(vertexInputFile.toString()));
      }
      if (conf.hasEdgeInputFormat()) {
        GiraphFileInputFormat.setEdgeInputPath(internalJob.getConfiguration(),
            new Path(edgeInputFile.toString()));
      }
      FileOutputFormat.setOutputPath(job.getInternalJob(),
                                     new Path(outputDir.toString()));

      // Configure a local zookeeper instance
      Properties zkProperties = configLocalZooKeeper(zkDir);

      QuorumPeerConfig qpConfig = new QuorumPeerConfig();
      qpConfig.parseProperties(zkProperties);

      // Create and run the zookeeper instance
      final InternalZooKeeper zookeeper = new InternalZooKeeper();
      final ServerConfig zkConfig = new ServerConfig();
      zkConfig.readFrom(qpConfig);

      ExecutorService executorService = Executors.newSingleThreadExecutor();
      executorService.execute(new Runnable() {
        @Override
        public void run() {
          try {
            zookeeper.runFromConfig(zkConfig);
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
        }
      });
      try {
        job.run(true);
      } finally {
        executorService.shutdown();
        zookeeper.end();
      }
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

      File checkpointsDir = FileUtils.createTempDir(tmpDir, "_checkpoints");

      conf.setVertexInputFormatClass(InMemoryVertexInputFormat.class);

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

      InMemoryVertexInputFormat.setGraph(graph);

      conf.setWorkerConfiguration(1, 1, 100.0f);
      GiraphConstants.SPLIT_MASTER_WORKER.set(conf, false);
      GiraphConstants.LOCAL_TEST_MODE.set(conf, true);
      conf.set(GiraphConstants.ZOOKEEPER_LIST, "localhost:" +
          String.valueOf(LOCAL_ZOOKEEPER_PORT));

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

      // Configure a local zookeeper instance
      Properties zkProperties = configLocalZooKeeper(zkDir);

      QuorumPeerConfig qpConfig = new QuorumPeerConfig();
      qpConfig.parseProperties(zkProperties);

      // Create and run the zookeeper instance
      final InternalZooKeeper zookeeper = new InternalZooKeeper();
      final ServerConfig zkConfig = new ServerConfig();
      zkConfig.readFrom(qpConfig);

      ExecutorService executorService = Executors.newSingleThreadExecutor();
      executorService.execute(new Runnable() {
        @Override
        public void run() {
          try {
            zookeeper.runFromConfig(zkConfig);
          } catch (IOException e) {
            throw new RuntimeException(e);
          }
        }
      });
      try {
        job.run(true);
      } finally {
        executorService.shutdown();
        zookeeper.end();
      }
      return graph;
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

        AccumuloInputFormat.setMockInstance(conf, INSTANCE_NAME);

        AccumuloOutputFormat.setOutputInfo(conf, USER, PASSWORD, true, null);
        AccumuloOutputFormat.setMockInstance(conf, INSTANCE_NAME);

        GiraphJob job = new GiraphJob(conf, getCallingMethodName());
        setupConfiguration(job);
        GiraphConfiguration giraphConf = job.getConfiguration();
        giraphConf.setVertexClass(EdgeNotification.class);
        giraphConf.setVertexInputFormatClass(AccumuloEdgeInputFormat.class);
        giraphConf.setVertexOutputFormatClass(AccumuloEdgeOutputFormat.class);

        HashSet<Pair<Text, Text>> columnsToFetch = new HashSet<Pair<Text,Text>>();
        columnsToFetch.add(new Pair<Text, Text>(FAMILY, CHILDREN));
        AccumuloInputFormat.fetchColumns(job.getConfiguration(), columnsToFetch);

        if(log.isInfoEnabled())
            log.info("Running edge notification job using Accumulo input");
        assertTrue(job.run(true));
        Scanner scanner = c.createScanner(TABLE_NAME, new Authorizations());
        scanner.setRange(new Range("0002", "0002"));
        scanner.fetchColumn(FAMILY, OUTPUT_FIELD);
        boolean foundColumn = false;
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

      ClassNotFoundException, InterruptedException {
    GiraphConfiguration conf = new GiraphConfiguration();
    conf.setVertexClass(AggregatorsTestVertex.class);
    conf.setVertexInputFormatClass(
        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
    GiraphJob job = prepareJob(getCallingMethodName(), conf);
    job.getConfiguration().setMasterComputeClass(
        AggregatorsTestVertex.AggregatorsTestMasterCompute.class);
    // test with aggregators split in a few requests
    job.getConfiguration().setInt(
        AggregatorUtils.MAX_BYTES_PER_AGGREGATOR_REQUEST, 50);
    assertTrue(job.run(true));
  }
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

    conf.setVertexClass(AggregatorsTestVertex.class);
    conf.setMasterComputeClass(
        AggregatorsTestVertex.AggregatorsTestMasterCompute.class);
    conf.setVertexInputFormatClass(
        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
    GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);

    GiraphConfiguration configuration = job.getConfiguration();
    GiraphConstants.CHECKPOINT_DIRECTORY.set(configuration, checkpointsDir.toString());
    GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(configuration, false);
    configuration.setCheckpointFrequency(4);

    assertTrue(job.run(true));

    // Restart the test from superstep 4
    System.out.println("testAggregatorsCheckpointing: Restarting from " +
        "superstep 4 with checkpoint path = " + checkpointsDir);
    outputPath = getTempPath(getCallingMethodName() + "Restarted");
    conf = new GiraphConfiguration();
    conf.setVertexClass(AggregatorsTestVertex.class);
    conf.setMasterComputeClass(
        AggregatorsTestVertex.AggregatorsTestMasterCompute.class);
    conf.setVertexInputFormatClass(
        SimplePageRankVertex.SimplePageRankVertexInputFormat.class);
    GiraphJob restartedJob = prepareJob(getCallingMethodName() + "Restarted",
        conf, outputPath);
    job.getConfiguration().setMasterComputeClass(
        SimpleCheckpointVertex.SimpleCheckpointVertexMasterCompute.class);
    GiraphConfiguration restartedJobConf = restartedJob.getConfiguration();
    GiraphConstants.CHECKPOINT_DIRECTORY.set(restartedJobConf,
        checkpointsDir.toString());
    restartedJobConf.setLong(GiraphConstants.RESTART_SUPERSTEP, 4);

    assertTrue(restartedJob.run(true));
  }
View Full Code Here

Examples of org.apache.giraph.job.GiraphJob

    // additional configuration for Hive
    adjustConfigurationForHive(getConf());

    // setup GiraphJob
    GiraphJob job = new GiraphJob(getConf(), getClass().getName());
    job.getConfiguration().setVertexClass(vertexClass);

    // setup input from Hive
    if (vertexInputFormatClass != null) {
      InputJobInfo vertexInputJobInfo = InputJobInfo.create(dbName,
          vertexInputTableName, vertexInputTableFilterExpr);
      GiraphHCatInputFormat.setVertexInput(job.getInternalJob(),
          vertexInputJobInfo);
      job.getConfiguration().setVertexInputFormatClass(vertexInputFormatClass);
    }
    if (edgeInputFormatClass != null) {
      InputJobInfo edgeInputJobInfo = InputJobInfo.create(dbName,
          edgeInputTableName, edgeInputTableFilterExpr);
      GiraphHCatInputFormat.setEdgeInput(job.getInternalJob(),
          edgeInputJobInfo);
      job.getConfiguration().setEdgeInputFormatClass(edgeInputFormatClass);
    }

    // setup output to Hive
    HCatOutputFormat.setOutput(job.getInternalJob(), OutputJobInfo.create(
        dbName, outputTableName, outputTablePartitionValues));
    HCatOutputFormat.setSchema(job.getInternalJob(),
        HCatOutputFormat.getTableSchema(job.getInternalJob()));
    if (skipOutput) {
      LOG.warn("run: Warning - Output will be skipped!");
    } else {
      job.getConfiguration().setVertexOutputFormatClass(
          vertexOutputFormatClass);
    }

    job.getConfiguration().setWorkerConfiguration(workers, workers, 100.0f);
    initGiraphJob(job);

    return job.run(isVerbose) ? 0 : -1;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.