public class BasicAddressResolver extends Object implements AddressResolver
AddressResolver
.
Allows to provide simple mapping between different address, which is useful different parts of the cluster are located in different subnetworks and port forwarding on the router is used for communication between them. Another common case is Docker environment which can create a pair of public and private address per container.
There are two different types of mapping supported by this implementation of
AddressResolver
.
First type maps specific socket addresses (host and port pairs) are mapped to each other. This is useful for port forwarding, where multiple nodes will typically map to the same external address (router), but with different port numbers. Here is the example:
<property name="addressResolver"> <bean class="org.apache.ignite.configuration.BasicAddressResolver"> <constructor-arg> <map> <entry key="10.0.0.1:47100" value="123.123.123.123:1111"/> <entry key="10.0.0.2:47100" value="123.123.123.123:2222"/> <entry key="10.0.0.3:47100" value="123.123.123.123:3333"/> </map> </constructor-arg> </bean> </property>
Second type maps one host to another. In this case any internal address a node is bound to will be mapped to the corresponding external host with the same host number. Here is the example:
<property name="addressResolver"> <bean class="org.apache.ignite.configuration.BasicAddressResolver"> <constructor-arg> <map> <entry key="10.0.0.1" value="123.123.123.123"/> </map> </constructor-arg> </bean> </property>Here any port on
10.0.0.1
will be mapped to the same port number on 123.123.123.123
.
E.g., 10.0.0.1:47100
will be mapped to 123.123.123.123:47100
, and 10.0.0.1:47500
will be mapped to 123.123.123.123:47500
.
Two types of mappings described above can be mixed within one address resolver.
Constructor and Description |
---|
BasicAddressResolver(Map<String,String> addrMap)
Created the address resolver.
|
Modifier and Type | Method and Description |
---|---|
Collection<InetSocketAddress> |
getExternalAddresses(InetSocketAddress addr)
Maps internal address to a collection of external addresses.
|
String |
toString() |
public BasicAddressResolver(Map<String,String> addrMap) throws UnknownHostException
addrMap
- Address mappings.UnknownHostException
- If any of the hosts can't be resolved.public Collection<InetSocketAddress> getExternalAddresses(InetSocketAddress addr) throws IgniteCheckedException
getExternalAddresses
in interface AddressResolver
addr
- Internal (local) address.IgniteCheckedException
- Thrown if any exception occurs.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.7.2 Release Date : February 6 2019