You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2014/04/07 09:30:00 UTC
svn commit: r1585418 -
/hama/trunk/core/src/test/java/org/apache/hama/MiniBSPCluster.java
Author: edwardyoon
Date: Mon Apr 7 07:30:00 2014
New Revision: 1585418
URL: http://svn.apache.org/r1585418
Log:
HAMA-855: Handling Address binding exceptions
Modified:
hama/trunk/core/src/test/java/org/apache/hama/MiniBSPCluster.java
Modified: hama/trunk/core/src/test/java/org/apache/hama/MiniBSPCluster.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/test/java/org/apache/hama/MiniBSPCluster.java?rev=1585418&r1=1585417&r2=1585418&view=diff
==============================================================================
--- hama/trunk/core/src/test/java/org/apache/hama/MiniBSPCluster.java (original)
+++ hama/trunk/core/src/test/java/org/apache/hama/MiniBSPCluster.java Mon Apr 7 07:30:00 2014
@@ -21,6 +21,7 @@ import static java.util.concurrent.TimeU
import static junit.framework.Assert.fail;
import java.io.IOException;
+import java.net.BindException;
import java.net.ServerSocket;
import java.util.ArrayList;
import java.util.List;
@@ -58,7 +59,7 @@ public class MiniBSPCluster {
public void run() {
try {
LOG.info("Starting BSP Master.");
- this.bspm = BSPMaster.startMaster(this.conf);
+ setMaster(40000);
this.bspm.offerService();
} catch (IOException ioe) {
LOG.error("Fail to startup BSP Master.", ioe);
@@ -68,6 +69,19 @@ public class MiniBSPCluster {
}
}
+ private void setMaster(int defaultPort) {
+ try {
+ this.conf.setInt("bsp.master.port", defaultPort);
+ this.bspm = BSPMaster.startMaster(this.conf);
+ } catch (BindException e) {
+ setMaster(++defaultPort);
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
public void shutdown() {
if (null != this.bspm)
this.bspm.shutdown();