Esempio n. 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);
  }