Package org.apache.giraph.graph

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


     * @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

        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

TOP

Related Classes of org.apache.giraph.graph.GiraphJob

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.