|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
com.tangosol.util.Base
com.tangosol.net.RefreshableAddressProvider
public abstract class RefreshableAddressProvider
A RefreshableAddressProvider is an abstract AddressProvider implementation that maintains a nearly up-to-date cache of Addresses that is periodically asynchronously refreshed. This ensures that the behaviour of this AddressProvider will be performant (specifically non-blocking).
Implementing subclasses should provide implementation logic for deciding how and when the address cache should be refreshed. That logic must reside in getNextAddressInternal()
instead of getNextAddress()
.
Note: subclasses must call initialize()
before the AddressProvider is used.
Nested Class Summary | |
---|---|
protected class |
RefreshableAddressProvider.RefreshThread |
Field Summary | |
---|---|
protected Daemon |
m_daemonRefresh The refresh daemon. |
protected java.util.Iterator |
m_iterator The iterator used to implement the AddressProvider interface. |
protected java.util.List |
m_listCache The cached addresses. |
static long |
REFRESH_DEFAULT Default refresh time of 10 seconds. |
Constructor Summary | |
---|---|
RefreshableAddressProvider() Default constructor. |
|
RefreshableAddressProvider(long lRefresh) Construct a RefreshableAddressProvider with the specified refresh interval. |
Method Summary | |
---|---|
void |
accept() This method should be called by the client immediately after it determines that it can successfully use an address returned by the AddressProvider.getNextAddress() method. |
protected java.util.Iterator |
ensureIterator() Return the cache iterator. |
boolean |
equals(java.lang.Object o) AddressProvider instances are considered equivalent iff they consistently produce the same resulting set of addresses. |
protected void |
finalize() Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. |
java.net.InetSocketAddress |
getNextAddress() Obtain a next available address to use. |
protected abstract java.net.InetSocketAddress |
getNextAddressInternal() Obtain the next available address to use. |
int |
hashCode() Return the hash code for this AddressProvider. |
protected void |
initialize() Initialize the RefreshableAddressProvider and prepare it for use by populating the address-list cache and starting the refresh thread. |
protected void |
instantiateRefreshThread(long lRefresh) Start the refresh thread. |
protected abstract boolean |
isExpired() Check if the cached address list should be refreshed. |
protected void |
refreshAddressList() Refresh the cached address list using the underlying provider. |
void |
reject(java.lang.Throwable eCause) This method should be called by the client immediately after it determines that an attempt to use an address returned by the AddressProvider.getNextAddress() method has failed. |
Field Detail |
---|
public static final long REFRESH_DEFAULT
protected volatile java.util.List m_listCache
protected java.util.Iterator m_iterator
protected Daemon m_daemonRefresh
Constructor Detail |
---|
public RefreshableAddressProvider()
public RefreshableAddressProvider(long lRefresh)
lRefresh
- the refresh intervalMethod Detail |
---|
protected void initialize()
protected abstract java.net.InetSocketAddress getNextAddressInternal()
protected abstract boolean isExpired()
public boolean equals(java.lang.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 AddressProvider
o
- the Object to compare this AddressProvider to for equalitypublic int hashCode()
hashCode
in interface AddressProvider
protected void finalize()
public final java.net.InetSocketAddress getNextAddress()
AddressProvider.accept()
method.getNextAddress
in interface AddressProvider
public final void accept()
AddressProvider.getNextAddress()
method.accept
in interface AddressProvider
public final void reject(java.lang.Throwable eCause)
AddressProvider.getNextAddress()
method has failed.reject
in interface AddressProvider
eCause
- (optional) an exception that carries the reason why the the caller rejected the previously returned addressprotected void refreshAddressList()
protected void instantiateRefreshThread(long lRefresh)
protected java.util.Iterator ensureIterator()
|
Oracle® Coherence Java API Reference Release 3.7.1.0 E22843-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |