Class RegistryDNS
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.registry.server.dns.RegistryDNS
- All Implemented Interfaces:
Closeable,AutoCloseable,DNSOperations,ZoneSelector,org.apache.hadoop.service.Service
public class RegistryDNS
extends org.apache.hadoop.service.AbstractService
implements DNSOperations, ZoneSelector
A DNS service reflecting the state of the YARN registry. Records are created
based on service records available in the YARN ZK-based registry.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn implementation allowing for obtaining and releasing a lock.Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNIOTCP(InetAddress addr, int port) Create the thread (Callable) monitoring the TCP listener.voidaddNIOUDP(InetAddress addr, int port) Create the thread monitoring the socket for inbound UDP requests.protected voidaddSplitReverseZones(org.apache.hadoop.conf.Configuration conf, long subnetCount) Create the zones based on the zone count.voiddelete(String path, ServiceRecord record) Delete the DNS records generated by the provided service record.byte[]errorMessage(org.xbill.DNS.Message query, int rcode) Generate an error message based on inbound query.org.xbill.DNS.ZonefindBestZone(org.xbill.DNS.Name name) Find the zone that correlates to the provided name.org.xbill.DNS.RRsetfindExactMatch(org.xbill.DNS.Name name, int type) Find the record set that matches the requested name and type.byte[]formErrorMessage(byte[] in) Creates a DNS error response.protected org.xbill.DNS.Record[]getRecords(org.xbill.DNS.Name name, int type) Requests records for the given resource name.protected org.xbill.DNS.NamegetReverseZoneName(org.apache.hadoop.conf.Configuration conf) Returns the list of reverse lookup zones.protected intReturn the number of zones in the map.voidinitializeChannels(org.apache.hadoop.conf.Configuration conf) voidProcess a TCP request.voidregister(String path, ServiceRecord record) Register DNS records based on the provided service record.voidserveNIOTCP(ServerSocketChannel serverSocketChannel, InetAddress addr, int port) Monitor the TCP socket for inbound requests.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) Initializes the registry.protected voidStops the registry.protected voidsetDNSSECEnabled(org.apache.hadoop.conf.Configuration conf) Set the value of the DNSSEC enabled property.protected voidShuts down the leveraged executor service.Methods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, serviceStart, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.service.Service
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
-
Field Details
-
CONTAINER
- See Also:
-
IN_ADDR_ARPA
- See Also:
-
ZONE_SUFFIX
- See Also:
-
-
Constructor Details
-
RegistryDNS
Construct the service.- Parameters:
name- service name
-
-
Method Details
-
initializeChannels
- Throws:
Exception
-
serviceInit
Initializes the registry.- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Parameters:
conf- the hadoop configuration- Throws:
Exception- if there are tcp/udp issues
-
getZoneCount
@VisibleForTesting protected int getZoneCount()Return the number of zones in the map.- Returns:
- number of zones in the map
-
addSplitReverseZones
@VisibleForTesting protected void addSplitReverseZones(org.apache.hadoop.conf.Configuration conf, long subnetCount) throws IOException Create the zones based on the zone count.- Parameters:
conf- the Hadoop configuration.subnetCount- number of subnets to create reverse zones for.- Throws:
IOException- if the DNSSEC key can not be read.
-
getReverseZoneName
protected org.xbill.DNS.Name getReverseZoneName(org.apache.hadoop.conf.Configuration conf) Returns the list of reverse lookup zones.- Parameters:
conf- the hadoop configuration.- Returns:
- the list of reverse zone names required based on the configuration properties.
-
setDNSSECEnabled
@VisibleForTesting protected void setDNSSECEnabled(org.apache.hadoop.conf.Configuration conf) Set the value of the DNSSEC enabled property.- Parameters:
conf- the Hadoop configuration.
-
serviceStop
Stops the registry.- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception- if the service stop generates an issue.
-
stopExecutor
protected void stopExecutor()Shuts down the leveraged executor service. -
formErrorMessage
public byte[] formErrorMessage(byte[] in) Creates a DNS error response.- Parameters:
in- the byte array detailing the error.- Returns:
- the error message, in bytes
-
nioTCPClient
Process a TCP request.- Parameters:
ch- the socket channel for the request.- Throws:
IOException- if the tcp processing generates an issue.
-
serveNIOTCP
public void serveNIOTCP(ServerSocketChannel serverSocketChannel, InetAddress addr, int port) throws Exception Monitor the TCP socket for inbound requests.- Parameters:
serverSocketChannel- the server socket channeladdr- the local inet addressport- the listener (local) port- Throws:
Exception- if the tcp processing fails.
-
addNIOTCP
Create the thread (Callable) monitoring the TCP listener.- Parameters:
addr- host address.port- host port.- Throws:
Exception- if the tcp listener generates an error.
-
addNIOUDP
Create the thread monitoring the socket for inbound UDP requests.- Parameters:
addr- host address.port- host port.- Throws:
Exception- if the UDP listener creation generates an error.
-
errorMessage
public byte[] errorMessage(org.xbill.DNS.Message query, int rcode) Generate an error message based on inbound query.- Parameters:
query- the query.rcode- the response code for the specific error.- Returns:
- the error message.
-
getRecords
protected org.xbill.DNS.Record[] getRecords(org.xbill.DNS.Name name, int type) Requests records for the given resource name.- Parameters:
name- - query stringtype- - type of DNS record to lookup- Returns:
- DNS records
-
findExactMatch
public org.xbill.DNS.RRset findExactMatch(org.xbill.DNS.Name name, int type) Find the record set that matches the requested name and type.- Parameters:
name- the requested name.type- the record type.- Returns:
- the set of records with the given name and type.
-
findBestZone
public org.xbill.DNS.Zone findBestZone(org.xbill.DNS.Name name) Find the zone that correlates to the provided name.- Specified by:
findBestZonein interfaceZoneSelector- Parameters:
name- the name to be matched to a zone.- Returns:
- the zone.
-
register
Register DNS records based on the provided service record.- Specified by:
registerin interfaceDNSOperations- Parameters:
path- the ZK path of the service record.record- record providing DNS registration info.- Throws:
IOException- if registration causes an error.
-
delete
Delete the DNS records generated by the provided service record.- Specified by:
deletein interfaceDNSOperations- Parameters:
path- the ZK path for the given record.record- the service record- Throws:
IOException- if deletion causes and error.
-