diff --git a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/main/java/org/apache/nifi/processors/enrich/QueryDNS.java b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/main/java/org/apache/nifi/processors/enrich/QueryDNS.java index d80a72cba8..bb346c6e0e 100644 --- a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/main/java/org/apache/nifi/processors/enrich/QueryDNS.java +++ b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/main/java/org/apache/nifi/processors/enrich/QueryDNS.java @@ -24,6 +24,7 @@ import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import javax.naming.Context; import javax.naming.NameNotFoundException; @@ -86,10 +87,10 @@ public class QueryDNS extends AbstractEnrichProcessor { public static final PropertyDescriptor DNS_TIMEOUT = new PropertyDescriptor.Builder() .name("DNS_TIMEOUT") .displayName("DNS Query Timeout") - .description("The amount of milliseconds to wait until considering a query as failed") + .description("The amount of time to wait until considering a query as failed") .required(true) - .defaultValue("1500") - .addValidator(StandardValidators.NON_EMPTY_VALIDATOR) + .defaultValue("1500 ms") + .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR) .build(); public static final PropertyDescriptor DNS_RETRIES = new PropertyDescriptor.Builder() @@ -218,7 +219,7 @@ public class QueryDNS extends AbstractEnrichProcessor { protected void initializeResolver(final ProcessContext context ) { - final String dnsTimeout = context.getProperty(DNS_TIMEOUT).getValue(); + final String dnsTimeout = context.getProperty(DNS_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).toString(); final String dnsServer = context.getProperty(DNS_SERVER).getValue(); final String dnsRetries = context.getProperty(DNS_RETRIES).getValue(); @@ -247,7 +248,7 @@ public class QueryDNS extends AbstractEnrichProcessor { /** * This method performs a simple DNS lookup using JNDI * @param queryInput String containing the query body itself (e.g. 4.3.3.1.in-addr.arpa); - * @param queryType String containign the query type (e.g. TXT); + * @param queryType String containing the query type (e.g. TXT); */ protected Attributes doLookup(String queryInput, String queryType) throws NamingException { // This is a simple DNS lookup attempt @@ -273,4 +274,4 @@ public class QueryDNS extends AbstractEnrichProcessor { initialized.set(true); } -} \ No newline at end of file +} diff --git a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/enrich/TestQueryDNS.java b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/enrich/TestQueryDNS.java index 65c1a503df..593ff0864e 100644 --- a/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/enrich/TestQueryDNS.java +++ b/nifi-nar-bundles/nifi-enrich-bundle/nifi-enrich-processors/src/test/java/org/apache/nifi/processors/enrich/TestQueryDNS.java @@ -74,7 +74,7 @@ public class TestQueryDNS { public void testVanillaQueryWithoutSplit() { queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "PTR"); queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1"); - queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000"); + queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000 ms"); queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "${ip_address:getDelimitedField(4, '.'):trim()}" + ".${ip_address:getDelimitedField(3, '.'):trim()}" + ".${ip_address:getDelimitedField(2, '.'):trim()}" + @@ -103,7 +103,7 @@ public class TestQueryDNS { public void testValidDataWithSplit() { queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "TXT"); queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1"); - queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000"); + queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000 ms"); queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "${ip_address:getDelimitedField(4, '.'):trim()}" + ".${ip_address:getDelimitedField(3, '.'):trim()}" + ".${ip_address:getDelimitedField(2, '.'):trim()}" + @@ -130,7 +130,7 @@ public class TestQueryDNS { queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "TXT"); queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1"); - queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000"); + queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000 ms"); queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "${ip_address:getDelimitedField(4, '.'):trim()}" + ".${ip_address:getDelimitedField(3, '.'):trim()}" + ".${ip_address:getDelimitedField(2, '.'):trim()}" + @@ -157,7 +157,7 @@ public class TestQueryDNS { public void testInvalidData() { queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "AAAA"); queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1"); - queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000"); + queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000 ms"); queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "nifi.apache.org"); @@ -176,7 +176,7 @@ public class TestQueryDNS { public void testCustomValidator() { queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "AAAA"); queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1"); - queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000"); + queryDNSTestRunner.setProperty(QueryDNS.DNS_TIMEOUT, "1000 ms"); queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "nifi.apache.org"); // Note the absence of a QUERY_PARSER_INPUT value queryDNSTestRunner.setProperty(QueryDNS.QUERY_PARSER, QueryDNS.REGEX.getValue());