Skip to content

Commit

Permalink
Don't log every jmx connection failure within JmxProxyImpl. The throw…
Browse files Browse the repository at this point in the history
…n exception is logged appropriately when caught.

Also reduces visibility of the not-for-public-use JmxConnectionFactory.connect(..) method.
  • Loading branch information
michaelsembwever committed Nov 8, 2017
1 parent 5d3d469 commit d75ba7b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public JmxConnectionFactory(MetricRegistry metricRegistry) {
hostConnectionCounters = new HostConnectionCounters(metricRegistry);
}

public JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException, NumberFormatException, InterruptedException {
protected JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException, InterruptedException {
// use configured jmx port for host if provided
if (jmxPorts != null && jmxPorts.containsKey(host) && !host.contains(":")) {
host = host + ":" + jmxPorts.get(host);
Expand All @@ -77,8 +77,7 @@ public JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int
}
}

public final JmxProxy connect(String host, int connectionTimeout)
throws ReaperException, NumberFormatException, InterruptedException {
public final JmxProxy connect(String host, int connectionTimeout) throws ReaperException, InterruptedException {
return connect(Optional.<RepairStatusHandler>absent(), host, connectionTimeout);
}

Expand All @@ -100,7 +99,8 @@ public final JmxProxy connectAny(
try {
return connect(handler, host, connectionTimeout);
} catch (ReaperException | RuntimeException e) {
LOG.info("Unreachable host", e);
LOG.info("Unreachable host: {}: {}", e.getMessage(), e.getCause().getMessage());
LOG.debug("Unreachable host: ", e);
} catch (InterruptedException expected) {
LOG.trace("Expected exception", expected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ static JmxProxy connect(
String password,
final EC2MultiRegionAddressTranslator addressTranslator,
int connectionTimeout)
throws ReaperException, NumberFormatException, InterruptedException {
throws ReaperException, InterruptedException {

if (host == null) {
throw new ReaperException("Null host given to JmxProxy.connect()");
Expand All @@ -177,7 +177,7 @@ static JmxProxy connect(
* @param addressTranslator if EC2MultiRegionAddressTranslator isn't null it will be used to
* translate addresses
*/
static JmxProxy connect(
private static JmxProxy connect(
Optional<RepairStatusHandler> handler,
String originalHost,
int port,
Expand Down Expand Up @@ -251,8 +251,7 @@ static JmxProxy connect(

return proxy;
} catch (IOException | ExecutionException | TimeoutException | InstanceNotFoundException e) {
LOG.error("Failed to establish JMX connection to {}:{}", host, port);
throw new ReaperException("Failure when establishing JMX connection", e);
throw new ReaperException("Failure when establishing JMX connection to " + host + ":" + port, e);
} catch (InterruptedException expected) {
LOG.debug(
"JMX connection to {}:{} was interrupted by Reaper. "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ private void setupReaperTestRunner() throws Exception {

context.jmxConnectionFactory = new JmxConnectionFactory() {
@Override
public JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {

return proxies.get(host);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private MockObjects initMocks() throws ReaperException {

context.jmxConnectionFactory = new JmxConnectionFactory() {
@Override
public JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {
return jmxProxy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public void setUp() throws Exception {

context.jmxConnectionFactory = new JmxConnectionFactory() {
@Override
public JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {
return proxy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public void testHangingRepair() throws InterruptedException, ReaperException {
final AtomicInteger repairAttempts = new AtomicInteger(1);

@Override
public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {

final JmxProxy jmx = mock(JmxProxy.class);
Expand Down Expand Up @@ -270,7 +270,7 @@ public void testHangingRepairNewAPI() throws InterruptedException, ReaperExcepti
final AtomicInteger repairAttempts = new AtomicInteger(1);

@Override
public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {

final JmxProxy jmx = mock(JmxProxy.class);
Expand Down Expand Up @@ -403,7 +403,7 @@ public void testResumeRepair() throws InterruptedException, ReaperException {
assertEquals(storage.getRepairSegment(RUN_ID, SEGMENT_ID).get().getState(), RepairSegment.State.NOT_STARTED);
context.jmxConnectionFactory = new JmxConnectionFactory() {
@Override
public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {

final JmxProxy jmx = mock(JmxProxy.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void successTest() throws InterruptedException, ReaperException, Executio

context.jmxConnectionFactory = new JmxConnectionFactory() {
@Override
public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {

JmxProxy jmx = mock(JmxProxy.class);
Expand Down Expand Up @@ -307,7 +307,7 @@ public void failureTest() throws InterruptedException, ReaperException, Executio

context.jmxConnectionFactory = new JmxConnectionFactory() {
@Override
public JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
protected JmxProxy connect(final Optional<RepairStatusHandler> handler, String host, int connectionTimeout)
throws ReaperException {

JmxProxy jmx = mock(JmxProxy.class);
Expand Down

0 comments on commit d75ba7b

Please sign in to comment.