Updated Branches: refs/heads/trunk 460198af9 -> 01c527e22
http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/comm/RequestFailureTest.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/comm/RequestFailureTest.java b/giraph-core/src/test/java/org/apache/giraph/comm/RequestFailureTest.java index cc7cb17..58aa7d1 100644 --- a/giraph-core/src/test/java/org/apache/giraph/comm/RequestFailureTest.java +++ b/giraph-core/src/test/java/org/apache/giraph/comm/RequestFailureTest.java @@ -18,7 +18,6 @@ package org.apache.giraph.comm; -import com.google.common.collect.Lists; import org.apache.giraph.comm.netty.NettyClient; import org.apache.giraph.comm.netty.NettyServer; import org.apache.giraph.comm.netty.handler.WorkerRequestServerHandler; @@ -27,16 +26,18 @@ import org.apache.giraph.comm.requests.WritableRequest; import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; +import org.apache.giraph.graph.Vertex; import org.apache.giraph.utils.ByteArrayVertexIdMessages; import org.apache.giraph.utils.MockUtils; import org.apache.giraph.utils.PairList; -import org.apache.giraph.graph.Vertex; import org.apache.giraph.worker.WorkerInfo; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.mapreduce.Mapper.Context; import org.junit.Before; import org.junit.Test; +import com.google.common.collect.Lists; + import java.io.IOException; import static org.junit.Assert.assertEquals; @@ -135,11 +136,11 @@ public class RequestFailureTest { @Test public void alreadyProcessedRequest() throws IOException { // Force a drop of the first request - conf.setBoolean(GiraphConstants.NETTY_SIMULATE_FIRST_RESPONSE_FAILED, true); + GiraphConstants.NETTY_SIMULATE_FIRST_RESPONSE_FAILED.set(conf, true); // One second to finish a request - conf.setInt(GiraphConstants.MAX_REQUEST_MILLISECONDS, 1000); + GiraphConstants.MAX_REQUEST_MILLISECONDS.set(conf, 1000); // Loop every 2 seconds - conf.setInt(GiraphConstants.WAITING_REQUEST_MSECS, 2000); + GiraphConstants.WAITING_REQUEST_MSECS.set(conf, 2000); checkSendingTwoRequests(); } @@ -147,11 +148,11 @@ public class RequestFailureTest { @Test public void resendRequest() throws IOException { // Force a drop of the first request - conf.setBoolean(GiraphConstants.NETTY_SIMULATE_FIRST_REQUEST_CLOSED, true); + GiraphConstants.NETTY_SIMULATE_FIRST_REQUEST_CLOSED.set(conf, true); // One second to finish a request - conf.setInt(GiraphConstants.MAX_REQUEST_MILLISECONDS, 1000); + GiraphConstants.MAX_REQUEST_MILLISECONDS.set(conf, 1000); // Loop every 2 seconds - conf.setInt(GiraphConstants.WAITING_REQUEST_MSECS, 2000); + GiraphConstants.WAITING_REQUEST_MSECS.set(conf, 2000); checkSendingTwoRequests(); } http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/comm/RequestTest.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/comm/RequestTest.java b/giraph-core/src/test/java/org/apache/giraph/comm/RequestTest.java index c8d6b3b..f1f8e26 100644 --- a/giraph-core/src/test/java/org/apache/giraph/comm/RequestTest.java +++ b/giraph-core/src/test/java/org/apache/giraph/comm/RequestTest.java @@ -18,8 +18,6 @@ package org.apache.giraph.comm; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; import org.apache.giraph.comm.netty.NettyClient; import org.apache.giraph.comm.netty.NettyServer; import org.apache.giraph.comm.netty.handler.WorkerRequestServerHandler; @@ -29,22 +27,25 @@ import org.apache.giraph.comm.requests.SendWorkerMessagesRequest; import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; -import org.apache.giraph.metrics.GiraphMetrics; import org.apache.giraph.edge.Edge; import org.apache.giraph.edge.EdgeFactory; +import org.apache.giraph.graph.Vertex; import org.apache.giraph.graph.VertexMutations; +import org.apache.giraph.metrics.GiraphMetrics; import org.apache.giraph.partition.Partition; import org.apache.giraph.partition.PartitionStore; import org.apache.giraph.utils.ByteArrayVertexIdMessages; import org.apache.giraph.utils.MockUtils; import org.apache.giraph.utils.PairList; -import org.apache.giraph.graph.Vertex; import org.apache.giraph.worker.WorkerInfo; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.mapreduce.Mapper.Context; import org.junit.Before; import org.junit.Test; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; + import java.io.IOException; import java.util.Map; import java.util.Map.Entry; @@ -85,8 +86,7 @@ public class RequestTest { public void setUp() throws IOException { // Setup the conf GiraphConfiguration tmpConf = new GiraphConfiguration(); - tmpConf.setClass(GiraphConstants.VERTEX_CLASS, TestVertex.class, - Vertex.class); + GiraphConstants.VERTEX_CLASS.set(tmpConf, TestVertex.class); conf = new ImmutableClassesGiraphConfiguration(tmpConf); @SuppressWarnings("rawtypes") http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/comm/SaslConnectionTest.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/comm/SaslConnectionTest.java b/giraph-core/src/test/java/org/apache/giraph/comm/SaslConnectionTest.java index 3094f3e..c27156f 100644 --- a/giraph-core/src/test/java/org/apache/giraph/comm/SaslConnectionTest.java +++ b/giraph-core/src/test/java/org/apache/giraph/comm/SaslConnectionTest.java @@ -18,7 +18,6 @@ package org.apache.giraph.comm; -import com.google.common.collect.Lists; import org.apache.giraph.comm.netty.NettyClient; import org.apache.giraph.comm.netty.NettyServer; import org.apache.giraph.comm.netty.handler.SaslServerHandler; @@ -26,8 +25,8 @@ import org.apache.giraph.comm.netty.handler.WorkerRequestServerHandler; import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; -import org.apache.giraph.utils.MockUtils; import org.apache.giraph.graph.Vertex; +import org.apache.giraph.utils.MockUtils; import org.apache.giraph.worker.WorkerInfo; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.mapreduce.Mapper.Context; @@ -35,6 +34,8 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; +import com.google.common.collect.Lists; + import java.io.IOException; import static org.mockito.Mockito.mock; @@ -58,7 +59,7 @@ public class SaslConnectionTest { public void setUp() { GiraphConfiguration tmpConfig = new GiraphConfiguration(); tmpConfig.setVertexClass(IntVertex.class); - tmpConfig.setBoolean(GiraphConstants.AUTHENTICATE, true); + GiraphConstants.AUTHENTICATE.set(tmpConfig, true); conf = new ImmutableClassesGiraphConfiguration(tmpConfig); } http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/conf/TestGiraphConfiguration.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/conf/TestGiraphConfiguration.java b/giraph-core/src/test/java/org/apache/giraph/conf/TestGiraphConfiguration.java index cd37197..f0d3bb1 100644 --- a/giraph-core/src/test/java/org/apache/giraph/conf/TestGiraphConfiguration.java +++ b/giraph-core/src/test/java/org/apache/giraph/conf/TestGiraphConfiguration.java @@ -20,6 +20,7 @@ package org.apache.giraph.conf; import org.junit.Test; +import static org.apache.giraph.conf.ClassConfOption.getClassesOfType; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; @@ -45,7 +46,7 @@ public class TestGiraphConfiguration { assertEquals(2, conf.getClasses("foo").length); } - Class<? extends If>[] klasses2 = conf.getClassesOfType("foo", If.class); + Class<? extends If>[] klasses2 = getClassesOfType(conf, "foo", If.class); assertEquals(2, klasses2.length); assertEquals(A.class, klasses2[0]); assertEquals(B.class, klasses2[1]); @@ -56,14 +57,14 @@ public class TestGiraphConfiguration { GiraphConfiguration conf = new GiraphConfiguration(); conf.setClasses("foo", If.class, A.class, B.class); - conf.addToClasses("foo", C.class, If.class); + ClassConfOption.addToClasses(conf, "foo", C.class, If.class); Class<?>[] klasses = conf.getClasses("foo"); assertEquals(3, klasses.length); assertEquals(A.class, klasses[0]); assertEquals(B.class, klasses[1]); assertEquals(C.class, klasses[2]); - conf.addToClasses("bar", B.class, If.class); + ClassConfOption.addToClasses(conf, "bar", B.class, If.class); klasses = conf.getClasses("bar"); assertEquals(1, klasses.length); assertEquals(B.class, klasses[0]); http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java b/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java index 9f0920a..9075145 100644 --- a/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java +++ b/giraph-core/src/test/java/org/apache/giraph/conf/TestObjectCreation.java @@ -18,15 +18,13 @@ package org.apache.giraph.conf; +import org.apache.giraph.graph.Vertex; import org.apache.giraph.time.SystemTime; import org.apache.giraph.time.Time; import org.apache.giraph.time.Times; -import org.apache.giraph.graph.Vertex; import org.apache.hadoop.io.DoubleWritable; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.LongWritable; -import org.apache.hadoop.io.Writable; -import org.apache.hadoop.io.WritableComparable; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -58,14 +56,10 @@ public class TestObjectCreation { @Before public void setUp() { GiraphConfiguration conf = new GiraphConfiguration(); - conf.setClass(GiraphConstants.VERTEX_ID_CLASS, IntWritable.class, - WritableComparable.class); - conf.setClass(GiraphConstants.VERTEX_VALUE_CLASS, LongWritable.class, - Writable.class); - conf.setClass(GiraphConstants.EDGE_VALUE_CLASS, DoubleWritable.class, - Writable.class); - conf.setClass(GiraphConstants.MESSAGE_VALUE_CLASS, LongWritable.class, - Writable.class); + GiraphConstants.VERTEX_ID_CLASS.set(conf, IntWritable.class); + GiraphConstants.VERTEX_VALUE_CLASS.set(conf, LongWritable.class); + GiraphConstants.EDGE_VALUE_CLASS.set(conf, DoubleWritable.class); + GiraphConstants.MESSAGE_VALUE_CLASS.set(conf, LongWritable.class); conf.setVertexClass(ImmutableVertex.class); configuration = new ImmutableClassesGiraphConfiguration<LongWritable, LongWritable, http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java b/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java index 54a8b92..10bb4d0 100644 --- a/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java +++ b/giraph-core/src/test/java/org/apache/giraph/master/TestMasterObserver.java @@ -18,18 +18,19 @@ package org.apache.giraph.master; -import com.google.common.collect.Maps; import org.apache.giraph.conf.GiraphClasses; import org.apache.giraph.conf.GiraphConstants; -import org.apache.giraph.io.formats.IntNullNullNullTextInputFormat; -import org.apache.giraph.utils.InternalVertexRunner; import org.apache.giraph.edge.ByteArrayEdges; import org.apache.giraph.graph.Vertex; +import org.apache.giraph.io.formats.IntNullNullNullTextInputFormat; +import org.apache.giraph.utils.InternalVertexRunner; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.util.StringUtils; import org.junit.Test; +import com.google.common.collect.Maps; + import java.io.IOException; import java.util.Map; @@ -87,7 +88,7 @@ public class TestMasterObserver { Obs.class.getName(), Obs.class.getName() }; - params.put(GiraphConstants.MASTER_OBSERVER_CLASSES, + params.put(GiraphConstants.MASTER_OBSERVER_CLASSES.getKey(), StringUtils.arrayToString(klasses)); GiraphClasses classes = new GiraphClasses(); http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java ---------------------------------------------------------------------- diff --git a/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java b/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java index d403dd8..8e79a47 100644 --- a/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java +++ b/giraph-core/src/test/java/org/apache/giraph/partition/TestPartitionStores.java @@ -18,19 +18,20 @@ package org.apache.giraph.partition; -import com.google.common.collect.Iterables; import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; +import org.apache.giraph.graph.Vertex; import org.apache.giraph.utils.UnsafeByteArrayInputStream; import org.apache.giraph.utils.UnsafeByteArrayOutputStream; -import org.apache.giraph.graph.Vertex; import org.apache.hadoop.io.IntWritable; import org.apache.hadoop.io.NullWritable; import org.apache.hadoop.mapreduce.Mapper; import org.junit.Before; import org.junit.Test; +import com.google.common.collect.Iterables; + import java.io.IOException; import static org.junit.Assert.assertEquals; @@ -134,8 +135,8 @@ public class TestPartitionStores { @Test public void testDiskBackedPartitionStore() { - conf.setBoolean(GiraphConstants.USE_OUT_OF_CORE_GRAPH, true); - conf.setInt(GiraphConstants.MAX_PARTITIONS_IN_MEMORY, 1); + GiraphConstants.USE_OUT_OF_CORE_GRAPH.set(conf, true); + GiraphConstants.MAX_PARTITIONS_IN_MEMORY.set(conf, 1); PartitionStore<IntWritable, IntWritable, NullWritable, IntWritable> partitionStore = new DiskBackedPartitionStore<IntWritable, @@ -143,7 +144,7 @@ public class TestPartitionStores { testReadWrite(partitionStore, conf); partitionStore.shutdown(); - conf.setInt(GiraphConstants.MAX_PARTITIONS_IN_MEMORY, 2); + GiraphConstants.MAX_PARTITIONS_IN_MEMORY.set(conf, 2); partitionStore = new DiskBackedPartitionStore<IntWritable, IntWritable, NullWritable, IntWritable>(conf, context); testReadWrite(partitionStore, conf); http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-examples/src/test/java/org/apache/giraph/TestAutoCheckpoint.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestAutoCheckpoint.java b/giraph-examples/src/test/java/org/apache/giraph/TestAutoCheckpoint.java index efbe320..386f67b 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/TestAutoCheckpoint.java +++ b/giraph-examples/src/test/java/org/apache/giraph/TestAutoCheckpoint.java @@ -77,11 +77,11 @@ public class TestAutoCheckpoint extends BspCase { conf.setMaxMasterSuperstepWaitMsecs(10000); conf.setEventWaitMsecs(1000); conf.setCheckpointFrequency(2); - conf.set(GiraphConstants.CHECKPOINT_DIRECTORY, + GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, getTempPath("_singleFaultCheckpoints").toString()); - conf.setBoolean(GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS, false); - conf.setInt(GiraphConstants.ZOOKEEPER_SESSION_TIMEOUT, 10000); - conf.setInt(GiraphConstants.ZOOKEEPER_MIN_SESSION_TIMEOUT, 10000); + GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(conf, false); + GiraphConstants.ZOOKEEPER_SESSION_TIMEOUT.set(conf, 10000); + GiraphConstants.ZOOKEEPER_MIN_SESSION_TIMEOUT.set(conf, 10000); assertTrue(job.run(true)); } http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-examples/src/test/java/org/apache/giraph/TestBspBasic.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestBspBasic.java b/giraph-examples/src/test/java/org/apache/giraph/TestBspBasic.java index 5234730..666a50b 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/TestBspBasic.java +++ b/giraph-examples/src/test/java/org/apache/giraph/TestBspBasic.java @@ -200,7 +200,7 @@ else[HADOOP_NON_JOBCONTEXT_IS_INTERFACE]*/ GiraphJob job = prepareJob(getCallingMethodName(), classes); GiraphConfiguration conf = job.getConfiguration(); conf.setWorkerConfiguration(5, 5, 100.0f); - conf.setBoolean(GiraphConstants.SPLIT_MASTER_WORKER, true); + GiraphConstants.SPLIT_MASTER_WORKER.set(conf, true); try { job.run(true); @@ -208,7 +208,7 @@ else[HADOOP_NON_JOBCONTEXT_IS_INTERFACE]*/ } catch (IllegalArgumentException e) { } - conf.setBoolean(GiraphConstants.SPLIT_MASTER_WORKER, false); + GiraphConstants.SPLIT_MASTER_WORKER.set(conf, false); try { job.run(true); fail(); @@ -264,7 +264,6 @@ else[HADOOP_NON_JOBCONTEXT_IS_INTERFACE]*/ classes.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class); GiraphJob job = prepareJob(callingMethod, classes, outputPath); Configuration conf = job.getConfiguration(); - conf.setFloat(GiraphConstants.TOTAL_INPUT_SPLIT_MULTIPLIER, 2.0f); // GeneratedInputSplit will generate 10 vertices conf.setLong(GeneratedVertexReader.READER_VERTICES, 10); assertTrue(job.run(true)); http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-examples/src/test/java/org/apache/giraph/TestManualCheckpoint.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestManualCheckpoint.java b/giraph-examples/src/test/java/org/apache/giraph/TestManualCheckpoint.java index eb2338c..210b78a 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/TestManualCheckpoint.java +++ b/giraph-examples/src/test/java/org/apache/giraph/TestManualCheckpoint.java @@ -19,6 +19,7 @@ package org.apache.giraph; import org.apache.giraph.conf.GiraphClasses; +import org.apache.giraph.conf.GiraphConfiguration; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.examples.SimpleCheckpointVertex; import org.apache.giraph.examples.SimpleSuperstepVertex.SimpleSuperstepVertexInputFormat; @@ -64,11 +65,10 @@ public class TestManualCheckpoint extends BspCase { classes.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class); GiraphJob job = prepareJob(getCallingMethodName(), classes, outputPath); - job.getConfiguration().set(GiraphConstants.CHECKPOINT_DIRECTORY, - checkpointsDir.toString()); - job.getConfiguration().setBoolean( - GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS, false); - job.getConfiguration().setCheckpointFrequency(2); + GiraphConfiguration conf = job.getConfiguration(); + GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, checkpointsDir.toString()); + GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(conf, false); + conf.setCheckpointFrequency(2); assertTrue(job.run(true)); @@ -97,9 +97,9 @@ public class TestManualCheckpoint extends BspCase { classes.setVertexOutputFormatClass(SimpleSuperstepVertexOutputFormat.class); GiraphJob restartedJob = prepareJob(getCallingMethodName() + "Restarted", classes, outputPath); - job.getConfiguration().setMasterComputeClass( + conf.setMasterComputeClass( SimpleCheckpointVertex.SimpleCheckpointVertexMasterCompute.class); - restartedJob.getConfiguration().set(GiraphConstants.CHECKPOINT_DIRECTORY, + GiraphConstants.CHECKPOINT_DIRECTORY.set(restartedJob.getConfiguration(), checkpointsDir.toString()); assertTrue(restartedJob.run(true)); http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java b/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java index 41f5e3c..f236128 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java +++ b/giraph-examples/src/test/java/org/apache/giraph/TestPartitionContext.java @@ -64,8 +64,7 @@ public class TestPartitionContext extends BspCase { GeneratedVertexReader.READER_VERTICES, PartitionContextTestVertex.NUM_VERTICES); // Increase the number of partitions - job.getConfiguration().setInt( - GiraphConstants.USER_PARTITION_COUNT, + GiraphConstants.USER_PARTITION_COUNT.set(job.getConfiguration(), PartitionContextTestVertex.NUM_PARTITIONS); assertTrue(job.run(true)); } http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/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 7deeb42..372c32f 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 @@ -19,10 +19,11 @@ 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; -import org.apache.giraph.comm.aggregators.AggregatorUtils; import org.apache.giraph.examples.AggregatorsTestVertex; import org.apache.giraph.examples.SimpleCheckpointVertex; import org.apache.giraph.examples.SimplePageRankVertex; @@ -37,10 +38,6 @@ import org.apache.hadoop.util.Progressable; import org.junit.Test; import org.mockito.Mockito; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; @@ -49,6 +46,10 @@ import java.io.IOException; import java.lang.reflect.Field; import java.util.Map; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + /** Tests if aggregators are handled on a proper way */ public class TestAggregatorsHandling extends BspCase { @@ -165,11 +166,10 @@ public class TestAggregatorsHandling extends BspCase { SimplePageRankVertex.SimplePageRankVertexInputFormat.class); GiraphJob job = prepareJob(getCallingMethodName(), classes, outputPath); - job.getConfiguration().set(GiraphConstants.CHECKPOINT_DIRECTORY, - checkpointsDir.toString()); - job.getConfiguration().setBoolean( - GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS, false); - job.getConfiguration().setCheckpointFrequency(4); + GiraphConfiguration conf = job.getConfiguration(); + GiraphConstants.CHECKPOINT_DIRECTORY.set(conf, checkpointsDir.toString()); + GiraphConstants.CLEANUP_CHECKPOINTS_AFTER_SUCCESS.set(conf, false); + conf.setCheckpointFrequency(4); assertTrue(job.run(true)); @@ -187,10 +187,10 @@ public class TestAggregatorsHandling extends BspCase { classes, outputPath); job.getConfiguration().setMasterComputeClass( SimpleCheckpointVertex.SimpleCheckpointVertexMasterCompute.class); - restartedJob.getConfiguration().set( - GiraphConstants.CHECKPOINT_DIRECTORY, checkpointsDir.toString()); - restartedJob.getConfiguration().setLong( - GiraphConstants.RESTART_SUPERSTEP, 4); + GiraphConfiguration restartedJobConf = restartedJob.getConfiguration(); + GiraphConstants.CHECKPOINT_DIRECTORY.set(restartedJobConf, + checkpointsDir.toString()); + restartedJobConf.setLong(GiraphConstants.RESTART_SUPERSTEP, 4); assertTrue(restartedJob.run(true)); } http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/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 f56d7e5..448afe6 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 @@ -81,8 +81,7 @@ public class TestPageRank extends BspCase { conf.setNumComputeThreads(numComputeThreads); // Set enough partitions to generate randomness on the compute side if (numComputeThreads != 1) { - conf.setInt(GiraphConstants.USER_PARTITION_COUNT, - numComputeThreads * 5); + GiraphConstants.USER_PARTITION_COUNT.set(conf, numComputeThreads * 5); } assertTrue(job.run(true)); if (!runningInDistributedMode()) { http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/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 c5d3a55..c8ca8a1 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 @@ -71,7 +71,8 @@ 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, "true"); + params.put(GiraphConstants.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT.getKey(), + "true"); GiraphClasses classes = new GiraphClasses(); classes.setVertexClass(ConnectedComponentsVertex.class); http://git-wip-us.apache.org/repos/asf/giraph/blob/01c527e2/giraph-examples/src/test/java/org/apache/giraph/vertex/TestVertexTypes.java ---------------------------------------------------------------------- diff --git a/giraph-examples/src/test/java/org/apache/giraph/vertex/TestVertexTypes.java b/giraph-examples/src/test/java/org/apache/giraph/vertex/TestVertexTypes.java index 5ca55b6..0898d63 100644 --- a/giraph-examples/src/test/java/org/apache/giraph/vertex/TestVertexTypes.java +++ b/giraph-examples/src/test/java/org/apache/giraph/vertex/TestVertexTypes.java @@ -22,12 +22,9 @@ import org.apache.giraph.combiner.Combiner; import org.apache.giraph.conf.GiraphConstants; import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; import org.apache.giraph.edge.ByteArrayEdges; -import org.apache.giraph.edge.VertexEdges; import org.apache.giraph.examples.SimpleSuperstepVertex.SimpleSuperstepVertexInputFormat; import org.apache.giraph.graph.Vertex; import org.apache.giraph.graph.VertexValueFactory; -import org.apache.giraph.io.VertexInputFormat; -import org.apache.giraph.io.VertexOutputFormat; import org.apache.giraph.io.formats.GeneratedVertexInputFormat; import org.apache.giraph.io.formats.JsonBase64VertexInputFormat; import org.apache.giraph.io.formats.JsonBase64VertexOutputFormat; @@ -41,6 +38,8 @@ import org.junit.Test; import java.io.IOException; +import static org.apache.giraph.conf.GiraphConstants.VERTEX_VALUE_FACTORY_CLASS; + public class TestVertexTypes { @@ -131,7 +130,7 @@ public class TestVertexTypes { Configuration conf = new Configuration(); conf.setInt(GiraphConstants.MAX_WORKERS, 1); conf.setInt(GiraphConstants.MIN_WORKERS, 1); - conf.set(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, + conf.set(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.getKey(), "org.apache.giraph.io.formats.DUMMY_TEST_VALUE"); return conf; } @@ -140,18 +139,12 @@ public class TestVertexTypes { public void testMatchingType() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf(); - conf.setClass(GiraphConstants.VERTEX_CLASS, - GeneratedVertexMatch.class, - Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - SimpleSuperstepVertexInputFormat.class, - VertexInputFormat.class); - conf.setClass(GiraphConstants.VERTEX_COMBINER_CLASS, - GeneratedVertexMatchCombiner.class, - Combiner.class); + GiraphConstants.VERTEX_CLASS.set(conf, GeneratedVertexMatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + SimpleSuperstepVertexInputFormat.class); + GiraphConstants.VERTEX_COMBINER_CLASS.set(conf, + GeneratedVertexMatchCombiner.class); @SuppressWarnings("rawtypes") GiraphConfigurationValidator<?, ?, ?, ?> validator = new GiraphConfigurationValidator(conf); @@ -167,15 +160,10 @@ public class TestVertexTypes { public void testDerivedMatchingType() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf() ; - conf.setClass(GiraphConstants.VERTEX_CLASS, - DerivedVertexMatch.class, - Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - SimpleSuperstepVertexInputFormat.class, - VertexInputFormat.class); + GiraphConstants.VERTEX_CLASS.set(conf, DerivedVertexMatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + SimpleSuperstepVertexInputFormat.class); @SuppressWarnings("rawtypes") GiraphConfigurationValidator<?, ?, ?, ?> validator = new GiraphConfigurationValidator(conf); @@ -186,15 +174,10 @@ public class TestVertexTypes { public void testDerivedInputFormatType() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf() ; - conf.setClass(GiraphConstants.VERTEX_CLASS, - DerivedVertexMatch.class, - Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - SimpleSuperstepVertexInputFormat.class, - VertexInputFormat.class); + GiraphConstants.VERTEX_CLASS.set(conf, DerivedVertexMatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + SimpleSuperstepVertexInputFormat.class); @SuppressWarnings("rawtypes") GiraphConfigurationValidator<?, ?, ?, ?> validator = new GiraphConfigurationValidator(conf); @@ -205,36 +188,26 @@ public class TestVertexTypes { public void testMismatchingVertex() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf() ; - conf.setClass(GiraphConstants.VERTEX_CLASS, - GeneratedVertexMismatch.class, - Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - SimpleSuperstepVertexInputFormat.class, - VertexInputFormat.class); - @SuppressWarnings("rawtypes") - GiraphConfigurationValidator<?, ?, ?, ?> validator = - new GiraphConfigurationValidator(conf); - validator.validateConfiguration(); + GiraphConstants.VERTEX_CLASS.set(conf, GeneratedVertexMismatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + SimpleSuperstepVertexInputFormat.class); + @SuppressWarnings("rawtypes") + GiraphConfigurationValidator<?, ?, ?, ?> validator = + new GiraphConfigurationValidator(conf); + validator.validateConfiguration(); } @Test(expected = IllegalArgumentException.class) public void testMismatchingCombiner() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf() ; - conf.setClass(GiraphConstants.VERTEX_CLASS, - GeneratedVertexMatch.class, Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - SimpleSuperstepVertexInputFormat.class, - VertexInputFormat.class); - conf.setClass(GiraphConstants.VERTEX_COMBINER_CLASS, - GeneratedVertexMismatchCombiner.class, - Combiner.class); + GiraphConstants.VERTEX_CLASS.set(conf, GeneratedVertexMatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + SimpleSuperstepVertexInputFormat.class); + GiraphConstants.VERTEX_COMBINER_CLASS.set(conf, + GeneratedVertexMismatchCombiner.class); @SuppressWarnings("rawtypes") GiraphConfigurationValidator<?, ?, ?, ?> validator = new GiraphConfigurationValidator(conf); @@ -245,17 +218,12 @@ public class TestVertexTypes { public void testMismatchingVertexValueFactory() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf() ; - conf.setClass(GiraphConstants.VERTEX_CLASS, - GeneratedVertexMatch.class, Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - SimpleSuperstepVertexInputFormat.class, - VertexInputFormat.class); - conf.setClass(GiraphConstants.VERTEX_VALUE_FACTORY_CLASS, - GeneratedVertexMismatchValueFactory.class, - VertexValueFactory.class); + GiraphConstants.VERTEX_CLASS.set(conf, GeneratedVertexMatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + SimpleSuperstepVertexInputFormat.class); + VERTEX_VALUE_FACTORY_CLASS.set(conf, + GeneratedVertexMismatchValueFactory.class); @SuppressWarnings("rawtypes") GiraphConfigurationValidator<?, ?, ?, ?> validator = new GiraphConfigurationValidator(conf); @@ -266,18 +234,12 @@ public class TestVertexTypes { public void testJsonBase64FormatType() throws SecurityException, NoSuchMethodException, NoSuchFieldException { Configuration conf = getDefaultTestConf() ; - conf.setClass(GiraphConstants.VERTEX_CLASS, - GeneratedVertexMatch.class, - Vertex.class); - conf.setClass(GiraphConstants.VERTEX_EDGES_CLASS, - ByteArrayEdges.class, - VertexEdges.class); - conf.setClass(GiraphConstants.VERTEX_INPUT_FORMAT_CLASS, - JsonBase64VertexInputFormat.class, - VertexInputFormat.class); - conf.setClass(GiraphConstants.VERTEX_OUTPUT_FORMAT_CLASS, - JsonBase64VertexOutputFormat.class, - VertexOutputFormat.class); + GiraphConstants.VERTEX_CLASS.set(conf, GeneratedVertexMatch.class); + GiraphConstants.VERTEX_EDGES_CLASS.set(conf, ByteArrayEdges.class); + GiraphConstants.VERTEX_INPUT_FORMAT_CLASS.set(conf, + JsonBase64VertexInputFormat.class); + GiraphConstants.VERTEX_OUTPUT_FORMAT_CLASS.set(conf, + JsonBase64VertexOutputFormat.class); @SuppressWarnings("rawtypes") GiraphConfigurationValidator<?, ?, ?, ?> validator = new GiraphConfigurationValidator(conf);
