*/
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-")) {