public class RefreshableAddressProvider extends Base implements DescribableAddressProvider
Modifier and Type | Class and Description |
---|---|
protected class |
RefreshableAddressProvider.CircularIterator
An Iterator implementation that can be converted into
circular mode to allow the remaining addresses and previously skipped
addresses to be used; typically set once an address has been accepted . |
protected class |
RefreshableAddressProvider.RefreshThread |
Base.LoggingWriter, Base.StackFrame
Modifier and Type | Field and Description |
---|---|
protected Daemon |
f_daemonRefresh
The refresh daemon.
|
protected RefreshableAddressProvider.CircularIterator |
f_iterator
An Iterator over the cached set of addresses.
|
protected long |
f_lRefresh
The interval with which to attempt to refresh the address list.
|
protected AddressProvider |
m_apRefresh
The address provider to be refreshed.
|
protected long |
m_ldtLastRefresh
The last timestamp when the address list was refreshed.
|
protected List |
m_listCache
The cached addresses.
|
static long |
REFRESH_DEFAULT
Default refresh time of 10 seconds.
|
Constructor and Description |
---|
RefreshableAddressProvider(AddressProvider ap)
Construct a RefreshableAddressProvider with the given AddressProvider
using default refresh interval
|
RefreshableAddressProvider(AddressProvider ap,
long lRefresh)
Construct a RefreshableAddressProvider with the specified AddressProvider
and refresh interval
|
Modifier and Type | Method and Description |
---|---|
void |
accept()
This method should be called by the client immediately after it determines
that it can successfully use an address returned by the
SocketAddressProvider.getNextAddress() method. |
protected void |
ensureRefreshThread()
Start the refresh thread if not already running.
|
boolean |
equals(Object o)
SocketAddressProvider instances are considered equivalent iff they
consistently produce the same resulting set of addresses.
|
String[] |
getAddressDescriptions()
Retrieve a human readable description of underlying addresses.
|
InetSocketAddress |
getNextAddress()
Covariant of
SocketAddressProvider.getNextAddress() which
returns an InetSocketAddress . |
protected InetSocketAddress |
getNextAddressInternal()
Obtain the next available address to use.
|
int |
hashCode()
Return the hash code for this SocketAddressProvider.
|
protected void |
refreshAddressList()
Refresh the cached address list using the underlying provider.
|
void |
reject(Throwable eCause)
This method should be called by the client immediately after it determines
that an attempt to use an address returned by the
SocketAddressProvider.getNextAddress()
method has failed. |
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
public static final long REFRESH_DEFAULT
protected final long f_lRefresh
protected final Daemon f_daemonRefresh
protected final RefreshableAddressProvider.CircularIterator f_iterator
protected volatile List m_listCache
protected long m_ldtLastRefresh
protected AddressProvider m_apRefresh
public RefreshableAddressProvider(AddressProvider ap)
public RefreshableAddressProvider(AddressProvider ap, long lRefresh)
lRefresh
- the refresh intervalprotected InetSocketAddress getNextAddressInternal()
public boolean equals(Object o)
Note: the general contract of hashCode and equals() should be preserved; AddressProviders that are "equal" should produce the same hashCode.
equals
in interface SocketAddressProvider
equals
in class Object
o
- the Object to compare this SocketAddressProvider to for equalitypublic int hashCode()
hashCode
in interface SocketAddressProvider
hashCode
in class Object
public final InetSocketAddress getNextAddress()
SocketAddressProvider.getNextAddress()
which
returns an InetSocketAddress
.
If the internal iterator used to return addresses is exhausted
then a new iterator is initialised and null is returned.getNextAddress
in interface AddressProvider
getNextAddress
in interface SocketAddressProvider
public final void accept()
SocketAddressProvider.getNextAddress()
method.accept
in interface SocketAddressProvider
public final void reject(Throwable eCause)
SocketAddressProvider.getNextAddress()
method has failed.reject
in interface SocketAddressProvider
eCause
- (optional) an exception that carries the reason why the
the caller rejected the previously returned addresspublic String[] getAddressDescriptions()
getAddressDescriptions
in interface DescribableAddressProvider
protected void refreshAddressList()
protected void ensureRefreshThread()