incubator-hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Hama Wiki] Update of "SerializePrinting" by thomasjungblut
Date Tue, 31 Jan 2012 08:33:51 GMT
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()));
        }
      }
+   }
+ }
  }}}
  

Mime
View raw message