Author: edwardyoon
Date: Wed Nov 16 08:24:31 2011
New Revision: 1202580
URL: http://svn.apache.org/viewvc?rev=1202580&view=rev
Log:
Minor refactor
Added:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java
- copied, changed from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertex.java
- copied, changed from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertexArrayWritable.java
- copied, changed from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertexArrayWritable.java
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPaths.java
- copied, changed from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java
incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java
- copied, changed from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java
incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexArrayWritable.java
- copied, changed from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/VertexArrayWritable.java
Removed:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/
Modified:
incubator/hama/trunk/examples/pom.xml
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ExampleDriver.java
Modified: incubator/hama/trunk/examples/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/examples/pom.xml?rev=1202580&r1=1202579&r2=1202580&view=diff
==============================================================================
--- incubator/hama/trunk/examples/pom.xml (original)
+++ incubator/hama/trunk/examples/pom.xml Wed Nov 16 08:24:31 2011
@@ -37,6 +37,11 @@
<artifactId>hama-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.hama</groupId>
+ <artifactId>hama-graph</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
<build>
<finalName>hama-examples-${project.version}</finalName>
Modified:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ExampleDriver.java
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ExampleDriver.java?rev=1202580&r1=1202579&r2=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ExampleDriver.java
(original)
+++
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ExampleDriver.java
Wed Nov 16 08:24:31 2011
@@ -20,7 +20,6 @@
package org.apache.hama.examples;
import org.apache.hadoop.util.ProgramDriver;
-import org.apache.hama.examples.graph.ShortestPaths;
public class ExampleDriver {
Copied:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java
(from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java)
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java?p2=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java&p1=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java&r1=1202511&r2=1202580&rev=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java
(original)
+++
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/PageRank.java
Wed Nov 16 08:24:31 2011
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hama.examples.graph;
+package org.apache.hama.examples;
import java.io.IOException;
import java.util.HashMap;
@@ -43,6 +43,7 @@ import org.apache.hama.bsp.SequenceFileI
import org.apache.hama.bsp.SequenceFileOutputFormat;
import org.apache.hama.util.KeyValuePair;
import org.apache.zookeeper.KeeperException;
+import org.apache.hama.graph.Vertex;
public class PageRank extends
BSP<Vertex, ShortestPathVertexArrayWritable, Text, DoubleWritable> {
Copied:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertex.java
(from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java)
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertex.java?p2=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertex.java&p1=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java&r1=1202511&r2=1202580&rev=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java
(original)
+++
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertex.java
Wed Nov 16 08:24:31 2011
@@ -15,11 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hama.examples.graph;
+package org.apache.hama.examples;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
+import org.apache.hama.graph.Vertex;
public final class ShortestPathVertex extends Vertex {
Copied:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertexArrayWritable.java
(from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertexArrayWritable.java)
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertexArrayWritable.java?p2=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertexArrayWritable.java&p1=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertexArrayWritable.java&r1=1202511&r2=1202580&rev=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertexArrayWritable.java
(original)
+++
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPathVertexArrayWritable.java
Wed Nov 16 08:24:31 2011
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hama.examples.graph;
+package org.apache.hama.examples;
import org.apache.hadoop.io.ArrayWritable;
Copied:
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPaths.java
(from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java)
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPaths.java?p2=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPaths.java&p1=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java&r1=1202511&r2=1202580&rev=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java
(original)
+++
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/ShortestPaths.java
Wed Nov 16 08:24:31 2011
@@ -15,16 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hama.examples.graph;
+package org.apache.hama.examples;
import java.io.IOException;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.io.SequenceFile;
-import org.apache.hadoop.fs.FileStatus;
import java.util.Map.Entry;
import org.apache.commons.logging.Log;
@@ -35,10 +31,8 @@ import org.apache.hadoop.io.Text;
import org.apache.hama.HamaConfiguration;
import org.apache.hama.bsp.BSP;
import org.apache.hama.bsp.BSPJob;
-import org.apache.hama.bsp.BSPJobClient;
import org.apache.hama.bsp.BSPPeer;
import org.apache.hama.bsp.BooleanMessage;
-import org.apache.hama.bsp.ClusterStatus;
import org.apache.hama.bsp.HashPartitioner;
import org.apache.hama.bsp.IntegerMessage;
import org.apache.hama.bsp.SequenceFileInputFormat;
@@ -110,16 +104,13 @@ public class ShortestPaths extends
@Override
public void cleanup(
- BSPPeer<ShortestPathVertex, ShortestPathVertexArrayWritable, Text,
IntWritable> peer) {
+ BSPPeer<ShortestPathVertex, ShortestPathVertexArrayWritable, Text,
IntWritable> peer)
+ throws IOException {
// write our map into hdfs
for (Entry<ShortestPathVertex, ShortestPathVertex[]> entry : adjacencyList
.entrySet()) {
- try {
- peer.write(new Text(entry.getKey().getName()), new IntWritable(entry
- .getKey().getCost()));
- } catch (IOException e) {
- e.printStackTrace();
- }
+ peer.write(new Text(entry.getKey().getName()), new IntWritable(entry
+ .getKey().getCost()));
}
}
@@ -187,28 +178,6 @@ public class ShortestPaths extends
System.out.println("Usage: <startNode> <output path> <input path>");
}
- public static void printOutput(Configuration conf) throws IOException {
- FileSystem fs = FileSystem.get(conf);
- LOG.info("-------------------- RESULTS --------------------");
- FileStatus[] stati = fs.listStatus(new Path(conf.get("bsp.output.dir")));
- for (FileStatus status : stati) {
- if (!status.isDir() && !status.getPath().getName().endsWith(".crc")) {
- Path path = status.getPath();
- SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
- Text key = new Text();
- IntWritable value = new IntWritable();
- int x = 0;
- while (reader.next(key, value)) {
- LOG.info(key.toString() + " | " + value.get());
- x++;
- if(x > 3)
- break;
- }
- reader.close();
- }
- }
- }
-
public static void main(String[] args) throws IOException,
InterruptedException, ClassNotFoundException, InstantiationException,
IllegalAccessException {
@@ -234,15 +203,10 @@ public class ShortestPaths extends
bsp.setOutputFormat(SequenceFileOutputFormat.class);
bsp.setOutputKeyClass(Text.class);
bsp.setOutputValueClass(IntWritable.class);
-
- BSPJobClient jobClient = new BSPJobClient(conf);
- ClusterStatus cluster = jobClient.getClusterStatus(false);
- // Use max tasks
bsp.setNumBspTask(6);
long startTime = System.currentTimeMillis();
if (bsp.waitForCompletion(true)) {
- printOutput(conf);
System.out.println("Job Finished in "
+ (double) (System.currentTimeMillis() - startTime) / 1000.0
+ " seconds");
Copied:
incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java
(from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java)
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java?p2=incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java&p1=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java&r1=1202511&r2=1202580&rev=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java
(original)
+++ incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/Vertex.java
Wed Nov 16 08:24:31 2011
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hama.examples.graph;
+package org.apache.hama.graph;
import java.io.DataInput;
import java.io.DataOutput;
Copied:
incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexArrayWritable.java
(from r1202511,
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/VertexArrayWritable.java)
URL:
http://svn.apache.org/viewvc/incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexArrayWritable.java?p2=incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexArrayWritable.java&p1=incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/VertexArrayWritable.java&r1=1202511&r2=1202580&rev=1202580&view=diff
==============================================================================
---
incubator/hama/trunk/examples/src/main/java/org/apache/hama/examples/graph/VertexArrayWritable.java
(original)
+++
incubator/hama/trunk/graph/src/main/java/org/apache/hama/graph/VertexArrayWritable.java
Wed Nov 16 08:24:31 2011
@@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.hama.examples.graph;
+package org.apache.hama.graph;
import org.apache.hadoop.io.ArrayWritable;