You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ap...@apache.org on 2012/10/11 18:48:47 UTC
svn commit: r1397159 [2/2] - in /giraph/trunk: ./
giraph-formats-contrib/src/main/java/org/apache/giraph/io/hcatalog/
giraph-formats-contrib/src/test/java/org/apache/giraph/io/accumulo/edgemarker/
giraph-formats-contrib/src/test/java/org/apache/giraph/...
Added: giraph/trunk/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java?rev=1397159&view=auto
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java (added)
+++ giraph/trunk/src/test/java/org/apache/giraph/examples/TryMultiIpcBindingPortsTest.java Thu Oct 11 16:48:45 2012
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.giraph.examples;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.giraph.GiraphConfiguration;
+import org.apache.giraph.io.IntIntNullIntTextInputFormat;
+import org.apache.giraph.io.IdWithValueTextOutputFormat;
+import org.apache.giraph.utils.InternalVertexRunner;
+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;
+
+/**
+ * Tests for {@link TryMultiIpcBindingPortsTest}
+ */
+public class TryMultiIpcBindingPortsTest {
+
+ /**
+ * A local integration test on toy data
+ */
+ @Test
+ public void testToyData() throws Exception {
+
+ // a small graph with three components
+ String[] graph = new String[] {
+ "1 2 3",
+ "2 1 4 5",
+ "3 1 4",
+ "4 2 3 5 13",
+ "5 2 4 12 13",
+ "12 5 13",
+ "13 4 5 12",
+
+ "6 7 8",
+ "7 6 10 11",
+ "8 6 10",
+ "10 7 8 11",
+ "11 7 10",
+
+ "9" };
+
+ // run internally
+ // fail the first port binding attempt
+ Map<String, String> params = Maps.<String, String>newHashMap();
+ params.put(GiraphConfiguration.FAIL_FIRST_IPC_PORT_BIND_ATTEMPT, "true");
+ Iterable<String> results = InternalVertexRunner.run(
+ ConnectedComponentsVertex.class,
+ MinimumIntCombiner.class,
+ IntIntNullIntTextInputFormat.class,
+ IdWithValueTextOutputFormat.class,
+ params,
+ graph);
+
+ SetMultimap<Integer,Integer> components = parseResults(results);
+
+ Set<Integer> componentIDs = components.keySet();
+ assertEquals(3, componentIDs.size());
+ assertTrue(componentIDs.contains(1));
+ assertTrue(componentIDs.contains(6));
+ assertTrue(componentIDs.contains(9));
+
+ Set<Integer> componentOne = components.get(1);
+ assertEquals(7, componentOne.size());
+ assertTrue(componentOne.contains(1));
+ assertTrue(componentOne.contains(2));
+ assertTrue(componentOne.contains(3));
+ assertTrue(componentOne.contains(4));
+ assertTrue(componentOne.contains(5));
+ assertTrue(componentOne.contains(12));
+ assertTrue(componentOne.contains(13));
+
+ Set<Integer> componentTwo = components.get(6);
+ assertEquals(5, componentTwo.size());
+ assertTrue(componentTwo.contains(6));
+ assertTrue(componentTwo.contains(7));
+ assertTrue(componentTwo.contains(8));
+ assertTrue(componentTwo.contains(10));
+ assertTrue(componentTwo.contains(11));
+
+ Set<Integer> componentThree = components.get(9);
+ assertEquals(1, componentThree.size());
+ assertTrue(componentThree.contains(9));
+ }
+
+ private SetMultimap<Integer,Integer> parseResults(
+ Iterable<String> results) {
+ SetMultimap<Integer,Integer> components = HashMultimap.create();
+ for (String result : results) {
+ Iterable<String> parts = Splitter.on('\t').split(result);
+ int vertex = Integer.parseInt(Iterables.get(parts, 0));
+ int component = Integer.parseInt(Iterables.get(parts, 1));
+ components.put(component, vertex);
+ }
+ return components;
+ }
+}
Modified: giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java?rev=1397159&r1=1397158&r2=1397159&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/graph/TestEdgeListVertex.java Thu Oct 11 16:48:45 2012
@@ -107,7 +107,7 @@ public class TestEdgeListVertex {
for (int i = 1000; i > 0; --i) {
edgeMap.put(new IntWritable(i), new DoubleWritable(i * 2.0));
}
- vertex.initialize(null, null, edgeMap, null);
+ vertex.initialize(null, null, edgeMap);
assertEquals(vertex.getNumEdges(), 1000);
for (Edge<IntWritable, DoubleWritable> edge : vertex.getEdges()) {
assertEquals(edge.getValue().get(),
@@ -124,7 +124,7 @@ public class TestEdgeListVertex {
for (int i = 1000; i > 0; --i) {
edgeMap.put(new IntWritable(i), new DoubleWritable(i * 3.0));
}
- vertex.initialize(null, null, edgeMap, null);
+ vertex.initialize(null, null, edgeMap);
assertEquals(vertex.getNumEdges(), 1000);
assertEquals(vertex.getEdgeValue(new IntWritable(600)),
new DoubleWritable(600 * 3.0));
@@ -140,7 +140,7 @@ public class TestEdgeListVertex {
@Test
public void testAddRemoveEdges() {
Map<IntWritable, DoubleWritable> edgeMap = Maps.newHashMap();
- vertex.initialize(null, null, edgeMap, null);
+ vertex.initialize(null, null, edgeMap);
assertEquals(vertex.getNumEdges(), 0);
assertTrue(vertex.addEdge(new IntWritable(2),
new DoubleWritable(2.0)));
@@ -180,7 +180,7 @@ public class TestEdgeListVertex {
edgeMap.put(new IntWritable(2), new DoubleWritable(22));
edgeMap.put(new IntWritable(3), new DoubleWritable(33));
edgeMap.put(new IntWritable(4), new DoubleWritable(44));
- vertex.initialize(null, null, edgeMap, null);
+ vertex.initialize(null, null, edgeMap);
GiraphTransferRegulator gtr =
new GiraphTransferRegulator(job.getConfiguration());
PartitionOwner owner = mock(PartitionOwner.class);
@@ -197,11 +197,7 @@ public class TestEdgeListVertex {
for (int i = edgesCount; i > 0; --i) {
edgeMap.put(new IntWritable(i), new DoubleWritable(i * 2.0));
}
- List<LongWritable> messageList = Lists.newArrayList();
- messageList.add(new LongWritable(4));
- messageList.add(new LongWritable(5));
- vertex.initialize(
- new IntWritable(2), new FloatWritable(3.0f), edgeMap, messageList);
+ vertex.initialize(new IntWritable(2), new FloatWritable(3.0f), edgeMap);
long serializeNanosStart = SystemTime.getInstance().getNanoseconds();
byte[] byteArray = WritableUtils.writeToByteArray(vertex);
long serializeNanos = SystemTime.getInstance().getNanosecondsSince(
@@ -227,7 +223,5 @@ public class TestEdgeListVertex {
assertEquals(vertex.getValue(), readVertex.getValue());
assertEquals(Lists.newArrayList(vertex.getEdges()),
Lists.newArrayList(readVertex.getEdges()));
- assertEquals(Lists.newArrayList(vertex.getMessages()),
- Lists.newArrayList(readVertex.getMessages()));
}
}
Modified: giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java?rev=1397159&r1=1397158&r2=1397159&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/graph/TestIntIntNullIntVertex.java Thu Oct 11 16:48:45 2012
@@ -59,11 +59,7 @@ public class TestIntIntNullIntVertex {
edges.put(new IntWritable(3), NullWritable.get());
edges.put(new IntWritable(47), NullWritable.get());
- List<IntWritable> messages = Lists.newArrayList(new IntWritable(943),
- new IntWritable(571));
-
- vertex.initialize(new IntWritable(23), new IntWritable(7), edges,
- messages);
+ vertex.initialize(new IntWritable(23), new IntWritable(7), edges);
vertex.voteToHalt();
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
@@ -78,8 +74,6 @@ public class TestIntIntNullIntVertex {
vertex1.readFields(in);
assertEquals(2, vertex1.getNumEdges());
- assertEquals(Lists.newArrayList(new IntWritable(943),
- new IntWritable(571)), Lists.newArrayList(vertex1.getMessages()));
assertEquals(true, vertex1.isHalted());
}
}
Modified: giraph/trunk/src/test/java/org/apache/giraph/graph/partition/TestPartitionStores.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/graph/partition/TestPartitionStores.java?rev=1397159&r1=1397158&r2=1397159&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/graph/partition/TestPartitionStores.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/graph/partition/TestPartitionStores.java Thu Oct 11 16:48:45 2012
@@ -103,25 +103,25 @@ public class TestPartitionStores {
ImmutableClassesGiraphConfiguration conf) {
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v1 =
new MyVertex();
- v1.initialize(new IntWritable(1), new IntWritable(1), null, null);
+ v1.initialize(new IntWritable(1), new IntWritable(1));
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v2 =
new MyVertex();
- v2.initialize(new IntWritable(2), new IntWritable(2), null, null);
+ v2.initialize(new IntWritable(2), new IntWritable(2));
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v3 =
new MyVertex();
- v3.initialize(new IntWritable(3), new IntWritable(3), null, null);
+ v3.initialize(new IntWritable(3), new IntWritable(3));
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v4 =
new MyVertex();
- v4.initialize(new IntWritable(4), new IntWritable(4), null, null);
+ v4.initialize(new IntWritable(4), new IntWritable(4));
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v5 =
new MyVertex();
- v5.initialize(new IntWritable(5), new IntWritable(5), null, null);
+ v5.initialize(new IntWritable(5), new IntWritable(5));
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v6 =
new MyVertex();
- v6.initialize(new IntWritable(7), new IntWritable(7), null, null);
+ v6.initialize(new IntWritable(7), new IntWritable(7));
Vertex<IntWritable, IntWritable, NullWritable, IntWritable> v7 =
new MyVertex();
- v7.initialize(new IntWritable(7), new IntWritable(7), null, null);
+ v7.initialize(new IntWritable(7), new IntWritable(7));
partitionStore.addPartition(createPartition(conf, 1, v1, v2));
partitionStore.addPartition(createPartition(conf, 2, v3));
Modified: giraph/trunk/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java
URL: http://svn.apache.org/viewvc/giraph/trunk/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java?rev=1397159&r1=1397158&r2=1397159&view=diff
==============================================================================
--- giraph/trunk/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java (original)
+++ giraph/trunk/src/test/java/org/apache/giraph/io/TestTextDoubleDoubleAdjacencyListVertexInputFormat.java Thu Oct 11 16:48:45 2012
@@ -145,7 +145,7 @@ public class TestTextDoubleDoubleAdjacen
for(Edge<I, E> edge : edges) {
edgeMap.put(edge.getTargetVertexId(), edge.getValue());
}
- expected.initialize(expectedId, expectedValue, edgeMap, null);
+ expected.initialize(expectedId, expectedValue, edgeMap);
assertValid(expected, actual);
}