diff options
author | Harald Musum <musum@verizonmedia.com> | 2023-01-04 13:48:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-04 13:48:59 +0100 |
commit | 261a7682dfef5645431abdc6f458499368ab0f7a (patch) | |
tree | 378a974f2194beb41af833c41f64f49a05f551d9 | |
parent | c5ef90a13114197b3119b2ec9d2cda8e3a233985 (diff) | |
parent | fefd2af6f868eb04b058e50874fb93e9a72df8da (diff) |
Merge pull request #25391 from vespa-engine/hmusum/dont-swallow-exception
Don't swallow exception
3 files changed, 6 insertions, 15 deletions
diff --git a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java index dcef432aec0..5e740c5f03c 100644 --- a/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java +++ b/clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/RpcServer.java @@ -4,6 +4,7 @@ package com.yahoo.vespa.clustercontroller.core.rpc; import com.yahoo.jrt.Acceptor; import com.yahoo.jrt.ErrorCode; import com.yahoo.jrt.Int32Value; +import com.yahoo.jrt.ListenFailedException; import com.yahoo.jrt.Method; import com.yahoo.jrt.Request; import com.yahoo.jrt.Spec; @@ -23,7 +24,6 @@ import com.yahoo.vdslib.state.State; import com.yahoo.vespa.clustercontroller.core.ContentCluster; import com.yahoo.vespa.clustercontroller.core.MasterElectionHandler; import com.yahoo.vespa.clustercontroller.core.NodeInfo; -import com.yahoo.vespa.clustercontroller.core.Timer; import com.yahoo.vespa.clustercontroller.core.listeners.NodeListener; import java.io.PrintWriter; import java.io.StringWriter; @@ -39,7 +39,6 @@ public class RpcServer { private static final Logger log = Logger.getLogger(RpcServer.class.getName()); - private final Timer timer; private final Object monitor; private final String clusterName; private final int fleetControllerIndex; @@ -51,11 +50,8 @@ public class RpcServer { private final List<Request> rpcRequests = new LinkedList<>(); private MasterElectionHandler masterHandler; private final BackOffPolicy slobrokBackOffPolicy; - private long lastConnectErrorTime = 0; - private String lastConnectError = ""; - public RpcServer(Timer timer, Object monitor, String clusterName, int fleetControllerIndex, BackOffPolicy bop) { - this.timer = timer; + public RpcServer(Object monitor, String clusterName, int fleetControllerIndex, BackOffPolicy bop) { this.monitor = monitor; this.clusterName = clusterName; this.fleetControllerIndex = fleetControllerIndex; @@ -99,13 +95,8 @@ public class RpcServer { log.log(Level.FINE, () -> "Fleetcontroller " + fleetControllerIndex + ": RPC server attempting to bind to port " + port); try { acceptor = supervisor.listen(new Spec(port)); - } catch (Exception e) { - long time = timer.getCurrentTimeInMillis(); - if (!e.getMessage().equals(lastConnectError) || time - lastConnectErrorTime > 60 * 1000) { - lastConnectError = e.getMessage(); - lastConnectErrorTime = time; - log.log(Level.WARNING, "Failed to bind or initialize RPC server socket: " + e.getMessage()); - } + } catch (ListenFailedException e) { + throw new RuntimeException(e); } log.log(Level.FINE, () -> "Fleetcontroller " + fleetControllerIndex + ": RPC server listening to port " + acceptor.port()); SlobrokList slist = new SlobrokList(); diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java index 07401534a7b..aa49074ed4a 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/FleetControllerTest.java @@ -125,7 +125,7 @@ public abstract class FleetControllerTest implements Waiter { options.nodeStateRequestTimeoutLatestPercentage(), options.nodeStateRequestRoundTripTimeMaxSeconds()); var lookUp = new SlobrokClient(context, timer, new String[0]); - var rpcServer = new RpcServer(timer, timer, options.clusterName(), options.fleetControllerIndex(), options.slobrokBackOffPolicy()); + var rpcServer = new RpcServer(timer, options.clusterName(), options.fleetControllerIndex(), options.slobrokBackOffPolicy()); var database = new DatabaseHandler(context, new ZooKeeperDatabaseFactory(context), timer, options.zooKeeperServerAddress(), timer); // Setting this <1000 ms causes ECONNREFUSED on socket trying to connect to ZK server, in ZooKeeper, diff --git a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java index d120dc06c9f..e0f6546e410 100644 --- a/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java +++ b/clustercontroller-core/src/test/java/com/yahoo/vespa/clustercontroller/core/RpcServerTest.java @@ -64,7 +64,7 @@ public class RpcServerTest extends FleetControllerTest { startingTest("RpcServerTest::testRebinding"); Slobrok slobrok = new Slobrok(); String[] slobrokConnectionSpecs = getSlobrokConnectionSpecs(slobrok); - RpcServer server = new RpcServer(timer, new Object(), "mycluster", 0, new BackOff()); + RpcServer server = new RpcServer(new Object(), "mycluster", 0, new BackOff()); server.setSlobrokConnectionSpecs(slobrokConnectionSpecs, 0); int portUsed = server.getPort(); server.setSlobrokConnectionSpecs(slobrokConnectionSpecs, portUsed); |