Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.net
Class RefreshableAddressProvider

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.net.RefreshableAddressProvider

All Implemented Interfaces:
AddressProvider, DescribableAddressProvider, SocketAddressProvider

public class RefreshableAddressProvider
extends Base
implements DescribableAddressProvider

A RefreshableAddressProvider is an AddressProvider implementation that wraps another AddressProvider and refresh the address list of the provider asynchronously. This ensures that the behaviour of this AddressProvider will be performant (specifically non-blocking).

Since:
Coherence 3.5
Author:
rhl 2008-12-14

Nested Class Summary
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
           

 

Field Summary
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  java.util.List m_listCache
          The cached addresses.
static long REFRESH_DEFAULT
          Default refresh time of 10 seconds.

 

Constructor Summary
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

 

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 SocketAddressProvider.getNextAddress() method.
protected  void ensureRefreshThread()
          Start the refresh thread if not already running.
 boolean equals(java.lang.Object o)
          SocketAddressProvider instances are considered equivalent iff they consistently produce the same resulting set of addresses.
 java.lang.String[] getAddressDescriptions()
          Retrieve a human readable description of underlying addresses.
 java.net.InetSocketAddress getNextAddress()
          Covariant of SocketAddressProvider.getNextAddress() which returns an InetSocketAddress.
protected  java.net.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(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 SocketAddressProvider.getNextAddress() method has failed.

 

Field Detail

REFRESH_DEFAULT

public static final long REFRESH_DEFAULT
Default refresh time of 10 seconds.

f_lRefresh

protected final long f_lRefresh
The interval with which to attempt to refresh the address list.

f_daemonRefresh

protected final Daemon f_daemonRefresh
The refresh daemon.

f_iterator

protected final RefreshableAddressProvider.CircularIterator f_iterator
An Iterator over the cached set of addresses.

m_listCache

protected volatile java.util.List m_listCache
The cached addresses.

m_ldtLastRefresh

protected long m_ldtLastRefresh
The last timestamp when the address list was refreshed.

m_apRefresh

protected AddressProvider m_apRefresh
The address provider to be refreshed.

Constructor Detail

RefreshableAddressProvider

public RefreshableAddressProvider(AddressProvider ap)
Construct a RefreshableAddressProvider with the given AddressProvider using default refresh interval

RefreshableAddressProvider

public RefreshableAddressProvider(AddressProvider ap,
                                  long lRefresh)
Construct a RefreshableAddressProvider with the specified AddressProvider and refresh interval
Parameters:
lRefresh - the refresh interval

Method Detail

getNextAddressInternal

protected java.net.InetSocketAddress getNextAddressInternal()
Obtain the next available address to use.
Returns:
the next available address or null if the list of available addresses was exhausted

equals

public boolean equals(java.lang.Object o)
SocketAddressProvider instances are considered equivalent iff they consistently produce the same resulting set of addresses.

Note: the general contract of hashCode and equals() should be preserved; AddressProviders that are "equal" should produce the same hashCode.

Specified by:
equals in interface SocketAddressProvider
Parameters:
o - the Object to compare this SocketAddressProvider to for equality
Returns:
true iff this SocketAddressProvider is equal to the specified object

hashCode

public int hashCode()
Return the hash code for this SocketAddressProvider.
Specified by:
hashCode in interface SocketAddressProvider
Returns:
the hash code for this SocketAddressProvider

getNextAddress

public final java.net.InetSocketAddress getNextAddress()
Covariant of 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.
Specified by:
getNextAddress in interface AddressProvider
Specified by:
getNextAddress in interface SocketAddressProvider
Returns:
the next available address or null if the list of available addresses was exhausted

accept

public final 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.
Specified by:
accept in interface SocketAddressProvider

reject

public final 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 SocketAddressProvider.getNextAddress() method has failed.
Specified by:
reject in interface SocketAddressProvider
Parameters:
eCause - (optional) an exception that carries the reason why the the caller rejected the previously returned address

getAddressDescriptions

public java.lang.String[] getAddressDescriptions()
Retrieve a human readable description of underlying addresses.
Specified by:
getAddressDescriptions in interface DescribableAddressProvider
Returns:
a string array of addresses in human readable format

refreshAddressList

protected void refreshAddressList()
Refresh the cached address list using the underlying provider.

ensureRefreshThread

protected void ensureRefreshThread()
Start the refresh thread if not already running.

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.