- 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:
Hiram R. Chirino 2007-11-05 17:07:38 +00:00
parent 9ecfbf98f5
commit 62890b3fbb
2 changed files with 11 additions and 4 deletions

View File

@ -170,7 +170,8 @@ public class TransportConnector implements Connector {
}
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);

View File

@ -23,6 +23,8 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.activemq.command.DiscoveryEvent;
import org.apache.activemq.transport.discovery.DiscoveryAgent;
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
@ -32,13 +34,15 @@ import org.apache.activemq.transport.discovery.DiscoveryListener;
*/
public class SimpleDiscoveryAgent implements DiscoveryAgent {
private final static Log LOG = LogFactory.getLog(SimpleDiscoveryAgent.class);
private long initialReconnectDelay = 1000;
private long maxReconnectDelay = 1000 * 30;
private long backOffMultiplier = 2;
private boolean useExponentialBackOff;
private boolean useExponentialBackOff=true;
private int maxReconnectAttempts;
private final Object sleepMutex = new Object();
private long minConnectTime = 500;
private long minConnectTime = 5000;
private DiscoveryListener listener;
private String services[] = new String[] {};
private final AtomicBoolean running = new AtomicBoolean(false);
@ -109,11 +113,12 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
// fails right
// away.
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++;
if (maxReconnectAttempts > 0 && event.connectFailures >= maxReconnectAttempts) {
// Don' try to re-connect
LOG.debug("Reconnect attempts exceeded "+maxReconnectAttempts+" tries. Reconnecting has been disabled.");
return;
}
@ -123,6 +128,7 @@ public class SimpleDiscoveryAgent implements DiscoveryAgent {
return;
}
LOG.debug("Waiting "+event.reconnectDelay+" ms before attepting to reconnect.");
sleepMutex.wait(event.reconnectDelay);
} catch (InterruptedException ie) {
Thread.currentThread().interrupt();