Package org.apache.bookkeeper.client
Class TopologyAwareEnsemblePlacementPolicy.DNSResolverDecorator
- java.lang.Object
-
- org.apache.bookkeeper.client.TopologyAwareEnsemblePlacementPolicy.DNSResolverDecorator
-
- All Implemented Interfaces:
DNSToSwitchMapping
- Enclosing class:
- TopologyAwareEnsemblePlacementPolicy
static class TopologyAwareEnsemblePlacementPolicy.DNSResolverDecorator extends java.lang.Object implements DNSToSwitchMapping
Decorator for any existing dsn resolver. Backfills returned data with appropriate default rack info.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.function.Supplier<java.lang.String>
defaultRackSupplier
(package private) Counter
failedToResolveNetworkLocationCounter
(package private) DNSToSwitchMapping
resolver
-
Constructor Summary
Constructors Constructor Description DNSResolverDecorator(DNSToSwitchMapping resolver, java.util.function.Supplier<java.lang.String> defaultRackSupplier, Counter failedToResolveNetworkLocationCounter)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
reloadCachedMappings()
Reload all of the cached mappings.java.util.List<java.lang.String>
resolve(java.util.List<java.lang.String> names)
Resolves a list of DNS-names/IP-addresses and returns back a list of switch information (network paths).void
setBookieAddressResolver(BookieAddressResolver bookieAddressResolver)
Receives the current BookieAddressResolver.boolean
useHostName()
Hints what to use with implementation when InetSocketAddress is converted to String: hostname (addr.getHostName(), default) or IP address (addr.getAddress().getHostAddress()).
-
-
-
Field Detail
-
defaultRackSupplier
final java.util.function.Supplier<java.lang.String> defaultRackSupplier
-
resolver
final DNSToSwitchMapping resolver
-
-
Constructor Detail
-
DNSResolverDecorator
DNSResolverDecorator(DNSToSwitchMapping resolver, java.util.function.Supplier<java.lang.String> defaultRackSupplier, Counter failedToResolveNetworkLocationCounter)
-
-
Method Detail
-
setBookieAddressResolver
public void setBookieAddressResolver(BookieAddressResolver bookieAddressResolver)
Description copied from interface:DNSToSwitchMapping
Receives the current BookieAddressResolver.- Specified by:
setBookieAddressResolver
in interfaceDNSToSwitchMapping
-
resolve
public java.util.List<java.lang.String> resolve(java.util.List<java.lang.String> names)
Description copied from interface:DNSToSwitchMapping
Resolves a list of DNS-names/IP-addresses and returns back a list of switch information (network paths). One-to-one correspondence must be maintained between the elements in the lists. Consider an element in the argument list - x.y.com. The switch information that is returned must be a network path of the form /foo/rack, where / is the root, and 'foo' is the switch where 'rack' is connected. Note the hostname/ip-address is not part of the returned path. The network topology of the cluster would determine the number of components in the network path.If a name cannot be resolved to a rack, the implementation should return
NetworkTopology.DEFAULT_REGION_AND_RACK
. This is what the bundled implementations do, though it is not a formal requirement- Specified by:
resolve
in interfaceDNSToSwitchMapping
- Parameters:
names
- the list of hosts to resolve (can be empty)- Returns:
- list of resolved network paths. If names is empty, the returned list is also empty
-
useHostName
public boolean useHostName()
Description copied from interface:DNSToSwitchMapping
Hints what to use with implementation when InetSocketAddress is converted to String: hostname (addr.getHostName(), default) or IP address (addr.getAddress().getHostAddress()).- Specified by:
useHostName
in interfaceDNSToSwitchMapping
- Returns:
- true if hostname, false if IP address. Default is true.
-
reloadCachedMappings
public void reloadCachedMappings()
Description copied from interface:DNSToSwitchMapping
Reload all of the cached mappings.If there is a cache, this method will clear it, so that future accesses will get a chance to see the new data.
- Specified by:
reloadCachedMappings
in interfaceDNSToSwitchMapping
-
-