mirror of https://github.com/apache/activemq.git
- Reduced verbosity of logging in TransportConnector so that exceptions should only be in DEBUG messages.
- Added more logging to SimpleDiscoveryAgent so that we can see what it's doing in regards to reconnect handling and enabled exponential backoff by default. git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@592090 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9ecfbf98f5
commit
62890b3fbb
|
@ -170,7 +170,8 @@ public class TransportConnector implements Connector {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onAcceptError(Exception error, String remoteHost) {
|
private void onAcceptError(Exception error, String remoteHost) {
|
||||||
LOG.error("Could not accept connection " + (remoteHost == null ? "" : "from " + remoteHost) + ": " + error, error);
|
LOG.error("Could not accept connection " + (remoteHost == null ? "" : "from " + remoteHost) + ": " + error.getMessage());
|
||||||
|
LOG.debug("Reason: " + error.getMessage(), error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.server.setBrokerInfo(brokerInfo);
|
this.server.setBrokerInfo(brokerInfo);
|
||||||
|
|
|
@ -23,6 +23,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import org.apache.activemq.command.DiscoveryEvent;
|
import org.apache.activemq.command.DiscoveryEvent;
|
||||||
import org.apache.activemq.transport.discovery.DiscoveryAgent;
|
import org.apache.activemq.transport.discovery.DiscoveryAgent;
|
||||||
import org.apache.activemq.transport.discovery.DiscoveryListener;
|
import org.apache.activemq.transport.discovery.DiscoveryListener;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple DiscoveryAgent that allows static configuration of the discovered
|
* A simple DiscoveryAgent that allows static configuration of the discovered
|
||||||
|
@ -32,13 +34,15 @@ import org.apache.activemq.transport.discovery.DiscoveryListener;
|
||||||
*/
|
*/
|
||||||
public class SimpleDiscoveryAgent implements DiscoveryAgent {
|
public class SimpleDiscoveryAgent implements DiscoveryAgent {
|
||||||
|
|
||||||
|
private final static Log LOG = LogFactory.getLog(SimpleDiscoveryAgent.class);
|
||||||
|
|
||||||
private long initialReconnectDelay = 1000;
|
private long initialReconnectDelay = 1000;
|
||||||
private long maxReconnectDelay = 1000 * 30;
|
private long maxReconnectDelay = 1000 * 30;
|
||||||
private long backOffMultiplier = 2;
|
private long backOffMultiplier = 2;
|
||||||
private boolean useExponentialBackOff;
|
private boolean useExponentialBackOff=true;
|
||||||
private int maxReconnectAttempts;
|
private int maxReconnectAttempts;
|
||||||
private final Object sleepMutex = new Object();
|
private final Object sleepMutex = new Object();
|
||||||
private long minConnectTime = 500;
|
private long minConnectTime = 5000;
|
||||||
private DiscoveryListener listener;
|
private DiscoveryListener listener;
|
||||||
private String services[] = new String[] {};
|
private String services[] = new String[] {};
|
||||||
private final AtomicBoolean running = new AtomicBoolean(false);
|
private final AtomicBoolean running = new AtomicBoolean(false);
|
||||||
|
@ -109,11 +113,12 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
|
||||||
// fails right
|
// fails right
|
||||||
// away.
|
// away.
|
||||||
if (event.connectTime + minConnectTime > System.currentTimeMillis()) {
|
if (event.connectTime + minConnectTime > System.currentTimeMillis()) {
|
||||||
|
LOG.debug("Failure occured soon after the discovery event was generated. It will be clasified as a connection failure: "+event);
|
||||||
|
|
||||||
event.connectFailures++;
|
event.connectFailures++;
|
||||||
|
|
||||||
if (maxReconnectAttempts > 0 && event.connectFailures >= maxReconnectAttempts) {
|
if (maxReconnectAttempts > 0 && event.connectFailures >= maxReconnectAttempts) {
|
||||||
// Don' try to re-connect
|
LOG.debug("Reconnect attempts exceeded "+maxReconnectAttempts+" tries. Reconnecting has been disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,6 +128,7 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.debug("Waiting "+event.reconnectDelay+" ms before attepting to reconnect.");
|
||||||
sleepMutex.wait(event.reconnectDelay);
|
sleepMutex.wait(event.reconnectDelay);
|
||||||
} catch (InterruptedException ie) {
|
} catch (InterruptedException ie) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
|
|
Loading…
Reference in New Issue