You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by tj...@apache.org on 2011/09/27 11:35:48 UTC

svn commit: r1176297 [15/19] - in /incubator/hama/branches/HamaV2: ./ api/ api/target/ api/target/classes/ api/target/classes/META-INF/ api/target/lib/ api/target/maven-archiver/ api/target/maven-shared-archive-resources/ api/target/maven-shared-archiv...

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,245 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hama.HamaConfiguration;
+import org.apache.hama.bsp.BSPJob;
+import org.apache.hama.bsp.BSPJobClient;
+import org.apache.hama.bsp.BSPPeer;
+import org.apache.hama.bsp.ClusterStatus;
+import org.apache.hama.bsp.DoubleMessage;
+import org.apache.zookeeper.KeeperException;
+
+public class PageRank extends PageRankBase {
+  public static final Log LOG = LogFactory.getLog(PageRank.class);
+
+  private Configuration conf;
+
+  private final HashMap<Vertex, List<Vertex>> adjacencyList = new HashMap<Vertex, List<Vertex>>();
+  private final HashMap<String, Vertex> lookupMap = new HashMap<String, Vertex>();
+  private final HashMap<Vertex, Double> tentativePagerank = new HashMap<Vertex, Double>();
+  // backup of the last pagerank to determine the error
+  private final HashMap<Vertex, Double> lastTentativePagerank = new HashMap<Vertex, Double>();
+  private String[] peerNames;
+
+  @Override
+  public void bsp(BSPPeer peer) throws IOException, KeeperException,
+      InterruptedException {
+    String master = conf.get(MASTER_TASK);
+    // setup the datasets
+    PageRankBase.mapAdjacencyList(getConf(), peer, adjacencyList,
+        tentativePagerank, lookupMap);
+
+    // while the error not converges against epsilon do the pagerank stuff
+    double error = 1.0;
+    int iteration = 0;
+    // if MAX_ITERATIONS are set to 0, ignore the iterations and just go
+    // with the error
+    while ((MAX_ITERATIONS > 0 && iteration < MAX_ITERATIONS)
+        || error >= EPSILON) {
+      peer.sync();
+
+      if (iteration >= 1) {
+        // copy the old pagerank to the backup
+        copyTentativePageRankToBackup();
+        // sum up all incoming messages for a vertex
+        HashMap<Vertex, Double> sumMap = new HashMap<Vertex, Double>();
+        DoubleMessage msg = null;
+        while ((msg = (DoubleMessage) peer.getCurrentMessage()) != null) {
+          Vertex k = lookupMap.get(msg.getTag());
+          if (!sumMap.containsKey(k)) {
+            sumMap.put(k, msg.getData());
+          } else {
+            sumMap.put(k, msg.getData() + sumMap.get(k));
+          }
+        }
+        // pregel formula:
+        // ALPHA = 0.15 / NumVertices()
+        // P(i) = ALPHA + 0.85 * sum
+        for (Entry<Vertex, Double> entry : sumMap.entrySet()) {
+          tentativePagerank.put(entry.getKey(), ALPHA
+              + (entry.getValue() * DAMPING_FACTOR));
+        }
+
+        // determine the error and send this to the master
+        double err = determineError();
+        error = broadcastError(peer, master, err);
+      }
+      // in every step send the tentative pagerank of a vertex to its
+      // adjacent vertices
+      for (Vertex vertex : adjacencyList.keySet()) {
+        sendMessageToNeighbors(peer, vertex);
+      }
+
+      iteration++;
+    }
+
+    // Clears all queues entries.
+    peer.clear();
+    // finally save the chunk of pageranks
+    PageRankBase.savePageRankMap(peer, conf, lastTentativePagerank);
+  }
+
+  private double broadcastError(BSPPeer peer, String master, double error)
+      throws IOException, KeeperException, InterruptedException {
+    peer.send(master, new DoubleMessage("", error));
+    peer.sync();
+    if (peer.getPeerName().equals(master)) {
+      double errorSum = 0.0;
+      int count = 0;
+      DoubleMessage message;
+      while ((message = (DoubleMessage) peer.getCurrentMessage()) != null) {
+        errorSum += message.getData();
+        count++;
+      }
+      double avgError = errorSum / (double) count;
+      // LOG.info("Average error: " + avgError);
+      for (String name : peer.getAllPeerNames()) {
+        peer.send(name, new DoubleMessage("", avgError));
+      }
+    }
+
+    peer.sync();
+    DoubleMessage message = (DoubleMessage) peer.getCurrentMessage();
+    return message.getData();
+  }
+
+  private double determineError() {
+    double error = 0.0;
+    for (Entry<Vertex, Double> entry : tentativePagerank.entrySet()) {
+      error += Math.abs(lastTentativePagerank.get(entry.getKey())
+          - entry.getValue());
+    }
+    return error;
+  }
+
+  private void copyTentativePageRankToBackup() {
+    for (Entry<Vertex, Double> entry : tentativePagerank.entrySet()) {
+      lastTentativePagerank.put(entry.getKey(), entry.getValue());
+    }
+  }
+
+  private void sendMessageToNeighbors(BSPPeer peer, Vertex v)
+      throws IOException {
+    List<Vertex> outgoingEdges = adjacencyList.get(v);
+    for (Vertex adjacent : outgoingEdges) {
+      int mod = Math.abs(adjacent.getId() % peerNames.length);
+      // send a message of the tentative pagerank divided by the size of
+      // the outgoing edges to all adjacents
+      peer.send(peerNames[mod], new DoubleMessage(adjacent.getName(),
+          tentativePagerank.get(v) / outgoingEdges.size()));
+    }
+  }
+
+  @Override
+  public void setConf(Configuration conf) {
+    this.conf = conf;
+    numOfVertices = Integer.parseInt(conf.get("num.vertices"));
+    DAMPING_FACTOR = Double.parseDouble(conf.get("damping.factor"));
+    ALPHA = (1 - DAMPING_FACTOR) / (double) numOfVertices;
+    EPSILON = Double.parseDouble(conf.get("epsilon.error"));
+    MAX_ITERATIONS = Integer.parseInt(conf.get("max.iterations"));
+    peerNames = conf.get(ShortestPaths.BSP_PEERS).split(";");
+  }
+
+  @Override
+  public Configuration getConf() {
+    return conf;
+  }
+
+  public static void printUsage() {
+    System.out.println("PageRank Example:");
+    System.out
+        .println("<damping factor> <epsilon error> <optional: output path> <optional: input path>");
+  }
+
+  public static void main(String[] args) throws IOException,
+      InterruptedException, ClassNotFoundException, InstantiationException,
+      IllegalAccessException {
+    if (args.length == 0) {
+      printUsage();
+      System.exit(-1);
+    }
+
+    HamaConfiguration conf = new HamaConfiguration(new Configuration());
+    // set the defaults
+    conf.set("damping.factor", "0.85");
+    conf.set("epsilon.error", "0.000001");
+
+    if (args.length < 2) {
+      System.out.println("You have to provide a damping factor and an error!");
+      System.out.println("Try using 0.85 0.001 as parameter!");
+      System.exit(-1);
+    } else {
+      conf.set("damping.factor", args[0]);
+      conf.set("epsilon.error", args[1]);
+      LOG.info("Set damping factor to " + args[0]);
+      LOG.info("Set epsilon error to " + args[1]);
+      if (args.length > 2) {
+        conf.set("out.path", args[2]);
+        LOG.info("Set output path to " + args[2]);
+        if (args.length == 4) {
+          conf.set("in.path", args[3]);
+          LOG.info("Using custom input at " + args[3]);
+        } else {
+          LOG.info("Running default example graph!");
+        }
+      } else {
+        conf.set("out.path", "pagerank/output");
+        LOG.info("Set output path to default of pagerank/output!");
+      }
+    }
+
+    BSPJobClient jobClient = new BSPJobClient(conf);
+    ClusterStatus cluster = jobClient.getClusterStatus(true);
+
+    // leave the iterations on default
+    conf.set("max.iterations", "0");
+
+    Collection<String> activeGrooms = cluster.getActiveGroomNames().keySet();
+    String[] grooms = activeGrooms.toArray(new String[activeGrooms.size()]);
+
+    if (conf.get("in.path") == null) {
+      conf = PageRankBase.partitionExample(new Path(conf.get("out.path")),
+          conf, grooms);
+    } else {
+      conf = PageRankBase.partitionTextFile(new Path(conf.get("in.path")),
+          conf, grooms);
+    }
+
+    BSPJob job = new BSPJob(conf);
+    job.setNumBspTask(cluster.getGroomServers());
+    job.setBspClass(PageRank.class);
+    job.setJarByClass(PageRank.class);
+    job.setJobName("Pagerank");
+    if (job.waitForCompletion(true)) {
+      PageRankBase.printOutput(FileSystem.get(conf), conf);
+    }
+  }
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRank.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankBase.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankBase.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankBase.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,175 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.io.BufferedWriter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.DoubleWritable;
+import org.apache.hadoop.io.ObjectWritable;
+import org.apache.hadoop.io.SequenceFile;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
+import org.apache.hama.HamaConfiguration;
+import org.apache.hama.bsp.BSP;
+import org.apache.hama.bsp.BSPPeer;
+import org.apache.hama.examples.graph.partitioning.PartitionableWritable;
+import org.apache.hama.examples.graph.partitioning.VertexPartitioner;
+
+public abstract class PageRankBase extends BSP {
+  public static final Log LOG = LogFactory.getLog(PageRankBase.class);
+
+  protected static int MAX_ITERATIONS = 30;
+  protected static final String MASTER_TASK = "master.groom";
+  protected static double ALPHA;
+  protected static int numOfVertices;
+  protected static double DAMPING_FACTOR = 0.85;
+  protected static double EPSILON = 0.001;
+
+  private static final VertexPartitioner partitioner = new VertexPartitioner();
+
+  static void mapAdjacencyList(Configuration conf, BSPPeer peer,
+      HashMap<Vertex, List<Vertex>> realAdjacencyList,
+      HashMap<Vertex, Double> tentativePagerank,
+      HashMap<String, Vertex> lookupMap) throws FileNotFoundException,
+      IOException {
+
+    FileSystem fs = FileSystem.get(conf);
+    Path p = new Path(conf.get("in.path." + peer.getPeerName().split(":")[0]));
+    SequenceFile.Reader reader = new SequenceFile.Reader(fs, p, conf);
+    ObjectWritable key = new ObjectWritable(Vertex.class);
+    key.setConf(conf);
+    ArrayWritable value = new ArrayWritable(Vertex.class);
+    while (reader.next(key, value)) {
+      Vertex realKey = (Vertex) key.get();
+      LinkedList<Vertex> list = new LinkedList<Vertex>();
+      realAdjacencyList.put(realKey, list);
+      lookupMap.put(realKey.name, realKey);
+      tentativePagerank.put(realKey, Double.valueOf(1.0 / numOfVertices));
+      for (Writable s : value.get()) {
+        list.add((Vertex) s);
+      }
+    }
+
+    reader.close();
+  }
+
+  static HamaConfiguration partitionTextFile(Path in, HamaConfiguration conf,
+      String[] groomNames) throws IOException, InstantiationException,
+      IllegalAccessException, InterruptedException {
+
+    // set the partitioning vertex class
+    conf.setClass("hama.partitioning.vertex.class", Vertex.class,
+        PartitionableWritable.class);
+
+    return (HamaConfiguration) partitioner.partition(conf, in, groomNames);
+  }
+
+  static HamaConfiguration partitionExample(Path out, HamaConfiguration conf,
+      String[] groomNames) throws IOException, InstantiationException,
+      IllegalAccessException, InterruptedException {
+
+    /**
+     * 1:twitter.com <br/>
+     * 2:google.com <br/>
+     * 3:facebook.com <br/>
+     * 4:yahoo.com <br/>
+     * 5:nasa.gov <br/>
+     * 6:stackoverflow.com <br/>
+     * 7:youtube.com
+     */
+
+    FileSystem fs = FileSystem.get(conf);
+    Path input = new Path(out, "pagerank-example");
+    FSDataOutputStream stream = fs.create(input);
+    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream));
+
+    String[] realNames = new String[] { null, "twitter.com", "google.com",
+        "facebook.com", "yahoo.com", "nasa.gov", "stackoverflow.com",
+        "youtube.com" };
+
+    String[] lineArray = new String[] { "1;2;3", "2", "3;1;2;5", "4;5;6",
+        "5;4;6", "6;4", "7;2;4" };
+
+    for (String line : lineArray) {
+      String[] arr = line.split(";");
+      String vId = arr[0];
+      int indexKey = Integer.valueOf(vId);
+
+      String adjacents = "";
+      for (int i = 1; i < arr.length; i++) {
+        int index = Integer.valueOf(arr[i]);
+        adjacents += realNames[index] + "\t";
+      }
+      writer.write(realNames[indexKey] + "\t" + adjacents);
+      writer.newLine();
+    }
+
+    writer.close();
+
+    return partitionTextFile(input, conf, groomNames);
+  }
+
+  static void savePageRankMap(BSPPeer peer, Configuration conf,
+      Map<Vertex, Double> tentativePagerank) throws IOException {
+    FileSystem fs = FileSystem.get(conf);
+    Path outPath = new Path(conf.get("out.path") + Path.SEPARATOR + "temp"
+        + Path.SEPARATOR
+        + peer.getPeerName().split(ShortestPaths.NAME_VALUE_SEPARATOR)[0]);
+    fs.delete(outPath, true);
+    final SequenceFile.Writer out = SequenceFile.createWriter(fs, conf,
+        outPath, Text.class, DoubleWritable.class);
+    for (Entry<Vertex, Double> row : tentativePagerank.entrySet()) {
+      out.append(new Text(row.getKey().getName()),
+          new DoubleWritable(row.getValue()));
+    }
+    out.close();
+  }
+
+  static void printOutput(FileSystem fs, Configuration conf) throws IOException {
+    LOG.info("-------------------- RESULTS --------------------");
+    FileStatus[] stati = fs.listStatus(new Path(conf.get("out.path")
+        + Path.SEPARATOR + "temp"));
+    for (FileStatus status : stati) {
+      Path path = status.getPath();
+      SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
+      Text key = new Text();
+      DoubleWritable value = new DoubleWritable();
+      while (reader.next(key, value)) {
+        LOG.info(key.toString() + " | " + value.get());
+      }
+      reader.close();
+    }
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankVertex.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankVertex.java?rev=1176297&view=auto
==============================================================================
    (empty)

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/PageRankVertex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,80 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+public final class ShortestPathVertex extends Vertex {
+
+  private int weight;
+  private Integer cost;
+
+  public ShortestPathVertex() {
+  }
+
+  public ShortestPathVertex(int weight, String name) {
+    super(name);
+    this.weight = weight;
+  }
+
+  public ShortestPathVertex(int weight, String name, Integer cost) {
+    super(name);
+    this.weight = weight;
+    this.cost = cost;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+  public Integer getCost() {
+    return cost;
+  }
+
+  public void setCost(Integer cost) {
+    this.cost = cost;
+  }
+
+  public int getId() {
+    return id;
+  }
+
+  public int getWeight() {
+    return weight;
+  }
+
+  @Override
+  public String toString() {
+    return name;
+  }
+
+  @Override
+  public void readFields(DataInput in) throws IOException {
+    super.readFields(in);
+    weight = in.readInt();
+  }
+
+  @Override
+  public void write(DataOutput out) throws IOException {
+    super.write(out);
+    out.writeInt(weight);
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathVertex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,243 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hama.HamaConfiguration;
+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.IntegerMessage;
+import org.apache.hama.examples.RandBench;
+import org.apache.zookeeper.KeeperException;
+
+public class ShortestPaths extends ShortestPathsBase {
+  public static final Log LOG = LogFactory.getLog(ShortestPaths.class);
+
+  private Configuration conf;
+  private final HashMap<ShortestPathVertex, List<ShortestPathVertex>> adjacencyList = new HashMap<ShortestPathVertex, List<ShortestPathVertex>>();
+  private final HashMap<String, ShortestPathVertex> vertexLookupMap = new HashMap<String, ShortestPathVertex>();
+  private String[] peerNames;
+
+  @Override
+  public void bsp(BSPPeer peer) throws IOException, KeeperException,
+      InterruptedException {
+    // map our input into ram
+    mapAdjacencyList(conf, peer, adjacencyList, vertexLookupMap);
+    // parse the configuration to get the peerNames
+    parsePeerNames(conf);
+    // get our master groom
+    String master = conf.get(MASTER_TASK);
+
+    // initial message bypass
+    ShortestPathVertex v = vertexLookupMap.get(conf
+        .get(SHORTEST_PATHS_START_VERTEX_ID));
+    if (v != null) {
+      v.setCost(0);
+      sendMessageToNeighbors(peer, v);
+    }
+
+    boolean updated = true;
+    while (updated) {
+      int updatesMade = 0;
+      peer.sync();
+
+      IntegerMessage msg = null;
+      Deque<ShortestPathVertex> updatedQueue = new LinkedList<ShortestPathVertex>();
+      while ((msg = (IntegerMessage) peer.getCurrentMessage()) != null) {
+        ShortestPathVertex vertex = vertexLookupMap.get(msg.getTag());
+        // check if we need an distance update
+        if (vertex.getCost() > msg.getData()) {
+          updatesMade++;
+          updatedQueue.add(vertex);
+          vertex.setCost(msg.getData());
+        }
+      }
+      // synchonize with all grooms if there were updates
+      updated = broadcastUpdatesMade(peer, master, updatesMade);
+      // send updates to the adjacents of the updated vertices
+      for (ShortestPathVertex vertex : updatedQueue) {
+        sendMessageToNeighbors(peer, vertex);
+      }
+    }
+    // finished, finally save our map to DFS.
+    saveVertexMap(conf, peer, adjacencyList);
+  }
+
+  /**
+   * Parses the peer names to fix inconsistency in bsp peer names from context.
+   * 
+   * @param conf
+   */
+  private void parsePeerNames(Configuration conf) {
+    peerNames = conf.get(BSP_PEERS).split(";");
+  }
+
+  /**
+   * This method broadcasts to a master groom how many updates were made. He
+   * simply sums them up and sends a message back to the grooms if sum is
+   * greater than zero.
+   * 
+   * @param peer The peer we got through the BSP method.
+   * @param master The assigned master groom name.
+   * @param updates How many updates were made?
+   * @return True if we need another iteration, False if no updates can be made
+   *         anymore.
+   * @throws IOException
+   * @throws KeeperException
+   * @throws InterruptedException
+   */
+  private boolean broadcastUpdatesMade(BSPPeer peer, String master, int updates)
+      throws IOException, KeeperException, InterruptedException {
+    peer.send(master, new IntegerMessage(peer.getPeerName(), updates));
+    peer.sync();
+    if (peer.getPeerName().equals(master)) {
+      int count = 0;
+      IntegerMessage message;
+      while ((message = (IntegerMessage) peer.getCurrentMessage()) != null) {
+        count += message.getData();
+      }
+
+      for (String name : peer.getAllPeerNames()) {
+        peer.send(name, new BooleanMessage("", count > 0 ? true : false));
+      }
+    }
+
+    peer.sync();
+    BooleanMessage message = (BooleanMessage) peer.getCurrentMessage();
+    return message.getData();
+  }
+
+  /**
+   * This method takes advantage of our partitioning: it uses the vertexID
+   * (simply hash of the name) to determine the host where the message belongs
+   * to. <br/>
+   * It sends the current cost to the adjacent vertex + the edge weight. If cost
+   * will be infinity we just going to send infinity, because summing the weight
+   * will cause an integer overflow resulting in negative weights.
+   * 
+   * @param peer The peer we got through the BSP method.
+   * @param id The vertex to all adjacent vertices the new cost has to be send.
+   * @throws IOException
+   */
+  private void sendMessageToNeighbors(BSPPeer peer, ShortestPathVertex id)
+      throws IOException {
+    List<ShortestPathVertex> outgoingEdges = adjacencyList.get(id);
+    for (ShortestPathVertex adjacent : outgoingEdges) {
+      int mod = Math.abs((adjacent.getId() % peer.getAllPeerNames().length));
+      peer.send(peerNames[mod],
+          new IntegerMessage(adjacent.getName(),
+              id.getCost() == Integer.MAX_VALUE ? id.getCost() : id.getCost()
+                  + adjacent.getWeight()));
+    }
+  }
+
+  @Override
+  public void setConf(Configuration conf) {
+    this.conf = conf;
+  }
+
+  @Override
+  public Configuration getConf() {
+    return conf;
+  }
+
+  public static void printUsage() {
+    System.out.println("Single Source Shortest Path Example:");
+    System.out
+        .println("<Startvertex name> <optional: output path> <optional: path to own adjacency list textfile!>");
+  }
+
+  public static void main(String[] args) throws IOException,
+      InterruptedException, ClassNotFoundException, InstantiationException,
+      IllegalAccessException {
+
+    printUsage();
+
+    // BSP job configuration
+    HamaConfiguration conf = new HamaConfiguration();
+    conf.set(SHORTEST_PATHS_START_VERTEX_ID, "Frankfurt");
+    System.out.println("Setting default start vertex to \"Frankfurt\"!");
+    conf.set(OUT_PATH, "sssp/output");
+    Path adjacencyListPath = null;
+
+    if (args.length > 0) {
+      conf.set(SHORTEST_PATHS_START_VERTEX_ID, args[0]);
+      System.out.println("Setting start vertex to " + args[0] + "!");
+
+      if (args.length > 1) {
+        conf.set(OUT_PATH, args[1]);
+        System.out.println("Using new output folder: " + args[1]);
+      }
+
+      if (args.length > 2) {
+        adjacencyListPath = new Path(args[2]);
+      }
+
+    }
+
+    Map<ShortestPathVertex, List<ShortestPathVertex>> adjacencyList = null;
+    if (adjacencyListPath == null)
+      adjacencyList = ShortestPathsGraphLoader.loadGraph();
+
+    BSPJob bsp = new BSPJob(conf, RandBench.class);
+    // Set the job name
+    bsp.setJobName("Single Source Shortest Path");
+    bsp.setBspClass(ShortestPaths.class);
+
+    // Set the task size as a number of GroomServer
+    BSPJobClient jobClient = new BSPJobClient(conf);
+    ClusterStatus cluster = jobClient.getClusterStatus(true);
+
+    Collection<String> activeGrooms = cluster.getActiveGroomNames().keySet();
+    String[] grooms = activeGrooms.toArray(new String[activeGrooms.size()]);
+
+    LOG.info("Starting data partitioning...");
+    if (adjacencyList == null) {
+      conf = (HamaConfiguration) partition(conf, adjacencyListPath, grooms);
+    } else {
+      conf = (HamaConfiguration) partitionExample(conf, adjacencyList, grooms);
+    }
+    LOG.info("Finished!");
+
+    bsp.setNumBspTask(cluster.getGroomServers());
+
+    long startTime = System.currentTimeMillis();
+    if (bsp.waitForCompletion(true)) {
+      System.out.println("Job Finished in "
+          + (double) (System.currentTimeMillis() - startTime) / 1000.0
+          + " seconds");
+      printOutput(FileSystem.get(conf), conf);
+    }
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPaths.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsBase.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsBase.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsBase.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsBase.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,179 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.io.BufferedWriter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FSDataOutputStream;
+import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.IntWritable;
+import org.apache.hadoop.io.ObjectWritable;
+import org.apache.hadoop.io.SequenceFile;
+import org.apache.hadoop.io.Text;
+import org.apache.hadoop.io.Writable;
+import org.apache.hama.bsp.BSP;
+import org.apache.hama.bsp.BSPPeer;
+import org.apache.hama.examples.graph.partitioning.PartitionableWritable;
+import org.apache.hama.examples.graph.partitioning.ShortestPathVertexPartitioner;
+
+public abstract class ShortestPathsBase extends BSP {
+
+  private static final String SSSP_EXAMPLE_FILE_NAME = "sssp-example";
+  public static final String BSP_PEERS = "bsp.peers";
+  public static final String SHORTEST_PATHS_START_VERTEX_ID = "shortest.paths.start.vertex.id";
+  public static final String PARTED = "parted";
+  public static final String IN_PATH = "in.path.";
+  public static final String OUT_PATH = "out.path";
+  public static final String NAME_VALUE_SEPARATOR = ":";
+  public static final String MASTER_TASK = "master.groom";
+
+  private static final ShortestPathVertexPartitioner partitioner = new ShortestPathVertexPartitioner();
+
+  /**
+   * When finished we just writing a sequencefile of the vertex name and the
+   * cost.
+   * 
+   * @param peer The peer we got through the BSP method.
+   * @param adjacencyList
+   * @throws IOException
+   */
+  protected final static void saveVertexMap(Configuration conf, BSPPeer peer,
+      Map<ShortestPathVertex, List<ShortestPathVertex>> adjacencyList)
+      throws IOException {
+    Path outPath = new Path(conf.get(OUT_PATH) + Path.SEPARATOR
+        + peer.getPeerName().split(":")[0]);
+    FileSystem fs = FileSystem.get(conf);
+    fs.delete(outPath, true);
+    final SequenceFile.Writer out = SequenceFile.createWriter(fs, conf,
+        outPath, Text.class, IntWritable.class);
+    for (ShortestPathVertex vertex : adjacencyList.keySet()) {
+      out.append(new Text(vertex.getName()), new IntWritable(vertex.getCost()));
+    }
+    out.close();
+  }
+
+  /**
+   * Just a reader of the vertexMap in DFS. Output going to STDOUT.
+   * 
+   * @param fs
+   * @param conf
+   * @throws IOException
+   */
+  protected final static void printOutput(FileSystem fs, Configuration conf)
+      throws IOException {
+    System.out.println("-------------------- RESULTS --------------------");
+    FileStatus[] stati = fs.listStatus(new Path(conf.get(OUT_PATH)));
+    for (FileStatus status : stati) {
+      if (!status.isDir() && !status.getPath().getName().equals(SSSP_EXAMPLE_FILE_NAME)) {
+        Path path = status.getPath();
+        SequenceFile.Reader reader = new SequenceFile.Reader(fs, path, conf);
+        Text key = new Text();
+        IntWritable value = new IntWritable();
+        while (reader.next(key, value)) {
+          System.out.println(key.toString() + " | " + value.get());
+        }
+        reader.close();
+      }
+    }
+  }
+
+  protected final static void mapAdjacencyList(Configuration conf,
+      BSPPeer peer,
+      Map<ShortestPathVertex, List<ShortestPathVertex>> adjacencyList,
+      Map<String, ShortestPathVertex> vertexLookupMap)
+      throws FileNotFoundException, IOException {
+
+    FileSystem fs = FileSystem.get(conf);
+    Path p = new Path(conf.get("in.path." + peer.getPeerName().split(":")[0]));
+    SequenceFile.Reader reader = new SequenceFile.Reader(fs, p, conf);
+    ObjectWritable key = new ObjectWritable(ShortestPathVertex.class);
+    key.setConf(conf);
+    ArrayWritable value = new ArrayWritable(ShortestPathVertex.class);
+    while (reader.next(key, value)) {
+      ShortestPathVertex realKey = (ShortestPathVertex) key.get();
+      realKey.setCost(Integer.MAX_VALUE);
+      LinkedList<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+      adjacencyList.put(realKey, list);
+      vertexLookupMap.put(realKey.name, realKey);
+
+      for (Writable s : value.get()) {
+        final ShortestPathVertex vertex = (ShortestPathVertex) s;
+        vertex.setCost(Integer.MAX_VALUE);
+        list.add(vertex);
+      }
+    }
+
+    reader.close();
+  }
+
+  protected final static Configuration partitionExample(Configuration conf,
+      Map<ShortestPathVertex, List<ShortestPathVertex>> adjacencyList,
+      String[] groomNames) throws IOException, InstantiationException,
+      IllegalAccessException, InterruptedException {
+
+    FileSystem fs = FileSystem.get(conf);
+    Path input = new Path(conf.get(OUT_PATH), SSSP_EXAMPLE_FILE_NAME);
+    FSDataOutputStream stream = fs.create(input);
+    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream));
+
+    Set<Entry<ShortestPathVertex, List<ShortestPathVertex>>> set = adjacencyList
+        .entrySet();
+
+    for (Entry<ShortestPathVertex, List<ShortestPathVertex>> entry : set) {
+
+      String line = entry.getKey().getName();
+
+      for (ShortestPathVertex v : entry.getValue()) {
+        line += "\t" + v.getName() + ":" + v.getWeight();
+      }
+
+      writer.write(line);
+      writer.newLine();
+
+    }
+
+    writer.close();
+
+    return partition(conf, input, groomNames);
+  }
+
+  protected final static Configuration partition(Configuration conf,
+      Path fileToPartition, String[] groomNames) throws IOException,
+      InstantiationException, IllegalAccessException, InterruptedException {
+
+    // set the partitioning vertex class
+    conf.setClass("hama.partitioning.vertex.class", ShortestPathVertex.class,
+        PartitionableWritable.class);
+
+    return partitioner.partition(conf, fileToPartition, groomNames);
+
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsBase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsGraphLoader.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsGraphLoader.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsGraphLoader.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsGraphLoader.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,92 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+public class ShortestPathsGraphLoader {
+  
+  static Map<ShortestPathVertex, List<ShortestPathVertex>> loadGraph() {
+
+    Map<ShortestPathVertex, List<ShortestPathVertex>> adjacencyList = new HashMap<ShortestPathVertex, List<ShortestPathVertex>>();
+    String[] cities = new String[] { "Frankfurt", "Mannheim", "Wuerzburg",
+        "Stuttgart", "Kassel", "Karlsruhe", "Erfurt", "Nuernberg", "Augsburg",
+        "Muenchen" };
+
+    for (String city : cities) {
+      if (city.equals("Frankfurt")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(85, "Mannheim"));
+        list.add(new ShortestPathVertex(173, "Kassel"));
+        list.add(new ShortestPathVertex(217, "Wuerzburg"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Stuttgart")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(183, "Nuernberg"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Kassel")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(502, "Muenchen"));
+        list.add(new ShortestPathVertex(173, "Frankfurt"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Erfurt")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(186, "Wuerzburg"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Wuerzburg")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(217, "Frankfurt"));
+        list.add(new ShortestPathVertex(168, "Erfurt"));
+        list.add(new ShortestPathVertex(103, "Nuernberg"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Mannheim")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(80, "Karlsruhe"));
+        list.add(new ShortestPathVertex(85, "Frankfurt"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Karlsruhe")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(250, "Augsburg"));
+        list.add(new ShortestPathVertex(80, "Mannheim"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Augsburg")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(250, "Karlsruhe"));
+        list.add(new ShortestPathVertex(84, "Muenchen"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Nuernberg")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(183, "Stuttgart"));
+        list.add(new ShortestPathVertex(167, "Muenchen"));
+        list.add(new ShortestPathVertex(103, "Wuerzburg"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      } else if (city.equals("Muenchen")) {
+        List<ShortestPathVertex> list = new LinkedList<ShortestPathVertex>();
+        list.add(new ShortestPathVertex(167, "Nuernberg"));
+        list.add(new ShortestPathVertex(173, "Kassel"));
+        list.add(new ShortestPathVertex(84, "Augsburg"));
+        adjacencyList.put(new ShortestPathVertex(0, city), list);
+      }
+    }
+    return adjacencyList;
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/ShortestPathsGraphLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,81 @@
+/**
+ * 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.hama.examples.graph;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.hama.examples.graph.partitioning.PartitionableWritable;
+
+public class Vertex implements PartitionableWritable {
+
+  protected int id;
+  protected String name;
+
+  public Vertex() {
+    super();
+  }
+
+  public Vertex(String name) {
+    super();
+    this.name = name;
+    this.id = name.hashCode();
+  }
+
+  @Override
+  public void readFields(DataInput in) throws IOException {
+    this.id = in.readInt();
+    this.name = in.readUTF();
+  }
+
+  @Override
+  public void write(DataOutput out) throws IOException {
+    out.writeInt(id);
+    out.writeUTF(name);
+  }
+
+  @Override
+  public int hashCode() {
+    return id;
+  }
+
+  @Override
+  public boolean equals(Object obj) {
+    if (this == obj)
+      return true;
+    if (obj == null)
+      return false;
+    if (getClass() != obj.getClass())
+      return false;
+    Vertex other = (Vertex) obj;
+    if (!name.equals(other.name))
+      return false;
+    return true;
+  }
+
+  @Override
+  public int getId() {
+    return id;
+  }
+
+  public String getName() {
+    return name;
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/Vertex.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AbstractGraphPartitioner.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AbstractGraphPartitioner.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AbstractGraphPartitioner.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AbstractGraphPartitioner.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,131 @@
+/**
+ * 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.hama.examples.graph.partitioning;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.FileSystem;
+import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.io.ArrayWritable;
+import org.apache.hadoop.io.ObjectWritable;
+import org.apache.hadoop.io.SequenceFile;
+import org.apache.hadoop.io.SequenceFile.CompressionType;
+import org.apache.hama.examples.graph.ShortestPaths;
+import org.apache.hama.examples.graph.Vertex;
+
+/**
+ * This partitioner partitions the file data which should be in text form into a
+ * sequencefile.
+ * 
+ * TODO: this should be extended with InputFormat stuff so we can parse every
+ * format.
+ * 
+ */
+public abstract class AbstractGraphPartitioner<T extends PartitionableWritable> {
+
+  public static final Log LOG = LogFactory
+      .getLog(AbstractGraphPartitioner.class);
+
+  private FileSystem fs;
+
+  private Class<T> vertexClass;
+
+  @SuppressWarnings("unchecked")
+  public Configuration partition(Configuration conf, Path file,
+      String[] groomNames) throws InstantiationException,
+      IllegalAccessException, IOException, InterruptedException {
+
+    fs = FileSystem.get(conf);
+
+    vertexClass = (Class<T>) conf.getClass("hama.partitioning.vertex.class",
+        Vertex.class);
+
+    int sizeOfCluster = groomNames.length;
+
+    // setup the paths where the grooms can find their input
+    List<Path> partPaths = new ArrayList<Path>(sizeOfCluster);
+    List<SequenceFile.Writer> writers = new ArrayList<SequenceFile.Writer>(
+        sizeOfCluster);
+    StringBuilder groomNameBuilder = new StringBuilder();
+    // this loop adds partition paths for the writers and sets the appropriate
+    // groom names to the files and configuration
+    for (String entry : groomNames) {
+      partPaths.add(new Path(file.getParent().toString() + Path.SEPARATOR
+          + ShortestPaths.PARTED + Path.SEPARATOR
+          + entry.split(ShortestPaths.NAME_VALUE_SEPARATOR)[0]));
+      conf.set(ShortestPaths.MASTER_TASK, entry);
+      groomNameBuilder.append(entry + ";");
+    }
+    // put every peer into the configuration
+    conf.set(ShortestPaths.BSP_PEERS, groomNameBuilder.toString());
+    // create a seq writer for the files
+    for (Path p : partPaths) {
+      fs.delete(p, true);
+      writers.add(SequenceFile.createWriter(fs, conf, p,
+          ObjectWritable.class, ArrayWritable.class,CompressionType.NONE));
+    }
+
+    BufferedReader br = null;
+    try {
+      // read the input
+      br = new BufferedReader(new InputStreamReader(fs.open(file)));
+
+      long numLines = 0L;
+      String line = null;
+      while ((line = br.readLine()) != null) {
+        // let the subclass process
+        AdjacentPair<T> pair = process(line);
+        // check to which partition the vertex belongs
+        int mod = Math.abs(pair.vertex.getId() % sizeOfCluster);
+        writers.get(mod).append(new ObjectWritable(vertexClass, pair.vertex),
+            new ArrayWritable(vertexClass, pair.adjacentVertices));
+        numLines++;
+        if (numLines % 100000 == 0) {
+          LOG.debug("Partitioned " + numLines + " of vertices!");
+        }
+      }
+
+      for (Path p : partPaths) {
+        conf.set("in.path." + p.getName(), p.toString());
+      }
+      conf.set("num.vertices", "" + numLines);
+      LOG.debug("Partitioned a total of " + numLines + " vertices!");
+
+      return conf;
+    } finally {
+      // close our ressources
+      if (br != null)
+        br.close();
+
+      for (SequenceFile.Writer w : writers)
+        w.close();
+
+      fs.close();
+    }
+  }
+
+  protected abstract AdjacentPair<T> process(String line);
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AbstractGraphPartitioner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AdjacentPair.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AdjacentPair.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AdjacentPair.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AdjacentPair.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,35 @@
+/**
+ * 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.hama.examples.graph.partitioning;
+
+
+public final class AdjacentPair<K extends PartitionableWritable> {
+  
+  final K vertex;
+  final K[] adjacentVertices;
+  
+  
+  public AdjacentPair(K vertex, K[] adjacentVertices) {
+    super();
+    this.vertex = vertex;
+    this.adjacentVertices = adjacentVertices;
+  }
+  
+  
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/AdjacentPair.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/PartitionableWritable.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/PartitionableWritable.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/PartitionableWritable.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/PartitionableWritable.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,26 @@
+/**
+ * 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.hama.examples.graph.partitioning;
+
+import org.apache.hadoop.io.Writable;
+
+public interface PartitionableWritable extends Writable {
+  
+  public int getId();
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/PartitionableWritable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/ShortestPathVertexPartitioner.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/ShortestPathVertexPartitioner.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/ShortestPathVertexPartitioner.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/ShortestPathVertexPartitioner.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,43 @@
+/**
+ * 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.hama.examples.graph.partitioning;
+
+import org.apache.hama.examples.graph.ShortestPathVertex;
+
+public class ShortestPathVertexPartitioner extends
+    AbstractGraphPartitioner<ShortestPathVertex> {
+
+  @Override
+  protected AdjacentPair<ShortestPathVertex> process(String line) {
+
+    String[] vertices = line.split("\t");
+
+    ShortestPathVertex v = new ShortestPathVertex(0, vertices[0]);
+
+    ShortestPathVertex[] adjacents = new ShortestPathVertex[vertices.length - 1];
+
+    for (int i = 1; i < vertices.length; i++) {
+      String[] vertexAndWeight = vertices[i].split(":");
+      adjacents[i - 1] = new ShortestPathVertex(
+          Integer.valueOf(vertexAndWeight[1]), vertexAndWeight[0]);
+    }
+
+    return new AdjacentPair<ShortestPathVertex>(v, adjacents);
+  }
+
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/ShortestPathVertexPartitioner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/VertexPartitioner.java
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/VertexPartitioner.java?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/VertexPartitioner.java (added)
+++ incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/VertexPartitioner.java Tue Sep 27 09:35:21 2011
@@ -0,0 +1,40 @@
+/**
+ * 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.hama.examples.graph.partitioning;
+
+import org.apache.hama.examples.graph.Vertex;
+
+public class VertexPartitioner extends AbstractGraphPartitioner<Vertex> {
+
+  @Override
+  protected AdjacentPair<Vertex> process(String line) {
+
+    String[] vertices = line.split("\t");
+
+    Vertex v = new Vertex(vertices[0]);
+    Vertex[] adjacents = new Vertex[vertices.length - 1];
+
+    for (int i = 1; i < vertices.length; i++) {
+      adjacents[i - 1] = new Vertex(vertices[i]);
+    }
+
+    return new AdjacentPair<Vertex>(v, adjacents);
+  }
+  
+  
+}

Propchange: incubator/hama/branches/HamaV2/examples/src/main/java/org/apache/hama/examples/graph/partitioning/VertexPartitioner.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/hama/branches/HamaV2/examples/target/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Sep 27 09:35:21 2011
@@ -0,0 +1 @@
+*

Added: incubator/hama/branches/HamaV2/examples/target/.plxarc
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/.plxarc?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/target/.plxarc (added)
+++ incubator/hama/branches/HamaV2/examples/target/.plxarc Tue Sep 27 09:35:21 2011
@@ -0,0 +1 @@
+maven-shared-archive-resources
\ No newline at end of file

Added: incubator/hama/branches/HamaV2/examples/target/classes/META-INF/DEPENDENCIES
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/META-INF/DEPENDENCIES?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/target/classes/META-INF/DEPENDENCIES (added)
+++ incubator/hama/branches/HamaV2/examples/target/classes/META-INF/DEPENDENCIES Tue Sep 27 09:35:21 2011
@@ -0,0 +1,111 @@
+// ------------------------------------------------------------------
+// Transitive dependencies of this project determined from the
+// maven pom organized by organization.
+// ------------------------------------------------------------------
+
+Apache Hama Examples
+
+
+From: 'an unknown organization'
+  - geronimo-spec-jta  geronimo-spec:geronimo-spec-jta:jar:1.0.1B-rc4
+
+  - HSQLDB (http://hsqldb.org/) hsqldb:hsqldb:jar:1.8.0.10
+    License: HSQLDB License  (http://hsqldb.org/web/hsqlLicense.html)
+  - JLine (http://jline.sourceforge.net) jline:jline:jar:0.9.94
+    License: BSD  (LICENSE.txt)
+  - An open source Java toolkit for Amazon S3 (http://jets3t.s3.amazonaws.com/index.html) net.java.dev.jets3t:jets3t:jar:0.7.1
+    License: Apache License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0)
+  - kosmosfs (http://kosmosfs.sourceforge.net/) net.sf.kosmosfs:kfs:jar:0.3
+    License: The Apache Software License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+  - hadoop-core  org.apache.hadoop:hadoop-core:jar:0.20.2
+
+  - hadoop-test  org.apache.hadoop:hadoop-test:jar:0.20.2
+
+  - servlet-api  org.apache.tomcat:servlet-api:jar:6.0.32
+
+  - zookeeper  org.apache.zookeeper:zookeeper:jar:3.3.1
+
+  - Eclipse JDT Core (http://www.eclipse.org/jdt/) org.eclipse.jdt:core:jar:3.1.1
+    License: Eclipse Public License v1.0  (http://www.eclipse.org/org/documents/epl-v10.php)
+  - oro  oro:oro:jar:2.0.8
+
+  - jasper-compiler  tomcat:jasper-compiler:jar:5.5.12
+
+  - jasper-runtime  tomcat:jasper-runtime:jar:5.5.12
+
+  - xmlenc Library (http://xmlenc.sourceforge.net) xmlenc:xmlenc:jar:0.52
+    License: The BSD License  (http://www.opensource.org/licenses/bsd-license.php)
+
+From: 'Apache MINA Project' (http://mina.apache.org/)
+  - Apache MINA Core (http://mina.apache.org/mina-core) org.apache.mina:mina-core:bundle:2.0.0-M5
+    License: Apache 2.0 License  (http://www.apache.org/licenses/LICENSE-2.0)
+
+From: 'Apache Software Foundation' (http://jakarta.apache.org/)
+  - HttpClient (http://jakarta.apache.org/commons/httpclient/) commons-httpclient:commons-httpclient:jar:3.0.1
+    License: Apache License  (http://www.apache.org/licenses/LICENSE-2.0)
+
+From: 'Apache Software Foundation' (http://www.apache.org)
+  - Apache Log4j (http://logging.apache.org/log4j/1.2/) log4j:log4j:bundle:1.2.16
+    License: The Apache Software License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+  - Annotation 1.0 (http://geronimo.apache.org/specs/geronimo-annotation_1.0_spec) org.apache.geronimo.specs:geronimo-annotation_1.0_spec:jar:1.0
+    License: The Apache Software License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+From: 'Apache Software Foundation'
+  - org.apache.tools.ant (http://ant.apache.org/ant/) org.apache.ant:ant:jar:1.7.1
+
+  - ant-launcher (http://ant.apache.org/ant-launcher/) org.apache.ant:ant-launcher:jar:1.7.1
+
+
+From: 'JUnit' (http://www.junit.org)
+  - JUnit (http://junit.org) junit:junit:jar:4.8.1
+    License: Common Public License Version 1.0  (http://www.opensource.org/licenses/cpl1.0.txt)
+
+From: 'Mort Bay Consulting' (http://www.mortbay.com)
+  - Jetty Server (http://jetty.mortbay.org/project/modules/jetty) org.mortbay.jetty:jetty:jar:6.1.14
+    License: Apache License Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Servlet Annotations (http://jetty.mortbay.org/project/jetty-annotations) org.mortbay.jetty:jetty-annotations:jar:6.1.14
+    License: Apache License Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Jetty Plus (http://jetty.mortbay.org/project/jetty-plus) org.mortbay.jetty:jetty-plus:jar:6.1.14
+    License: Apache License Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Jetty Utilities (http://jetty.mortbay.org/project/jetty-util) org.mortbay.jetty:jetty-util:jar:6.1.14
+    License: Apache License Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Glassfish Jasper (http://jetty.mortbay.org/project/modules/jsp-2.1) org.mortbay.jetty:jsp-2.1:jar:6.1.14
+    License: CDDL 1.0  (https://glassfish.dev.java.net/public/CDDLv1.0.html)
+  - Glassfish Jasper API (http://jetty.mortbay.org/project/modules/jsp-api-2.1) org.mortbay.jetty:jsp-api-2.1:jar:6.1.14
+    License: Apache License Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Servlet Specification 2.5 API (http://jetty.mortbay.org/project/modules/servlet-api-2.5) org.mortbay.jetty:servlet-api-2.5:jar:6.1.14
+    License: CDDL 1.0  (https://glassfish.dev.java.net/public/CDDLv1.0.html)
+
+From: 'QOS.ch' (http://www.qos.ch)
+  - SLF4J API Module (http://www.slf4j.org) org.slf4j:slf4j-api:jar:1.5.2
+
+  - SLF4J LOG4J-12 Binding (http://www.slf4j.org) org.slf4j:slf4j-log4j12:jar:1.5.2
+
+
+From: 'The Apache Software Foundation' (http://jakarta.apache.org)
+  - Codec (http://jakarta.apache.org/commons/codec/) commons-codec:commons-codec:jar:1.3
+    License: The Apache Software License, Version 2.0  (/LICENSE.txt)
+  - EL (http://jakarta.apache.org/commons/el/) commons-el:commons-el:jar:1.0
+    License: The Apache Software License, Version 2.0  (/LICENSE.txt)
+  - Jakarta Commons Net (http://jakarta.apache.org/commons/${pom.artifactId.substring(8)}/) commons-net:commons-net:jar:1.4.1
+    License: The Apache Software License, Version 2.0  (/LICENSE.txt)
+
+From: 'The Apache Software Foundation' (http://www.apache.org/)
+  - ant (http://www.apache.org/ant/) ant:ant:jar:1.6.5
+    License: The Apache Software License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+  - Commons CLI (http://commons.apache.org/cli/) commons-cli:commons-cli:jar:1.2
+    License: The Apache Software License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+  - Commons Logging (http://commons.apache.org/logging) commons-logging:commons-logging:jar:1.1.1
+    License: The Apache Software License, Version 2.0  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+  - Apache Ftplet API (http://mina.apache.org/ftpserver) org.apache.ftpserver:ftplet-api:bundle:1.0.0
+    License: Apache 2.0 License  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Apache FtpServer Core (http://mina.apache.org/ftpserver/ftpserver-core) org.apache.ftpserver:ftpserver-core:bundle:1.0.0
+    License: Apache 2.0 License  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Apache FtpServer Deprecated classes (http://mina.apache.org/ftpserver/ftpserver-deprecated) org.apache.ftpserver:ftpserver-deprecated:jar:1.0.0-M2
+    License: Apache 2.0 License  (http://www.apache.org/licenses/LICENSE-2.0)
+  - Apache Hama Core (http://incubator.apache.org/hama/hama-core) org.apache.hama:hama-core:jar:0.4.0-incubating-SNAPSHOT
+    License: Apache 2  (http://www.apache.org/licenses/LICENSE-2.0.txt)
+
+
+
+

Added: incubator/hama/branches/HamaV2/examples/target/classes/META-INF/LICENSE
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/META-INF/LICENSE?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/target/classes/META-INF/LICENSE (added)
+++ incubator/hama/branches/HamaV2/examples/target/classes/META-INF/LICENSE Tue Sep 27 09:35:21 2011
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/META-INF/LICENSE
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/target/classes/META-INF/NOTICE
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/META-INF/NOTICE?rev=1176297&view=auto
==============================================================================
--- incubator/hama/branches/HamaV2/examples/target/classes/META-INF/NOTICE (added)
+++ incubator/hama/branches/HamaV2/examples/target/classes/META-INF/NOTICE Tue Sep 27 09:35:21 2011
@@ -0,0 +1,8 @@
+
+Apache Hama Examples
+Copyright 2008-2011 The Apache Software Foundation
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
+
+

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/META-INF/NOTICE
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/ExampleDriver.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/ExampleDriver.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/ExampleDriver.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/PiEstimator$MyEstimator.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/PiEstimator%24MyEstimator.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/PiEstimator$MyEstimator.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/PiEstimator.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/PiEstimator.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/PiEstimator.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/RandBench$RandBSP.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/RandBench%24RandBSP.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/RandBench$RandBSP.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/RandBench.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/RandBench.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/RandBench.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/SerializePrinting$HelloBSP.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/SerializePrinting%24HelloBSP.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/SerializePrinting$HelloBSP.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/SerializePrinting.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/SerializePrinting.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/SerializePrinting.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/PageRank.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/PageRank.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/PageRank.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/PageRankBase.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/PageRankBase.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/PageRankBase.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/ShortestPathVertex.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/ShortestPathVertex.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/ShortestPathVertex.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/ShortestPaths.class
URL: http://svn.apache.org/viewvc/incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/ShortestPaths.class?rev=1176297&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/hama/branches/HamaV2/examples/target/classes/org/apache/hama/examples/graph/ShortestPaths.class
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream