@Override
  public List<DnsEntryData> getInstanceLinksDnsData(final Instance instance) {
    MultiRecordMapper<DnsEntryData> mapper =
        new MultiRecordMapper<DnsEntryData>() {
          @Override
          protected DnsEntryData map(List<Object> input) {
            DnsEntryData data = new DnsEntryData();
            Map<String, Map<String, String>> resolve = new HashMap<>();
            Map<String, String> ips = new HashMap<>();
            String targetInstanceName =
                input.get(4) == null ? null : ((Instance) input.get(4)).getName();
            ips.put(((IpAddress) input.get(1)).getAddress(), targetInstanceName);
            // add all instance links
            resolve.put(((InstanceLink) input.get(0)).getLinkName(), ips);
            data.setSourceIpAddress(((IpAddress) input.get(2)).getAddress());
            data.setResolveServicesAndContainers(resolve);
            data.setInstance((Instance) input.get(3));
            return data;
          }
        };

    InstanceLinkTable instanceLink = mapper.add(INSTANCE_LINK);
    IpAddressTable targetIpAddress = mapper.add(IP_ADDRESS);
    IpAddressTable clientIpAddress = mapper.add(IP_ADDRESS);
    InstanceTable clientInstance = mapper.add(INSTANCE);
    InstanceTable targetInstance = mapper.add(INSTANCE);
    NicTable clientNic = NIC.as("client_nic");
    NicTable targetNic = NIC.as("target_nic");
    IpAddressNicMapTable clientNicIpTable = IP_ADDRESS_NIC_MAP.as("client_nic_ip");
    IpAddressNicMapTable targetNicIpTable = IP_ADDRESS_NIC_MAP.as("target_nic_ip");

    return create()
        .select(mapper.fields())
        .from(NIC)
        .join(clientNic)
        .on(NIC.VNET_ID.eq(clientNic.VNET_ID))
        .join(instanceLink)
        .on(instanceLink.INSTANCE_ID.eq(clientNic.INSTANCE_ID))
        .join(targetNic)
        .on(targetNic.INSTANCE_ID.eq(instanceLink.TARGET_INSTANCE_ID))
        .join(targetInstance)
        .on(targetNic.INSTANCE_ID.eq(targetInstance.ID))
        .join(targetNicIpTable)
        .on(targetNicIpTable.NIC_ID.eq(targetNic.ID))
        .join(targetIpAddress)
        .on(targetNicIpTable.IP_ADDRESS_ID.eq(targetIpAddress.ID))
        .join(clientNicIpTable)
        .on(clientNicIpTable.NIC_ID.eq(clientNic.ID))
        .join(clientIpAddress)
        .on(clientNicIpTable.IP_ADDRESS_ID.eq(clientIpAddress.ID))
        .join(clientInstance)
        .on(clientNic.INSTANCE_ID.eq(clientInstance.ID))
        .where(
            NIC.INSTANCE_ID
                .eq(instance.getId())
                .and(NIC.VNET_ID.isNotNull())
                .and(NIC.REMOVED.isNull())
                .and(targetIpAddress.ROLE.eq(IpAddressConstants.ROLE_PRIMARY))
                .and(targetIpAddress.REMOVED.isNull())
                .and(clientIpAddress.ROLE.eq(IpAddressConstants.ROLE_PRIMARY))
                .and(clientIpAddress.REMOVED.isNull())
                .and(targetNicIpTable.REMOVED.isNull())
                .and(clientNic.REMOVED.isNull())
                .and(targetNic.REMOVED.isNull())
                .and(instanceLink.REMOVED.isNull())
                .and(instanceLink.SERVICE_CONSUME_MAP_ID.isNull())
                .and(
                    targetInstance.STATE.in(
                        InstanceConstants.STATE_RUNNING, InstanceConstants.STATE_STARTING))
                .and(
                    targetInstance
                        .HEALTH_STATE
                        .isNull()
                        .or(
                            targetInstance.HEALTH_STATE.eq(
                                HealthcheckConstants.HEALTH_STATE_HEALTHY))))
        .fetch()
        .map(mapper);
  }