Examples of GiraphJob


Examples of org.apache.giraph.graph.GiraphJob

            // write input data to disk
            writeLines(inputFile, data);

            // create and configure the job to run the vertex
            GiraphJob job = new GiraphJob(vertexClass.getName());
            job.setVertexClass(vertexClass);
            job.setVertexInputFormatClass(vertexInputFormatClass);
            job.setVertexOutputFormatClass(vertexOutputFormatClass);
           
            if (vertexCombinerClass != null) {
                job.setVertexCombinerClass(vertexCombinerClass);
            }

            job.setWorkerConfiguration(1, 1, 100.0f);
            Configuration conf = job.getConfiguration();
            conf.setBoolean(GiraphJob.SPLIT_MASTER_WORKER, false);
            conf.setBoolean(GiraphJob.LOCAL_TEST_MODE, true);
            conf.set(GiraphJob.ZOOKEEPER_LIST, "localhost:" +
                    String.valueOf(LOCAL_ZOOKEEPER_PORT));

            for (Map.Entry<String,String> param : params.entrySet()) {
                conf.set(param.getKey(), param.getValue());
            }

            FileInputFormat.addInputPath(job, new Path(inputFile.toString()));
            FileOutputFormat.setOutputPath(job, new Path(outputDir.toString()));

            // configure a local zookeeper instance
            Properties zkProperties = new Properties();
            zkProperties.setProperty("tickTime", "2000");
            zkProperties.setProperty("dataDir", zkDir.getAbsolutePath());
            zkProperties.setProperty("clientPort",
                    String.valueOf(LOCAL_ZOOKEEPER_PORT));
            zkProperties.setProperty("maxClientCnxns", "10000");
            zkProperties.setProperty("minSessionTimeout", "10000");
            zkProperties.setProperty("maxSessionTimeout", "100000");
            zkProperties.setProperty("initLimit", "10");
            zkProperties.setProperty("syncLimit", "5");
            zkProperties.setProperty("snapCount", "50000");

            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.graph.GiraphJob

     */
    public void testPartitioners()
            throws IOException, InterruptedException, ClassNotFoundException {
        final int correctLen = 123;

        GiraphJob job = new GiraphJob("testVertexBalancer");
        setupConfiguration(job);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setWorkerContextClass(
            SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        job.getConfiguration().set(
            PartitionBalancer.PARTITION_BALANCE_ALGORITHM,
            PartitionBalancer.VERTICES_BALANCE_ALGORITHM);
        Path outputPath = new Path("/tmp/testVertexBalancer");
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
        FileSystem hdfs = FileSystem.get(job.getConfiguration());
        if (getJobTracker() != null) {
            FileStatus [] fileStatusArr = hdfs.listStatus(outputPath);
            int totalLen = 0;
            for (FileStatus fileStatus : fileStatusArr) {
                if (fileStatus.getPath().toString().contains("/part-m-")) {
                    totalLen += fileStatus.getLen();
                }
            }
            assertTrue(totalLen == correctLen);
        }

        job = new GiraphJob("testHashPartitioner");
        setupConfiguration(job);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setWorkerContextClass(
            SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        outputPath = new Path("/tmp/testHashPartitioner");
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
        if (getJobTracker() != null) {
            FileStatus [] fileStatusArr = hdfs.listStatus(outputPath);
            int totalLen = 0;
            for (FileStatus fileStatus : fileStatusArr) {
                if (fileStatus.getPath().toString().contains("/part-m-")) {
                    totalLen += fileStatus.getLen();
                }
            }
            assertTrue(totalLen == correctLen);
        }

        job = new GiraphJob("testSuperstepHashPartitioner");
        setupConfiguration(job);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setWorkerContextClass(
            SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        job.setGraphPartitionerFactoryClass(
            SuperstepHashPartitionerFactory.class);
        outputPath = new Path("/tmp/testSuperstepHashPartitioner");
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
        if (getJobTracker() != null) {
            FileStatus [] fileStatusArr = hdfs.listStatus(outputPath);
            int totalLen = 0;
            for (FileStatus fileStatus : fileStatusArr) {
                if (fileStatus.getPath().toString().contains("/part-m-")) {
                    totalLen += fileStatus.getLen();
                }
            }
            assertTrue(totalLen == correctLen);
        }

        job = new GiraphJob("testHashRangePartitioner");
        setupConfiguration(job);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setWorkerContextClass(
            SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        job.setGraphPartitionerFactoryClass(
            HashRangePartitionerFactory.class);
        outputPath = new Path("/tmp/testHashRangePartitioner");
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
        if (getJobTracker() != null) {
            FileStatus [] fileStatusArr = hdfs.listStatus(outputPath);
            int totalLen = 0;
            for (FileStatus fileStatus : fileStatusArr) {
                if (fileStatus.getPath().toString().contains("/part-m-")) {
                    totalLen += fileStatus.getLen();
                }
            }
            assertTrue(totalLen == correctLen);
        }

        job = new GiraphJob("testReverseIdSuperstepHashPartitioner");
        setupConfiguration(job);
        job.setVertexClass(SimpleCheckpointVertex.class);
        job.setWorkerContextClass(
            SimpleCheckpointVertex.SimpleCheckpointVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
        job.setGraphPartitionerFactoryClass(
            SuperstepHashPartitionerFactory.class);
        job.getConfiguration().setBoolean(
            GeneratedVertexReader.REVERSE_ID_ORDER,
            true);
        outputPath = new Path("/tmp/testReverseIdSuperstepHashPartitioner");
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
        if (getJobTracker() != null) {
            FileStatus [] fileStatusArr = hdfs.listStatus(outputPath);
            int totalLen = 0;
            for (FileStatus fileStatus : fileStatusArr) {
                if (fileStatus.getPath().toString().contains("/part-m-")) {
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

    }

    @Override
    public void setUp() {
        try {
            job = new GiraphJob("TestEdgeArrayVertex");
        } catch (IOException e) {
            throw new RuntimeException("setUp: Failed", e);
        }
        job.setVertexClass(IFDLEdgeListVertex.class);
        job.getConfiguration().setClass(GiraphJob.VERTEX_INDEX_CLASS,
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

    public int run(String[] args) throws Exception {
        if (args.length != 2) {
            throw new IllegalArgumentException(
                "run: Must have 2 arguments <output path> <# of workers>");
        }
        GiraphJob job = new GiraphJob(getConf(), getClass().getName());
        job.setVertexClass(getClass());
        job.setVertexInputFormatClass(
            SimpleSuperstepVertexInputFormat.class);
        job.setWorkerContextClass(EmitterWorkerContext.class);
        Configuration conf = job.getConfiguration();
        conf.set(SimpleVertexWithWorkerContext.OUTPUTDIR, args[0]);
        job.setWorkerConfiguration(Integer.parseInt(args[1]),
                                   Integer.parseInt(args[1]),
                                   100.0f);
        if (job.run(true) == true) {
            return 0;
        } else {
            return -1;
        }
    }
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

     * @throws ClassNotFoundException
     * @throws InterruptedException
     */
    public void testContinue()
            throws IOException, InterruptedException, ClassNotFoundException {
        GiraphJob job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.setVertexClass(PageRankBenchmark.PageRankEdgeListVertex.class);
        job.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
        job.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
        job.getConfiguration().setLong(
            PseudoRandomVertexInputFormat.AGGREGATE_VERTICES, 101);
        job.getConfiguration().setLong(
            PseudoRandomVertexInputFormat.EDGES_PER_VERTEX, 2);
        job.getConfiguration().setInt(PageRankBenchmark.SUPERSTEP_COUNT, 2);
        Path outputPath = new Path("/tmp/" + getCallingMethodName());
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));

        job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.setVertexClass(PageRankBenchmark.PageRankEdgeListVertex.class);
        job.setVertexInputFormatClass(JsonBase64VertexInputFormat.class);
        job.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
        job.getConfiguration().setInt(PageRankBenchmark.SUPERSTEP_COUNT, 3);
        FileInputFormat.setInputPaths(job, outputPath);
        Path outputPath2 = new Path("/tmp/" + getCallingMethodName() + "2");
        removeAndSetOutput(job, outputPath2);
        assertTrue(job.run(true));

        FileStatus twoJobsFile = null;
        if (getJobTracker() == null) {
            twoJobsFile = getSinglePartFileStatus(job, outputPath);
        }

        job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.setVertexClass(PageRankBenchmark.PageRankEdgeListVertex.class);
        job.setVertexInputFormatClass(PseudoRandomVertexInputFormat.class);
        job.setVertexOutputFormatClass(JsonBase64VertexOutputFormat.class);
        job.getConfiguration().setLong(
            PseudoRandomVertexInputFormat.AGGREGATE_VERTICES, 101);
        job.getConfiguration().setLong(
            PseudoRandomVertexInputFormat.EDGES_PER_VERTEX, 2);
        job.getConfiguration().setInt(PageRankBenchmark.SUPERSTEP_COUNT, 5);
        Path outputPath3 = new Path("/tmp/" + getCallingMethodName() + "3");
        removeAndSetOutput(job, outputPath3);
        assertTrue(job.run(true));

        if (getJobTracker() == null) {
            FileStatus oneJobFile = getSinglePartFileStatus(job, outputPath3);
            assertTrue(twoJobsFile.getLen() == oneJobFile.getLen());
        }
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

     * @throws ClassNotFoundException
     * @throws InterruptedException
     */
    public void testMutateGraph()
            throws IOException, InterruptedException, ClassNotFoundException {
        GiraphJob job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.setVertexClass(SimpleMutateGraphVertex.class);
        job.setWorkerContextClass(
            SimpleMutateGraphVertex.SimpleMutateGraphVertexWorkerContext.class);
        job.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
        job.setVertexOutputFormatClass(SimplePageRankVertexOutputFormat.class);
        Path outputPath = new Path("/tmp/" + getCallingMethodName());
        removeAndSetOutput(job, outputPath);
        assertTrue(job.run(true));
    }
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

    public int run(String[] argArray) throws Exception {
        Preconditions.checkArgument(argArray.length == 4,
            "run: Must have 4 arguments <input path> <output path> " +
            "<source vertex id> <# of workers>");

        GiraphJob job = new GiraphJob(getConf(), getClass().getName());
        job.setVertexClass(getClass());
        job.setVertexInputFormatClass(
            SimpleShortestPathsVertexInputFormat.class);
        job.setVertexOutputFormatClass(
            SimpleShortestPathsVertexOutputFormat.class);
        FileInputFormat.addInputPath(job, new Path(argArray[0]));
        FileOutputFormat.setOutputPath(job, new Path(argArray[1]));
        job.getConfiguration().setLong(SimpleShortestPathsVertex.SOURCE_ID,
                                       Long.parseLong(argArray[2]));
        job.setWorkerConfiguration(Integer.parseInt(argArray[3]),
                                   Integer.parseInt(argArray[3]),
                                   100.0f);

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

Examples of org.apache.giraph.graph.GiraphJob

            throws InstantiationException, IllegalAccessException,
            IOException, InterruptedException, IllegalArgumentException,
        InvocationTargetException, SecurityException, NoSuchMethodException {
        System.out.println("testInstantiateVertex: java.class.path=" +
                           System.getProperty("java.class.path"));
        GiraphJob job = new GiraphJob(getCallingMethodName());
        job.setVertexClass(SimpleSuperstepVertex.class);
        job.setVertexInputFormatClass(
            SimpleSuperstepVertex.SimpleSuperstepVertexInputFormat.class);
        GraphState<LongWritable, IntWritable, FloatWritable, IntWritable> gs =
            new GraphState<LongWritable, IntWritable,
                           FloatWritable, IntWritable>();
        BasicVertex<LongWritable, IntWritable, FloatWritable, IntWritable> vertex =
            BspUtils.createVertex(job.getConfiguration());
        vertex.initialize(null, null, null, null);
        System.out.println("testInstantiateVertex: Got vertex " + vertex +
                           ", graphState" + gs);
        VertexInputFormat<LongWritable, IntWritable, FloatWritable, IntWritable>
            inputFormat = BspUtils.createVertexInputFormat(job.getConfiguration());
        List<InputSplit> splitArray =
            inputFormat.getSplits(
                new JobContext(new Configuration(), new JobID()), 1);
        ByteArrayOutputStream byteArrayOutputStream =
            new ByteArrayOutputStream();
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

        if (getJobTracker() != null) {
            System.out.println("testLocalJobRunnerConfig: Skipping for " +
                               "non-local");
            return;
        }
        GiraphJob job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.setWorkerConfiguration(5, 5, 100.0f);
        job.getConfiguration().setBoolean(GiraphJob.SPLIT_MASTER_WORKER, true);
        job.setVertexClass(SimpleSuperstepVertex.class);
        job.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
        try {
            job.run(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
        }

        job.getConfiguration().setBoolean(GiraphJob.SPLIT_MASTER_WORKER, false);
        try {
            job.run(true);
            assertTrue(false);
        } catch (IllegalArgumentException e) {
        }
        job.setWorkerConfiguration(1, 1, 100.0f);
        job.run(true);
    }
View Full Code Here

Examples of org.apache.giraph.graph.GiraphJob

        if (getJobTracker() == null) {
            System.out.println("testBspFail: not executed for local setup.");
            return;
        }

        GiraphJob job = new GiraphJob(getCallingMethodName());
        setupConfiguration(job);
        job.getConfiguration().setInt("mapred.map.max.attempts", 1);
        job.setVertexClass(SimpleFailVertex.class);
        job.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
        Path outputPath = new Path("/tmp/" + getCallingMethodName());
        removeAndSetOutput(job, outputPath);
        assertTrue(!job.run(true));
    }
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.