hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tjungb...@apache.org
Subject svn commit: r1339625 - /incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/SuperstepBSP.java
Date Thu, 17 May 2012 14:52:34 GMT
Author: tjungblut
Date: Thu May 17 14:52:34 2012
New Revision: 1339625

URL: http://svn.apache.org/viewvc?rev=1339625&view=rev
Log:
Fix for superstep BSP

Modified:
    incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/SuperstepBSP.java

Modified: incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/SuperstepBSP.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/SuperstepBSP.java?rev=1339625&r1=1339624&r2=1339625&view=diff
==============================================================================
--- incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/SuperstepBSP.java (original)
+++ incubator/hama/trunk/core/src/main/java/org/apache/hama/bsp/SuperstepBSP.java Thu May
17 14:52:34 2012
@@ -17,17 +17,19 @@
  */
 package org.apache.hama.bsp;
 
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.util.ReflectionUtils;
-import org.apache.hama.bsp.BSP;
-import org.apache.hama.bsp.BSPPeer;
 import org.apache.hama.bsp.sync.SyncException;
 
-import java.io.IOException;
-
 public class SuperstepBSP<K1, V1, K2, V2, M extends Writable> extends
     BSP<K1, V1, K2, V2, M> {
 
+  private static final Log LOG = LogFactory.getLog(SuperstepBSP.class);
+
   private Superstep<K1, V1, K2, V2, M>[] supersteps;
   private int startSuperstep;
 
@@ -36,13 +38,23 @@ public class SuperstepBSP<K1, V1, K2, V2
   public void setup(BSPPeer<K1, V1, K2, V2, M> peer) throws IOException,
       SyncException, InterruptedException {
     // instantiate our superstep classes
-    Class<?>[] classes = peer.getConfiguration().getClasses(
-        "hama.supersteps.class", Superstep.class);
+    String classList = peer.getConfiguration().get("hama.supersteps.class");
+    String[] classNames = classList.split(",");
+
+    LOG.debug("Size of classes = " + classNames.length);
 
-    supersteps = new Superstep[classes.length];
-    for (int i = 0; i < classes.length; i++) {
-      Superstep<K1, V1, K2, V2, M> newInstance = (Superstep<K1, V1, K2, V2, M>)
ReflectionUtils
-          .newInstance(classes[i], peer.getConfiguration());
+    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;
     }



Mime
View raw message