Serialize Printing of "Hello BSP"

Each BSP task of the HAMA cluster, will print the string "Hello BSP" in serial order. This example will help you to understand the concepts of the BSP computing model.

BSP implementation of Serialize Printing of "Hello BSP"

  public class ClassSerializePrinting extends
    BSP<NullWritable, NullWritable, IntWritable, Text> {

  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));
      }
      bspPeer.sync();
      IntegerMessage msg = null;
      while ((msg = (IntegerMessage) bspPeer.getCurrentMessage()) != null) {
        bspPeer.write(new IntWritable(msg.getData()), new Text(msg.getTag()));
      }
    }
  }
}