Show / Hide Table of Contents

Class ConfigurableAddressProvider

ConfigurableAddressProvider is an implementation of the IAddressProvider 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>
Inheritance
object
ConfigurableAddressProvider
Implements
IAddressProvider
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Net
Assembly: Coherence.dll
Syntax
public class ConfigurableAddressProvider : IAddressProvider
Remarks

The order of items in the configured list will be randomized to provide basic load balancing. This implementation is not thread safe.

Constructors

ConfigurableAddressProvider(IXmlElement)

Construct an instance of ConfigurableAddressProvider based on the specified XML element.

Declaration
public ConfigurableAddressProvider(IXmlElement xmlConfig)
Parameters
Type Name Description
IXmlElement xmlConfig

The XML element that contains the configuration info.

Remarks

Unresolvable addresses will be skipped.

ConfigurableAddressProvider(IXmlElement, bool)

Construct an instance of ConfigurableAddressProvider based on the specified XML element.

Declaration
public ConfigurableAddressProvider(IXmlElement xmlConfig, bool isSafe)
Parameters
Type Name Description
IXmlElement xmlConfig

The XML element that contains the configuration info.

bool isSafe

True if the provider skips unresolved addresses.

Fields

f_listHolders

A list of AddressHolder objects.

Declaration
protected IList<ConfigurableAddressProvider.AddressHolder> f_listHolders
Field Value
Type Description
IList<ConfigurableAddressProvider.AddressHolder>

m_isSafe

Specifies if the provider is only to return resolved addresses.

Declaration
protected readonly bool m_isSafe
Field Value
Type Description
bool

m_iterAddr

An address iterator for the previously resolved address.

Declaration
protected IEnumerator<IPEndPoint> m_iterAddr
Field Value
Type Description
IEnumerator<IPEndPoint>

m_last

Index of the last returned address.

Declaration
protected int m_last
Field Value
Type Description
int

Properties

NextAddress

Next available address to use.

Declaration
public virtual IPEndPoint NextAddress { get; }
Property Value
Type Description
IPEndPoint

The next available address or null if the list of available addresses was exhausted.

Remarks

If the caller can successfully use the returned address (e.g. a connection was established), it should call the IAddressProvider's Accept() method.

RemoteHostAddress

The host address of a remote server that client connected to.

Declaration
public string RemoteHostAddress { get; set; }
Property Value
Type Description
string

RequestTimeout

The maximum amount of time to wait.

Declaration
public long RequestTimeout { get; set; }
Property Value
Type Description
long

Methods

Accept()

This method should be called by the client immediately after it determines that it can successfully use an address returned by the NextAddress.

Declaration
public virtual void Accept()

Configure(IXmlElement)

Configure this ConfigurableAddressProvider based on the specified XML.

Declaration
protected void Configure(IXmlElement xmlConfig)
Parameters
Type Name Description
IXmlElement xmlConfig

The XML element that contains the configuration info.

Reject(Exception)

This method should be called by the client immediately after it determines that an attempt to use an address returned by the NextAddress has failed.

Declaration
public virtual void Reject(Exception eCause)
Parameters
Type Name Description
Exception eCause

(Optional) an exception that carries the reason why the caller rejected the previously returned address.

Reset()

Make all addresses iterable, starting at the first address.

Declaration
protected void Reset()

Reset(int)

Make all addresses iterable, starting at the index after the specified one.

Declaration
protected void Reset(int iLast)
Parameters
Type Name Description
int iLast

The index after which to start.

ResolveAddress(string, int)

Resolve a host and port.

Declaration
protected IEnumerator<IPEndPoint> ResolveAddress(string host, int port)
Parameters
Type Name Description
string host

The host.

int port

The port

Returns
Type Description
IEnumerator<IPEndPoint>

An IPEndPoint enumerator.

SortHolders(IList<AddressHolder>)

Sort the holders in the order to be returned by the NextAddress property. This implementation randomizes the holder list for simple load balancing.

Declaration
protected IList<ConfigurableAddressProvider.AddressHolder> SortHolders(IList<ConfigurableAddressProvider.AddressHolder> list)
Parameters
Type Name Description
IList<ConfigurableAddressProvider.AddressHolder> list

The original list retrieved from the configuration.

Returns
Type Description
IList<ConfigurableAddressProvider.AddressHolder>

The re-ordered list.

ToString()

Return a string representation of this ConfigurableAddressProvider.

Declaration
public override string ToString()
Returns
Type Description
string

A string representation of the list of configured addresses.

Overrides
object.ToString()

Implements

IAddressProvider
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.