hama-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Garuda Kang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HAMA-855) Handling Address binding exceptions
Date Mon, 07 Apr 2014 03:53:15 GMT

    [ https://issues.apache.org/jira/browse/HAMA-855?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13961634#comment-13961634
] 

Garuda Kang commented on HAMA-855:
----------------------------------

i guess this problem is due to
hama-core : org.apache.hama.bsp.BSPMaster 's 534 line

int defaultPort = conf.getInt("bsp.master.port", 40000);

this will be cannot change specified port.
i seemed to need find next port and bind logic.

so i suggest this patch (did not tested)

Index: src/main/java/org/apache/hama/bsp/BSPMaster.java
===================================================================
--- eclipse_workspace/hama-trunk/core/src/main/java/org/apache/hama/bsp/BSPMaster.java	(revision
1575192)
+++ eclipse_workspace/hama-trunk/core/src/main/java/org/apache/hama/bsp/BSPMaster.java	(working
copy)
@@ -290,12 +290,8 @@
     // inetSocketAddress is null if we are in local mode, then we should start
     // nothing.
     if (inetSocketAddress != null) {
-      host = inetSocketAddress.getHostName();
-      port = inetSocketAddress.getPort();
-      LOG.info("RPC BSPMaster: host " + host + " port " + port);
-
       startTime = System.currentTimeMillis();
-      this.masterServer = RPC.getServer(this, host, port, conf);
+      initMaster(inetSocketAddress);
 
       infoPort = conf.getInt("bsp.http.infoserver.port", 40013);
 
@@ -359,6 +355,22 @@
       LOG.info(localModeMessage);
     }
   }
+  
+  private void initMaster(InetSocketAddress inetSocketAddress) {
+    try {
+      host = inetSocketAddress.getHostName();
+      port = inetSocketAddress.getPort();
+      LOG.info("RPC BSPMaster: host " + host + " port " + port);
+      this.masterServer = RPC.getServer(this, host, port, conf);
+    }catch(Exception e) {
+      if(port%40000 > 5) {
+        throw new RuntimeException("RPC Server could not be launched!");
+      }
+      port++;
+      InetSocketAddress addr = getAddress(this.conf,port);
+      initMaster(addr);
+    }
+  }
 
   /**
    * A GroomServer registers with its status to BSPMaster when startup, which
@@ -537,6 +549,18 @@
       return null;
     }
   }
+  
+  public static InetSocketAddress getAddress(Configuration conf, int defaultPort) {
+    String hamaMasterStr = conf.get("bsp.master.address", "localhost");
+    // we ensure that hamaMasterStr is non-null here because we provided
+    // "localhost" as default.
+    if (!hamaMasterStr.equals("local")) {
+      conf.setInt("bsp.master.port", defaultPort);
+      return NetUtils.createSocketAddr(hamaMasterStr, defaultPort);
+    } else {
+      return null;
+    }
+  }
 
   /**
    * BSPMaster identifier

> Handling Address binding exceptions
> -----------------------------------
>
>                 Key: HAMA-855
>                 URL: https://issues.apache.org/jira/browse/HAMA-855
>             Project: Hama
>          Issue Type: Bug
>          Components: bsp core
>    Affects Versions: 0.6.3
>            Reporter: Edward J. Yoon
>            Assignee: Edward J. Yoon
>             Fix For: 0.7.0
>
>
> Often, build fails with Address binding exceptions. We can add some re-attempt mechanism
to avoid this situations.
> https://builds.apache.org/job/Hama-trunk/245/testReport/org.apache.hama.bsp/TestBSPMasterGroomServer/testSubmitJob/
> {code}
> 14/01/21 01:15:23 ERROR bsp.GroomServer: Got fatal exception while reinitializing GroomServer:
java.net.BindException: Problem binding to vesta.apache.org/67.195.138.9:53307 : Address already
in use
> 	at org.apache.hama.ipc.Server.bind(Server.java:250)
> 	at org.apache.hama.ipc.Server$Listener.<init>(Server.java:316)
> 	at org.apache.hama.ipc.Server.<init>(Server.java:1313)
> 	at org.apache.hama.ipc.RPC$Server.<init>(RPC.java:595)
> 	at org.apache.hama.ipc.RPC.getServer(RPC.java:551)
> 	at org.apache.hama.ipc.RPC.getServer(RPC.java:538)
> 	at org.apache.hama.ipc.RPC.getServer(RPC.java:528)
> 	at org.apache.hama.bsp.GroomServer.initialize(GroomServer.java:326)
> 	at org.apache.hama.bsp.GroomServer.run(GroomServer.java:832)
> 	at java.lang.Thread.run(Thread.java:662)
> Caused by: java.net.BindException: Address already in use
> 	at sun.nio.ch.Net.bind(Native Method)
> 	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:124)
> 	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
> 	at org.apache.hama.ipc.Server.bind(Server.java:248)
> 	... 9 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message