Package org.apache.giraph.job

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


      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

      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

        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

      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

    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

    // 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

    // additional configuration for Hive
    adjustConfigurationForHive();

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

    setupHiveInputs(giraphConf);
    setupHiveOutput(giraphConf);

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

    logOptions(giraphConf);

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

    conf.setVertexClass(SimpleMutateGraphVertex.class);
    conf.setVertexInputFormatClass(SimplePageRankVertexInputFormat.class);
    conf.setVertexOutputFormatClass(SimplePageRankVertexOutputFormat.class);
    conf.setWorkerContextClass(
        SimpleMutateGraphVertex.SimpleMutateGraphVertexWorkerContext.class);
    GiraphJob job = prepareJob(getCallingMethodName(), conf,
        getTempPath(getCallingMethodName()));
    assertTrue(job.run(true));
  }
View Full Code Here

    GiraphConfiguration conf = new GiraphConfiguration();
    conf.setVertexClass(
        SimpleCheckpointVertex.SimpleCheckpointComputation.class);
    conf.setVertexInputFormatClass(SimpleSuperstepVertexInputFormat.class);
    conf.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class);
    GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath);

    // An unlikely impossible number of workers to achieve
    final int unlikelyWorkers = Short.MAX_VALUE;
    job.getConfiguration().setWorkerConfiguration(unlikelyWorkers,
        unlikelyWorkers,
        100.0f);
    // Only one poll attempt of one second to make failure faster
    job.getConfiguration().setMaxMasterSuperstepWaitMsecs(1000);
    job.getConfiguration().setEventWaitMsecs(1000);
    assertFalse(job.run(false));
  }
View Full Code Here

TOP

Related Classes of org.apache.giraph.job.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.