|
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
java.util.AbstractCollection
java.util.AbstractSet
com.tangosol.net.ConfigurableAddressProvider
public class ConfigurableAddressProvider
ConfigurableAddressProvider is an implementation of the AddressProvider interface based on a static list of addresses configured in an XML element that contains one or more items in the following format:
<socket-address> <address>...</address> <port>...</port> </socket-address>
The order of items in the configured list will be randomized to provide basic load balancing.
This implementation is not thread safe.
Nested Class Summary | |
---|---|
protected class |
ConfigurableAddressProvider.AddressHolder A stateful holder for an obtaining an InetSocketAddress object. |
Field Summary | |
---|---|
protected boolean |
m_fSafe Specifies if the provider is only to return resolved addresses. |
protected int |
m_iLast Index of the last returned address. |
protected java.util.List |
m_listHolders A list of AddressHolder objects. |
Constructor Summary | |
---|---|
ConfigurableAddressProvider(XmlElement xmlConfig) Construct an instance of ConfigurableAddressProvider based on the specified XML element. |
|
ConfigurableAddressProvider(XmlElement xmlConfig, boolean fSafe) Construct an instance of ConfigurableAddressProvider based on the specified XML element. |
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 void |
configure(XmlElement xmlConfig) Configure this ConfigurableAddressProvider based on the specified XML. |
static AddressProvider |
createAddressProvider(XmlElement xmlConfig, java.lang.ClassLoader loader) Instantiate an AddressProvider configured according to the specified XML. |
boolean |
equals(java.lang.Object o) AddressProvider instances should compare to be equals() iff they should be expected to consistently produce the same resulting set of addresses. |
java.net.InetSocketAddress |
getNextAddress() Obtain a next available address to use. |
int |
hashCode() Return the hash code for this AddressProvider. |
java.util.Iterator |
iterator() Returns an iterator over the elements contained in this collection. |
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. |
protected void |
reset() Make all addresses iterable, starting at the first address. |
protected void |
reset(int iLast) Make all addresses iterable, starting at the index after the specified one. |
protected java.net.InetSocketAddress |
resolveAddress(java.lang.String sHost, int nPort) Resolve an address and port. |
int |
size() Returns the number of elements in this collection. |
protected java.util.List |
sortHolders(java.util.List list) Sort the holders in the order to be returned by the getNextAddress() method. |
java.lang.String |
toString() Return a string representation of this ConfigurableAddressProvider. |
Methods inherited from class java.util.AbstractSet |
---|
removeAll |
Methods inherited from class java.util.AbstractCollection |
---|
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray |
Methods inherited from interface java.util.Set |
---|
add, addAll, clear, contains, containsAll, isEmpty, remove, retainAll, toArray, toArray |
Field Detail |
---|
protected java.util.List m_listHolders
protected int m_iLast
protected boolean m_fSafe
Constructor Detail |
---|
public ConfigurableAddressProvider(XmlElement xmlConfig)
Unresolveable addresses will be skipped.
xmlConfig
- the XML element that contains the configuration infopublic ConfigurableAddressProvider(XmlElement xmlConfig, boolean fSafe)
xmlConfig
- the XML element that contains the configuration infofSafe
- true if the provider is skips unresolved addressesMethod Detail |
---|
public java.net.InetSocketAddress getNextAddress()
AddressProvider.accept()
method.getNextAddress
in interface AddressProvider
public void accept()
AddressProvider.getNextAddress()
method.accept
in interface AddressProvider
public 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 addresspublic int size()
size
in interface java.util.Collection
size
in interface java.util.Set
size
in class java.util.AbstractCollection
public java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.Set
iterator
in class java.util.AbstractCollection
protected void reset()
protected void reset(int iLast)
iLast
- the index of the last address returnedprotected void configure(XmlElement xmlConfig)
xmlConfig
- the XML element that contains the configuration infoprotected java.util.List sortHolders(java.util.List list)
getNextAddress()
method. This implementation randomizes the holder list for simple load balancing.list
- the original list retrieved from the configurationpublic static AddressProvider createAddressProvider(XmlElement xmlConfig, java.lang.ClassLoader loader)
<!ELEMENT ... (socket-address+ | address-provider)> <!ELEMENT address-provider (class-name | (class-factory-name, method-name), init-params?> <!ELEMENT socket-address (address, port)>
xmlConfig
- the XML element that contains the configuration infoloader
- (optional) the ClassLoader that should be used to load necessary classespublic boolean equals(java.lang.Object o)
Note: the general contract of hashCode and equals() should be preserved; AddressProviders which compare equals() should have the same hashCode.
equals
in interface AddressProvider
equals
in interface java.util.Collection
equals
in interface java.util.Set
equals
in class java.util.AbstractSet
o
- the Object to compare this AddressProvider to for equalityObject.equals(Object)
, Set.equals(Object)
, List.equals(Object)
public int hashCode()
hashCode
in interface AddressProvider
hashCode
in interface java.util.Collection
hashCode
in interface java.util.Set
hashCode
in class java.util.AbstractSet
Object.hashCode()
, Object.equals(Object)
, Set.equals(Object)
public java.lang.String toString()
toString
in class java.util.AbstractCollection
protected java.net.InetSocketAddress resolveAddress(java.lang.String sHost, int nPort)
sHost
- the hostnPort
- the port
|
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 |