hama-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edwardy...@apache.org
Subject svn commit: r1694390 - /hama/trunk/core/src/main/java/org/apache/hama/bsp/message/HamaMessageManagerImpl.java
Date Thu, 06 Aug 2015 01:18:56 GMT
Author: edwardyoon
Date: Thu Aug  6 01:18:56 2015
New Revision: 1694390

URL: http://svn.apache.org/r1694390
Log:
HAMA-969: Infinite loop defect in HamaMessageManagerImpl (JongYoon Lim via edwardyoon)

Modified:
    hama/trunk/core/src/main/java/org/apache/hama/bsp/message/HamaMessageManagerImpl.java

Modified: hama/trunk/core/src/main/java/org/apache/hama/bsp/message/HamaMessageManagerImpl.java
URL: http://svn.apache.org/viewvc/hama/trunk/core/src/main/java/org/apache/hama/bsp/message/HamaMessageManagerImpl.java?rev=1694390&r1=1694389&r2=1694390&view=diff
==============================================================================
--- hama/trunk/core/src/main/java/org/apache/hama/bsp/message/HamaMessageManagerImpl.java
(original)
+++ hama/trunk/core/src/main/java/org/apache/hama/bsp/message/HamaMessageManagerImpl.java
Thu Aug  6 01:18:56 2015
@@ -51,8 +51,12 @@ public final class HamaMessageManagerImp
   private static final Log LOG = LogFactory
       .getLog(HamaMessageManagerImpl.class);
 
+  private static final int MAX_RETRY = 5;
+
   private Server server;
 
+  private static int retry = 0;
+
   private LRUCache<InetSocketAddress, HamaMessageManager<M>> peersLRUCache =
null;
 
   @SuppressWarnings("serial")
@@ -60,6 +64,7 @@ public final class HamaMessageManagerImp
   public final void init(TaskAttemptID attemptId, BSPPeer<?, ?, ?, ?, M> peer,
       HamaConfiguration conf, InetSocketAddress peerAddress) {
     super.init(attemptId, peer, conf, peerAddress);
+    retry = 0;
     startRPCServer(conf, peerAddress);
     peersLRUCache = new LRUCache<InetSocketAddress, HamaMessageManager<M>>(
         maxCachedConnections) {
@@ -87,7 +92,6 @@ public final class HamaMessageManagerImp
   }
 
   private void startServer(String hostName, int port) throws IOException {
-    int retry = 0;
     try {
       this.server = RPC.getServer(this, hostName, port,
           conf.getInt("hama.default.messenger.handler.threads.num", 5), false,
@@ -97,13 +101,13 @@ public final class HamaMessageManagerImp
       LOG.info("BSPPeer address:" + server.getListenerAddress().getHostName()
           + " port:" + server.getListenerAddress().getPort());
     } catch (BindException e) {
-      LOG.warn("Address already in use. Retrying " + hostName + ":" + port + 1);
-      startServer(hostName, port + 1);
-      retry++;
-
-      if (retry > 5) {
+      final int nextPort = port + 1;
+      LOG.warn("Address already in use. Retrying " + hostName + ":"
+              + nextPort);
+      if (retry++ >= MAX_RETRY) {
         throw new RuntimeException("RPC Server could not be launched!");
       }
+      startServer(hostName, nextPort);
     }
   }
 



Mime
View raw message