RegistryDNS extends AbstractService implements DNSOperations,
    ZoneSelector { protected Record[] getRecords(Name name, int type) { Record[] result = null; ExecutorService executor = Executors.newSingleThreadExecutor(); Future<Record[]> future = executor.submit(new LookupTask(name, type)); try { result = future.get(1500, TimeUnit.MILLISECONDS); return result; } catch (InterruptedException | ExecutionException | TimeoutException | NullPointerException | ExceptionInInitializerError e) { LOG.warn("Failed to lookup: {} type: {}", name, Type.string(type), e); return result; } finally { executor.shutdown(); } } RegistryDNS(String name); void initializeChannels(Configuration conf); byte[] formErrorMessage(byte[] in); void nioTCPClient(SocketChannel ch); void serveNIOTCP(ServerSocketChannel serverSocketChannel,
      InetAddress addr, int port); void addNIOTCP(final InetAddress addr, final int port); void addNIOUDP(final InetAddress addr, final int port); byte[] errorMessage(Message query, int rcode); RRset findExactMatch(Name name, int type); @Override Zone findBestZone(Name name); @Override void register(String path, ServiceRecord record); @Override void delete(String path, ServiceRecord record); static final String CONTAINER; static final String IN_ADDR_ARPA; static final String ZONE_SUFFIX; }
@Test public void testExampleDotCom() throws Exception { Name name = Name.fromString("example.com."); Record[] records = getRegistryDNS().getRecords(name, Type.SOA); assertNotNull("example.com exists:", records); }
@Test(timeout=5000) public void testUpstreamFault() throws Exception { Name name = Name.fromString("19.0.17.172.in-addr.arpa."); Record[] recs = getRegistryDNS().getRecords(name, Type.CNAME); assertNull("Record is not null", recs); }