Updated Branches: refs/heads/trunk 24c7044ba -> db077ec20
http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java b/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java index 372c32f..53cdeab 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java +++ b/giraph-examples/src/test/java/org/apache/giraph/aggregators/TestAggregatorsHandling.java @@ -20,7 +20,6 @@ package org.apache.giraph.aggregators; import org.apache.giraph.BspCase; import org.apache.giraph.comm.aggregators.AggregatorUtils; -import org.apache.giraph.conf.GiraphClasses; import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; @@ -31,7 +30,6 @@ import org.apache.giraph.job.GiraphJob; import org.apache.giraph.master.MasterAggregatorHandler; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.DoubleWritable; -import org.apache.hadoop.io.FloatWritable; import org.apache.hadoop.io.LongWritable; import org.apache.hadoop.io.Writable; import org.apache.hadoop.util.Progressable; @@ -76,12 +74,11 @@ public class TestAggregatorsHandling extends BspCase { @Test public void testAggregatorsHandling() throws IOException, ClassNotFoundException, InterruptedException { - GiraphClasses<LongWritable, DoubleWritable, FloatWritable, DoubleWritable> - classes = new GiraphClasses(); - classes.setVertexClass(AggregatorsTestVertex.class); - classes.setVertexInputFormatClass( + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setVertexClass(AggregatorsTestVertex.class); + conf.setVertexInputFormatClass( SimplePageRankVertex.SimplePageRankVertexInputFormat.class); - GiraphJob job = prepareJob(getCallingMethodName(), classes); + GiraphJob job = prepareJob(getCallingMethodName(), conf); job.getConfiguration().setMasterComputeClass( AggregatorsTestVertex.AggregatorsTestMasterCompute.class); // test with aggregators split in a few requests @@ -157,19 +154,18 @@ public class TestAggregatorsHandling extends BspCase { IOException, InterruptedException { Path checkpointsDir = getTempPath("checkPointsForTesting"); Path outputPath = getTempPath(getCallingMethodName()); - GiraphClasses<LongWritable, DoubleWritable, FloatWritable, DoubleWritable> - classes = new GiraphClasses(); - classes.setVertexClass(AggregatorsTestVertex.class); - classes.setMasterComputeClass( + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setVertexClass(AggregatorsTestVertex.class); + conf.setMasterComputeClass( AggregatorsTestVertex.AggregatorsTestMasterCompute.class); - classes.setVertexInputFormatClass( + conf.setVertexInputFormatClass( SimplePageRankVertex.SimplePageRankVertexInputFormat.class); - GiraphJob job = prepareJob(getCallingMethodName(), classes, outputPath); + GiraphJob job = prepareJob(getCallingMethodName(), conf, outputPath); - GiraphConfiguration conf = job.getConfiguration(); - GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, checkpointsDir.toString()); - GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(conf, false); - conf.setCheckpointFrequency(4); + 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)); @@ -177,14 +173,14 @@ public class TestAggregatorsHandling extends BspCase { System.out.println("testAggregatorsCheckpointing: Restarting from " + "superstep 4 with checkpoint path = " + checkpointsDir); outputPath = getTempPath(getCallingMethodName() + "Restarted"); - classes = new GiraphClasses(); - classes.setVertexClass(AggregatorsTestVertex.class); - classes.setMasterComputeClass( + conf = new GiraphConfiguration(); + conf.setVertexClass(AggregatorsTestVertex.class); + conf.setMasterComputeClass( AggregatorsTestVertex.AggregatorsTestMasterCompute.class); - classes.setVertexInputFormatClass( + conf.setVertexInputFormatClass( SimplePageRankVertex.SimplePageRankVertexInputFormat.class); GiraphJob restartedJob = prepareJob(getCallingMethodName() + "Restarted", - classes, outputPath); + conf, outputPath); job.getConfiguration().setMasterComputeClass( SimpleCheckpointVertex.SimpleCheckpointVertexMasterCompute.class); GiraphConfiguration restartedJobConf = restartedJob.getConfiguration(); http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java index 55ca60c..5d3fae1 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTest.java @@ -18,20 +18,19 @@ package org.apache.giraph.examples; -import com.google.common.base.Splitter; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.Iterables; -import com.google.common.collect.SetMultimap; import org.apache.giraph.combiner.MinimumIntCombiner; -import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; +import org.apache.giraph.edge.ByteArrayEdges; import org.apache.giraph.io.formats.IdWithValueTextOutputFormat; import org.apache.giraph.io.formats.IntIntNullTextInputFormat; import org.apache.giraph.utils.InternalVertexRunner; -import org.apache.giraph.edge.ByteArrayEdges; import org.junit.Test; -import java.util.Map; +import com.google.common.base.Splitter; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Iterables; +import com.google.common.collect.SetMultimap; + import java.util.Set; import static org.junit.Assert.assertEquals; @@ -66,17 +65,15 @@ public class ConnectedComponentsVertexTest { "9" }; - GiraphClasses classes = new GiraphClasses(); - classes.setVertexClass(ConnectedComponentsVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setCombinerClass(MinimumIntCombiner.class); - classes.setVertexInputFormatClass(IntIntNullTextInputFormat.class); - classes.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class); - Map<String, String> emptyParams = ImmutableMap.of(); + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setVertexClass(ConnectedComponentsVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setCombinerClass(MinimumIntCombiner.class); + conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class); + conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class); // run internally - Iterable<String> results = InternalVertexRunner.run(classes, - emptyParams, graph); + Iterable<String> results = InternalVertexRunner.run(conf, graph); SetMultimap<Integer,Integer> components = parseResults(results); http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java index e42f172..f748cb0 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/ConnectedComponentsVertexTestInMemory.java @@ -18,22 +18,21 @@ package org.apache.giraph.examples; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.SetMultimap; import org.apache.giraph.combiner.MinimumIntCombiner; -import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; +import org.apache.giraph.edge.ByteArrayEdges; import org.apache.giraph.graph.Vertex; import org.apache.giraph.utils.InternalVertexRunner; import org.apache.giraph.utils.TestGraph; -import org.apache.giraph.edge.ByteArrayEdges; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.NullWritable; import org.junit.Test; -import java.util.Map; -import java.util.Map.Entry; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.SetMultimap; + import java.util.AbstractMap.SimpleEntry; +import java.util.Map.Entry; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -57,19 +56,13 @@ public class ConnectedComponentsVertexTestInMemory { */ @Test public void testToyData() throws Exception { - GiraphClasses<IntWritable, - IntWritable, - NullWritable, - IntWritable > classes = new GiraphClasses(); - classes.setVertexClass(ConnectedComponentsVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setCombinerClass(MinimumIntCombiner.class); + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setVertexClass(ConnectedComponentsVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setCombinerClass(MinimumIntCombiner.class); TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> graph = - new TestGraph<IntWritable, - IntWritable, - NullWritable, - IntWritable> (classes); + new TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> (conf); // a small graph with three components graph.addVertex(new IntWritable(1), new IntWritable(1), makeEdges(2, 3)) .addVertex(new IntWritable(2), new IntWritable(2), makeEdges(1, 4, 5)) @@ -87,11 +80,9 @@ public class ConnectedComponentsVertexTestInMemory { .addVertex(new IntWritable(11), new IntWritable(11), makeEdges(7, 10)) .addVertex(new IntWritable(9), new IntWritable(9)); - Map<String, String> emptyParams = ImmutableMap.of(); - // run internally TestGraph<IntWritable, IntWritable, NullWritable, IntWritable> results = - InternalVertexRunner.run(classes, emptyParams, graph); + InternalVertexRunner.run(conf, graph); SetMultimap<Integer,Integer> components = parseResults(results); http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java index 042dbe4..2e4bbc4 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/PageRankVertexTest.java @@ -18,13 +18,9 @@ package org.apache.giraph.examples; -import com.google.common.collect.Maps; -import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.edge.ByteArrayEdges; import org.apache.giraph.utils.InternalVertexRunner; -import org.apache.hadoop.io.DoubleWritable; -import org.apache.hadoop.io.LongWritable; -import org.apache.hadoop.io.NullWritable; import org.junit.Test; import java.util.Map; @@ -52,25 +48,19 @@ public class PageRankVertexTest { "5 2 4" }; - Map<String, String> params = Maps.newHashMap(); - params.put(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, String.valueOf(50)); - params.put(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, - String.valueOf(0.15)); - - GiraphClasses<LongWritable, DoubleWritable, NullWritable, DoubleWritable> - classes = new GiraphClasses<LongWritable, DoubleWritable, - NullWritable, DoubleWritable>(); - classes.setVertexClass(PageRankVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setVertexInputFormatClass( - LongDoubleNullTextInputFormat.class); - classes.setVertexOutputFormatClass( + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 50); + conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.15f); + conf.setVertexClass(PageRankVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setVertexInputFormatClass(LongDoubleNullTextInputFormat.class); + conf.setVertexOutputFormatClass( VertexWithDoubleValueNullEdgeTextOutputFormat.class); - classes.setWorkerContextClass(RandomWalkWorkerContext.class); - classes.setMasterComputeClass( + conf.setWorkerContextClass(RandomWalkWorkerContext.class); + conf.setMasterComputeClass( RandomWalkVertex.RandomWalkVertexMasterCompute.class); // Run internally - Iterable<String> results = InternalVertexRunner.run(classes, params, graph); + Iterable<String> results = InternalVertexRunner.run(conf, graph); Map<Long, Double> steadyStateProbabilities = RandomWalkTestUtils.parseSteadyStateProbabilities(results); http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java index f77ea3e..a3dbd45 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/RandomWalkWithRestartVertexTest.java @@ -18,16 +18,12 @@ package org.apache.giraph.examples; -import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; +import org.apache.giraph.edge.ByteArrayEdges; import org.apache.giraph.examples.RandomWalkVertex.RandomWalkVertexMasterCompute; import org.apache.giraph.utils.InternalVertexRunner; -import org.apache.giraph.edge.ByteArrayEdges; -import org.apache.hadoop.io.DoubleWritable; -import org.apache.hadoop.io.LongWritable; import org.junit.Test; -import com.google.common.collect.Maps; - import java.util.Map; import static org.junit.Assert.assertEquals; @@ -42,28 +38,22 @@ public class RandomWalkWithRestartVertexTest { */ @Test public void testToyData() throws Exception { - // A small graph String[] graph = new String[] { "12 34 56", "34 78", "56 34 78", "78 34" }; - Map<String, String> params = Maps.newHashMap(); - params.put(RandomWalkWithRestartVertex.SOURCE_VERTEX, "12"); - params.put(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, "30"); - params.put(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, "0.25"); - - GiraphClasses<LongWritable, DoubleWritable, DoubleWritable, DoubleWritable> - classes = new GiraphClasses<LongWritable, DoubleWritable, - DoubleWritable, DoubleWritable>(); - classes.setVertexClass(RandomWalkWithRestartVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setVertexInputFormatClass( - LongDoubleDoubleTextInputFormat.class); - classes.setVertexOutputFormatClass( + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setInt(RandomWalkWithRestartVertex.SOURCE_VERTEX, 12); + conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 30); + conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.25f); + conf.setVertexClass(RandomWalkWithRestartVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setVertexInputFormatClass(LongDoubleDoubleTextInputFormat.class); + conf.setVertexOutputFormatClass( VertexWithDoubleValueDoubleEdgeTextOutputFormat.class); - classes.setWorkerContextClass(RandomWalkWorkerContext.class); - classes.setMasterComputeClass(RandomWalkVertexMasterCompute.class); + conf.setWorkerContextClass(RandomWalkWorkerContext.class); + conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class); // Run internally - Iterable<String> results = InternalVertexRunner.run(classes, params, graph); + Iterable<String> results = InternalVertexRunner.run(conf, graph); Map<Long, Double> steadyStateProbabilities = RandomWalkTestUtils.parseSteadyStateProbabilities(results); @@ -87,24 +77,20 @@ public class RandomWalkWithRestartVertexTest { new String[] { "12 34:0.1 56:0.9", "34 78:0.9 56:0.1", "56 12:0.1 34:0.8 78:0.1", "78 34:1.0" }; - Map<String, String> params = Maps.newHashMap(); - params.put(RandomWalkWithRestartVertex.SOURCE_VERTEX, "12"); - params.put(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, "30"); - params.put(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, "0.15"); - - GiraphClasses<LongWritable, DoubleWritable, DoubleWritable, - DoubleWritable> classes = new GiraphClasses<LongWritable, - DoubleWritable, DoubleWritable, DoubleWritable>(); - classes.setVertexClass(RandomWalkWithRestartVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setVertexInputFormatClass( + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setInt(RandomWalkWithRestartVertex.SOURCE_VERTEX, 12); + conf.setInt(RandomWalkWithRestartVertex.MAX_SUPERSTEPS, 30); + conf.setFloat(RandomWalkWithRestartVertex.TELEPORTATION_PROBABILITY, 0.15f); + conf.setVertexClass(RandomWalkWithRestartVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setVertexInputFormatClass( NormalizingLongDoubleDoubleTextInputFormat.class); - classes.setVertexOutputFormatClass( + conf.setVertexOutputFormatClass( VertexWithDoubleValueDoubleEdgeTextOutputFormat.class); - classes.setWorkerContextClass(RandomWalkWorkerContext.class); - classes.setMasterComputeClass(RandomWalkVertexMasterCompute.class); + conf.setWorkerContextClass(RandomWalkWorkerContext.class); + conf.setMasterComputeClass(RandomWalkVertexMasterCompute.class); // Run internally - Iterable<String> results = InternalVertexRunner.run(classes, params, graph); + Iterable<String> results = InternalVertexRunner.run(conf, graph); Map<Long, Double> steadyStateProbabilities = RandomWalkTestUtils.parseSteadyStateProbabilities(results); http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java index e51b611..ee99dc5 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/SimpleShortestPathsVertexTest.java @@ -18,16 +18,13 @@ package org.apache.giraph.examples; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; +import org.apache.giraph.edge.ByteArrayEdges; +import org.apache.giraph.edge.EdgeFactory; import org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexInputFormat; import org.apache.giraph.io.formats.JsonLongDoubleFloatDoubleVertexOutputFormat; import org.apache.giraph.utils.InternalVertexRunner; import org.apache.giraph.utils.MockUtils; -import org.apache.giraph.edge.ByteArrayEdges; -import org.apache.giraph.edge.EdgeFactory; import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.FloatWritable; import org.apache.hadoop.io.LongWritable; @@ -36,8 +33,13 @@ import org.json.JSONException; import org.junit.Test; import org.mockito.Mockito; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + import java.util.Map; +import static org.apache.giraph.examples.SimpleShortestPathsVertex.SOURCE_ID; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -58,9 +60,7 @@ public class SimpleShortestPathsVertexTest { DoubleWritable> env = MockUtils.prepareVertex(vertex, 1L, new LongWritable(7L), new DoubleWritable(Double.MAX_VALUE), false); - Mockito.when(env.getConfiguration().getLong( - SimpleShortestPathsVertex.SOURCE_ID, - SimpleShortestPathsVertex.SOURCE_ID_DEFAULT)).thenReturn(2L); + Mockito.when(SOURCE_ID.get(env.getConfiguration())).thenReturn(2L); vertex.addEdge(EdgeFactory.create( new LongWritable(10L), new FloatWritable(2.5f))); @@ -90,9 +90,7 @@ public class SimpleShortestPathsVertexTest { DoubleWritable> env = MockUtils.prepareVertex(vertex, 1L, new LongWritable(7L), new DoubleWritable(0.5), false); - Mockito.when(env.getConfiguration().getLong( - SimpleShortestPathsVertex.SOURCE_ID, - SimpleShortestPathsVertex.SOURCE_ID_DEFAULT)).thenReturn(2L); + Mockito.when(SOURCE_ID.get(env.getConfiguration())).thenReturn(2L); vertex.addEdge(EdgeFactory.create(new LongWritable(10L), new FloatWritable(2.5f))); @@ -122,21 +120,18 @@ public class SimpleShortestPathsVertexTest { "[4,0,[]]" }; + GiraphConfiguration conf = new GiraphConfiguration(); // start from vertex 1 - Map<String, String> params = Maps.newHashMap(); - params.put(SimpleShortestPathsVertex.SOURCE_ID, "1"); - - GiraphClasses<LongWritable, DoubleWritable, FloatWritable, DoubleWritable> - classes = new GiraphClasses(); - classes.setVertexClass(SimpleShortestPathsVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setVertexInputFormatClass( + SOURCE_ID.set(conf, 1); + conf.setVertexClass(SimpleShortestPathsVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setVertexInputFormatClass( JsonLongDoubleFloatDoubleVertexInputFormat.class); - classes.setVertexOutputFormatClass( + conf.setVertexOutputFormatClass( JsonLongDoubleFloatDoubleVertexOutputFormat.class); // run internally - Iterable<String> results = InternalVertexRunner.run(classes, params, graph); + Iterable<String> results = InternalVertexRunner.run(conf, graph); Map<Long, Double> distances = parseDistances(results); http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java b/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java index 448afe6..922e736 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/TestPageRank.java @@ -18,13 +18,9 @@ package org.apache.giraph.examples; import org.apache.giraph.BspCase; -import org.apache.giraph.conf.GiraphClasses; import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.job.GiraphJob; -import org.apache.hadoop.io.DoubleWritable; -import org.apache.hadoop.io.FloatWritable; -import org.apache.hadoop.io.LongWritable; import org.junit.Test; import java.io.IOException; @@ -67,22 +63,20 @@ public class TestPageRank extends BspCase { */ private void testPageRank(int numComputeThreads) throws IOException, InterruptedException, ClassNotFoundException { - GiraphClasses<LongWritable, DoubleWritable, FloatWritable, DoubleWritable> - classes = new GiraphClasses(); - classes.setVertexClass(SimplePageRankVertex.class); - classes.setVertexInputFormatClass( + GiraphConfiguration conf = new GiraphConfiguration(); + conf.setVertexClass(SimplePageRankVertex.class); + conf.setVertexInputFormatClass( SimplePageRankVertex.SimplePageRankVertexInputFormat.class); - classes.setWorkerContextClass( + conf.setWorkerContextClass( SimplePageRankVertex.SimplePageRankVertexWorkerContext.class); - classes.setMasterComputeClass( + conf.setMasterComputeClass( SimplePageRankVertex.SimplePageRankVertexMasterCompute.class); - GiraphJob job = prepareJob(getCallingMethodName(), classes); - GiraphConfiguration conf = job.getConfiguration(); conf.setNumComputeThreads(numComputeThreads); // Set enough partitions to generate randomness on the compute side if (numComputeThreads != 1) { GiraphConstants.USER_PARTITION_COUNT.set(conf, numComputeThreads * 5); } + GiraphJob job = prepareJob(getCallingMethodName(), conf); assertTrue(job.run(true)); if (!runningInDistributedMode()) { double maxPageRank = @@ -97,7 +91,7 @@ public class TestPageRank extends BspCase { " numComputeThreads=" + numComputeThreads); assertEquals(34.03, maxPageRank, 0.001); assertEquals(0.03, minPageRank, 0.00001); - assertEquals(5l, numVertices); + assertEquals(5L, numVertices); } } } http://git-wip-us.apache.org/repos/asf/giraph/blob/db077ec2/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java b/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java index 48153ae..4945b52 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java +++ b/giraph-examples/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java @@ -19,21 +19,19 @@ package org.apache.giraph.examples; import org.apache.giraph.combiner.MinimumIntCombiner; -import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; +import org.apache.giraph.edge.ByteArrayEdges; import org.apache.giraph.io.formats.IdWithValueTextOutputFormat; import org.apache.giraph.io.formats.IntIntNullTextInputFormat; import org.apache.giraph.utils.InternalVertexRunner; -import org.apache.giraph.edge.ByteArrayEdges; import org.junit.Test; import com.google.common.base.Splitter; import com.google.common.collect.HashMultimap; import com.google.common.collect.Iterables; -import com.google.common.collect.Maps; import com.google.common.collect.SetMultimap; -import java.util.Map; import java.util.Set; import static org.junit.Assert.assertEquals; @@ -70,19 +68,15 @@ public class TryMultiIpcBindingPortsTest { // run internally // fail the first port binding attempt - Map<String, String> params = Maps.<String, String>newHashMap(); - params.put(GiraphConstants.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT.getKey(), - "true"); - - GiraphClasses classes = new GiraphClasses(); - classes.setVertexClass(ConnectedComponentsVertex.class); - classes.setVertexEdgesClass(ByteArrayEdges.class); - classes.setCombinerClass(MinimumIntCombiner.class); - classes.setVertexInputFormatClass(IntIntNullTextInputFormat.class); - classes.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class); - - Iterable<String> results = InternalVertexRunner.run(classes, params, - graph); + GiraphConfiguration conf = new GiraphConfiguration(); + GiraphConstants.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT.set(conf, true); + conf.setVertexClass(ConnectedComponentsVertex.class); + conf.setVertexEdgesClass(ByteArrayEdges.class); + conf.setCombinerClass(MinimumIntCombiner.class); + conf.setVertexInputFormatClass(IntIntNullTextInputFormat.class); + conf.setVertexOutputFormatClass(IdWithValueTextOutputFormat.class); + + Iterable<String> results = InternalVertexRunner.run(conf, graph); SetMultimap<Integer,Integer> components = parseResults(results);
