org.apache.giraph
Class BspCase

java.lang.Object
  extended by org.apache.giraph.BspCase
All Implemented Interfaces:
org.apache.zookeeper.Watcher
Direct Known Subclasses:
TestAggregatorsHandling, TestAutoCheckpoint, TestBspBasic, TestComputationState, TestEdgeInput, TestFilters, TestGraphPartitioner, TestJsonBase64Format, TestManualCheckpoint, TestMaxSuperstep, TestMutateGraph, TestNotEnoughMapTasks, TestPageRank

public class BspCase
extends Object
implements org.apache.zookeeper.Watcher

Extended TestCase for making setting up Bsp testing.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.apache.zookeeper.Watcher
org.apache.zookeeper.Watcher.Event
 
Field Summary
static String READER_VERTICES
           
 
Constructor Summary
BspCase(String testName)
          Create the test case
 
Method Summary
static String getCallingMethodName()
           
 int getNumResults(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path outputPath)
          Read all parts- files in the output and count their lines.
 int getNumWorkers()
          Get the number of workers used in the BSP application
static org.apache.hadoop.fs.FileStatus getSinglePartFileStatus(org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.Path partDirPath)
          Get the single part file status and make sure there is only one part
protected  org.apache.hadoop.fs.Path getTempPath(String name)
          Create a temporary path
 String getZooKeeperList()
          Get the ZooKeeper list
protected  GiraphJob prepareJob(String name, GiraphConfiguration conf)
          Prepare a GiraphJob for test purposes
protected  GiraphJob prepareJob(String name, GiraphConfiguration conf, org.apache.hadoop.fs.Path outputPath)
          Prepare a GiraphJob for test purposes
 void process(org.apache.zookeeper.WatchedEvent event)
           
static void removeAndSetOutput(GiraphJob job, org.apache.hadoop.fs.Path outputPath)
          Helper method to remove an old output directory if it exists, and set the output path for any VertexOutputFormat that uses FileOutputFormat.
 boolean runningInDistributedMode()
          Are the tests executed on a real hadoop instance?
 void setUp()
           
 org.apache.hadoop.conf.Configuration setupConfiguration(GiraphJob job)
          Adjust the configuration to the basic test case
 void tearDown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READER_VERTICES

public static final String READER_VERTICES
See Also:
Constant Field Values
Constructor Detail

BspCase

public BspCase(String testName)
Create the test case

Parameters:
testName - name of the test case
Method Detail

setupConfiguration

public final org.apache.hadoop.conf.Configuration setupConfiguration(GiraphJob job)
                                                              throws IOException
Adjust the configuration to the basic test case

Throws:
IOException

getTempPath

protected org.apache.hadoop.fs.Path getTempPath(String name)
Create a temporary path

Parameters:
name - name of the file to create in the temporary folder
Returns:
newly created temporary path

prepareJob

protected GiraphJob prepareJob(String name,
                               GiraphConfiguration conf)
                        throws IOException
Prepare a GiraphJob for test purposes

Parameters:
name - identifying name for job
conf - GiraphConfiguration describing which classes to use
Returns:
GiraphJob configured for testing
Throws:
IOException - if anything goes wrong

prepareJob

protected GiraphJob prepareJob(String name,
                               GiraphConfiguration conf,
                               org.apache.hadoop.fs.Path outputPath)
                        throws IOException
Prepare a GiraphJob for test purposes

Parameters:
name - identifying name for job
conf - GiraphConfiguration describing which classes to use
outputPath - Where to right output to
Returns:
GiraphJob configured for testing
Throws:
IOException - if anything goes wrong

getNumWorkers

public int getNumWorkers()
Get the number of workers used in the BSP application

Returns:
number of workers

getZooKeeperList

public String getZooKeeperList()
Get the ZooKeeper list


runningInDistributedMode

public boolean runningInDistributedMode()
Are the tests executed on a real hadoop instance?

Returns:
whether we use a real hadoop instance or not

getSinglePartFileStatus

public static org.apache.hadoop.fs.FileStatus getSinglePartFileStatus(org.apache.hadoop.conf.Configuration conf,
                                                                      org.apache.hadoop.fs.Path partDirPath)
                                                               throws IOException
Get the single part file status and make sure there is only one part

Parameters:
conf - Configuration to get the file system from
partDirPath - Directory where the single part file should exist
Returns:
Single part file status
Throws:
IOException

getNumResults

public int getNumResults(org.apache.hadoop.conf.Configuration conf,
                         org.apache.hadoop.fs.Path outputPath)
                  throws IOException
Read all parts- files in the output and count their lines. This works only for textual output!

Parameters:
conf - Configuration
outputPath - Output path
Returns:
Number of output lines
Throws:
IOException

setUp

public void setUp()

tearDown

public void tearDown()
              throws IOException
Throws:
IOException

process

public void process(org.apache.zookeeper.WatchedEvent event)
Specified by:
process in interface org.apache.zookeeper.Watcher

removeAndSetOutput

public static void removeAndSetOutput(GiraphJob job,
                                      org.apache.hadoop.fs.Path outputPath)
                               throws IOException
Helper method to remove an old output directory if it exists, and set the output path for any VertexOutputFormat that uses FileOutputFormat.

Parameters:
job - Job to set the output path for
outputPath - Path to output
Throws:
IOException

getCallingMethodName

public static String getCallingMethodName()


Copyright © 2011-2013 The Apache Software Foundation. All Rights Reserved.