You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by Apache Wiki <wi...@apache.org> on 2012/01/31 09:33:51 UTC

[Hama Wiki] Update of "SerializePrinting" by thomasjungblut

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hama Wiki" for change notification.

The "SerializePrinting" page has been changed by thomasjungblut:
http://wiki.apache.org/hama/SerializePrinting?action=diff&rev1=13&rev2=14

Comment:
updated to new api

   * See the [[BSPModel|BSP programming model]] of HAMA if you didn't read yet.
  
  {{{
-     public void bsp(BSPPeerProtocol bspPeer) throws IOException,
-         KeeperException, InterruptedException {
+   public class ClassSerializePrinting extends
+     BSP<NullWritable, NullWritable, IntWritable, Text> {
  
-       int i = 0;
+   public static final int NUM_SUPERSTEPS = 15;
+ 
+   @Override
+   public void bsp(BSPPeer<NullWritable, NullWritable, IntWritable, Text> bspPeer)
+       throws IOException, SyncException, InterruptedException {
+ 
+     for (int i = 0; i < NUM_SUPERSTEPS; i++) {
        for (String otherPeer : bspPeer.getAllPeerNames()) {
+         bspPeer.send(otherPeer, new IntegerMessage(bspPeer.getPeerName(), i));
-         String peerName = bspPeer.getPeerName();
-         if (peerName.equals(otherPeer)) {
-           writeLogToFile(peerName, i);
-         }
+       }
- 
-         Thread.sleep(PRINT_INTERVAL);
-         bspPeer.sync();
+       bspPeer.sync();
-         i++;
+       IntegerMessage msg = null;
+       while ((msg = (IntegerMessage) bspPeer.getCurrentMessage()) != null) {
+         bspPeer.write(new IntWritable(msg.getData()), new Text(msg.getTag()));
        }
      }
+   }
+ }
  }}}