Example #1
0
  @SuppressWarnings("unchecked")
  @Override
  public void setup(BSPPeer<K1, V1, K2, V2, M> peer)
      throws IOException, SyncException, InterruptedException {
    // instantiate our superstep classes
    String classList = peer.getConfiguration().get("hama.supersteps.class");
    String[] classNames = classList.split(",");

    LOG.debug("Size of classes = " + classNames.length);

    supersteps = new Superstep[classNames.length];
    Superstep<K1, V1, K2, V2, M> newInstance;
    for (int i = 0; i < classNames.length; i++) {

      try {
        newInstance =
            (Superstep<K1, V1, K2, V2, M>)
                ReflectionUtils.newInstance(Class.forName(classNames[i]), peer.getConfiguration());
      } catch (ClassNotFoundException e) {
        LOG.error(
            (new StringBuffer("Could not instantiate a Superstep class ").append(classNames[i]))
                .toString(),
            e);
        throw new IOException(e);
      }
      newInstance.setup(peer);
      supersteps[i] = newInstance;
    }
    startSuperstep = peer.getConfiguration().getInt("attempt.superstep", 0);
  }
Example #2
0
 @Override
 public void bsp(BSPPeer<K1, V1, K2, V2, M> peer)
     throws IOException, SyncException, InterruptedException {
   for (int index = startSuperstep; index < supersteps.length; index++) {
     Superstep<K1, V1, K2, V2, M> superstep = supersteps[index];
     superstep.compute(peer);
     if (superstep.haltComputation(peer)) {
       break;
     }
     peer.sync();
     startSuperstep = 0;
   }
 }
Example #3
0
 @Override
 public void cleanup(BSPPeer<K1, V1, K2, V2, M> peer) throws IOException {
   for (Superstep<K1, V1, K2, V2, M> superstep : supersteps) {
     superstep.cleanup(peer);
   }
 }