public class CatchingReconnectionListener extends java.lang.Object implements ReconnectionListener
ReconnectionListener which ensures the methods never throw Exception (though
Error and Throwable are not caught).
This should wrap any untrusted ReconnectionListener.
This class should be regarded as internal API. We recognise it may be useful outside
internals, to which end it is exposed. The constructor is stable. All methods are
unstable and can change with breakage in patch versions. If you want a stable interface,
wrap your own reconnection listener in this, instead of extending it (and instead extend AbstractReconnectionListener).
| Modifier and Type | Field and Description |
|---|---|
private ReconnectionListener |
delegate |
private static org.slf4j.Logger |
log |
| Constructor and Description |
|---|
CatchingReconnectionListener(ReconnectionListener delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
connectionFailure(java.lang.Throwable cause)
A connection to Memcached was attempted, but ultimately failed.
|
void |
connectionLost(java.lang.Throwable cause,
HostAndPort address)
A connection to Memcached was lost after having been acquired.
|
boolean |
equals(java.lang.Object o) |
int |
hashCode() |
void |
reconnectionCancelled()
The reconnection was cancelled.
|
void |
reconnectionQueuedFromError(java.lang.Throwable cause,
HostAndPort address,
long backOffMillis,
int attempt)
A new reconnection has been queued on the executor.
|
void |
reconnectionSuccessful(HostAndPort address,
int attempt,
boolean willStayConnected)
A reconnect was successful, and a new connection has been set up.
|
java.lang.String |
toString() |
private static final org.slf4j.Logger log
private final ReconnectionListener delegate
public CatchingReconnectionListener(ReconnectionListener delegate)
public void connectionFailure(java.lang.Throwable cause)
connectionFailure in interface ReconnectionListenercause - why the connection failed, never nullpublic void reconnectionCancelled()
reconnectionCancelled in interface ReconnectionListenerpublic void reconnectionSuccessful(HostAndPort address, int attempt, boolean willStayConnected)
reconnectionSuccessful in interface ReconnectionListeneraddress - the address to which the client connected, never nullattempt - which attempt it succeeded on; this is 1-indexed (i.e. 1st attempt is 1, 2nd is
2)willStayConnected - whether the connection will immediately close after this, often due to
race conditionspublic void connectionLost(@Nullable
java.lang.Throwable cause,
HostAndPort address)
This will be called regardless of if it was shut down intentionally, or in error.
connectionLost in interface ReconnectionListenercause - the cause of losing the connection, can be nulladdress - the address to the Memcached node we were connected, never nullpublic void reconnectionQueuedFromError(java.lang.Throwable cause,
HostAndPort address,
long backOffMillis,
int attempt)
If the client is shut down between this call and the actual connection, you will never see a follow-up to any success or failure method.
reconnectionQueuedFromError in interface ReconnectionListenercause - the cause of the reconnection, i.e. "what failed to cause this?", never nulladdress - the address to the Memcached node we will connect to, never nullbackOffMillis - how many milliseconds we will wait before we attempt again, never nullattempt - which attempt we are on; this is 1-indexed (i.e. 1st attempt is 1, 2nd is 2)public boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2023 Spotify AB. All Rights Reserved.