public class FixedDelayStrategy extends java.lang.Object implements ReconnectDelayStrategy
Modifier and Type | Class and Description |
---|---|
static class |
FixedDelayStrategy.MaximumRetryExceeded
A specialized exception type thrown by ExponentialDelayStrategy
to indicate that the client should "give up" on attempting to
reconnect to a server.
|
Modifier and Type | Field and Description |
---|---|
protected int |
_delay |
protected java.lang.String |
_firstUri |
protected java.lang.String |
_lastUri |
protected int |
_maximum |
protected long |
_start |
static int |
DEFAULT_DELAY
The default delay when reconnecting to a server, in milliseconds.
|
Constructor and Description |
---|
FixedDelayStrategy()
Construct a FixedDelayStrategy with the default delay (200ms).
|
FixedDelayStrategy(int delay_)
Construct a FixedDelayStrategy with a specified delay.
|
FixedDelayStrategy(int delay_,
int maximum_)
Construct a FixedDelayStrategy with a specified delay and maximum.
|
Modifier and Type | Method and Description |
---|---|
int |
getConnectWaitDuration(java.lang.String uri_)
Returns the time (in milliseconds) that the client should wait
before connecting to the given server URI.
|
void |
reset()
Resets the state of this delay.
|
public static final int DEFAULT_DELAY
protected int _delay
protected int _maximum
protected long _start
protected java.lang.String _lastUri
protected java.lang.String _firstUri
public FixedDelayStrategy()
public FixedDelayStrategy(int delay_)
delay_
- The delay (milliseconds) to be used between reconnect
attempts to the same server.public FixedDelayStrategy(int delay_, int maximum_)
delay_
- The delay (milliseconds) to be used between reconnect
attempts to the same server.maximum_
- The maximum time (milliseconds) to try connecting
to servers before "giving up."public int getConnectWaitDuration(java.lang.String uri_) throws java.lang.Exception
getConnectWaitDuration
in interface ReconnectDelayStrategy
uri_
- The URI to which the client intends to connect.java.lang.Exception
- Any exception thrown indicates no connection
should be attempted.public void reset()
reset
in interface ReconnectDelayStrategy