mirror of https://github.com/apache/nifi.git
NIFI-1965 This closes #819. COnvert DNS_TIMEOUT property to TIME_PERIOD
This commit is contained in:
parent
ae8045d99b
commit
f6ba922292
|
@ -24,6 +24,7 @@ import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import javax.naming.Context;
|
import javax.naming.Context;
|
||||||
import javax.naming.NameNotFoundException;
|
import javax.naming.NameNotFoundException;
|
||||||
|
@ -86,10 +87,10 @@ public class QueryDNS extends AbstractEnrichProcessor {
|
||||||
public static final PropertyDescriptor DNS_TIMEOUT = new PropertyDescriptor.Builder()
|
public static final PropertyDescriptor DNS_TIMEOUT = new PropertyDescriptor.Builder()
|
||||||
.name("DNS_TIMEOUT")
|
.name("DNS_TIMEOUT")
|
||||||
.displayName("DNS Query 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)
|
.required(true)
|
||||||
.defaultValue("1500")
|
.defaultValue("1500 ms")
|
||||||
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
|
.addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
public static final PropertyDescriptor DNS_RETRIES = new PropertyDescriptor.Builder()
|
public static final PropertyDescriptor DNS_RETRIES = new PropertyDescriptor.Builder()
|
||||||
|
@ -218,7 +219,7 @@ public class QueryDNS extends AbstractEnrichProcessor {
|
||||||
|
|
||||||
protected void initializeResolver(final ProcessContext context ) {
|
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 dnsServer = context.getProperty(DNS_SERVER).getValue();
|
||||||
final String dnsRetries = context.getProperty(DNS_RETRIES).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
|
* 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 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 {
|
protected Attributes doLookup(String queryInput, String queryType) throws NamingException {
|
||||||
// This is a simple DNS lookup attempt
|
// This is a simple DNS lookup attempt
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TestQueryDNS {
|
||||||
public void testVanillaQueryWithoutSplit() {
|
public void testVanillaQueryWithoutSplit() {
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "PTR");
|
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "PTR");
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1");
|
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()}" +
|
queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "${ip_address:getDelimitedField(4, '.'):trim()}" +
|
||||||
".${ip_address:getDelimitedField(3, '.'):trim()}" +
|
".${ip_address:getDelimitedField(3, '.'):trim()}" +
|
||||||
".${ip_address:getDelimitedField(2, '.'):trim()}" +
|
".${ip_address:getDelimitedField(2, '.'):trim()}" +
|
||||||
|
@ -103,7 +103,7 @@ public class TestQueryDNS {
|
||||||
public void testValidDataWithSplit() {
|
public void testValidDataWithSplit() {
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "TXT");
|
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "TXT");
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1");
|
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()}" +
|
queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "${ip_address:getDelimitedField(4, '.'):trim()}" +
|
||||||
".${ip_address:getDelimitedField(3, '.'):trim()}" +
|
".${ip_address:getDelimitedField(3, '.'):trim()}" +
|
||||||
".${ip_address:getDelimitedField(2, '.'):trim()}" +
|
".${ip_address:getDelimitedField(2, '.'):trim()}" +
|
||||||
|
@ -130,7 +130,7 @@ public class TestQueryDNS {
|
||||||
|
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "TXT");
|
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "TXT");
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1");
|
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()}" +
|
queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "${ip_address:getDelimitedField(4, '.'):trim()}" +
|
||||||
".${ip_address:getDelimitedField(3, '.'):trim()}" +
|
".${ip_address:getDelimitedField(3, '.'):trim()}" +
|
||||||
".${ip_address:getDelimitedField(2, '.'):trim()}" +
|
".${ip_address:getDelimitedField(2, '.'):trim()}" +
|
||||||
|
@ -157,7 +157,7 @@ public class TestQueryDNS {
|
||||||
public void testInvalidData() {
|
public void testInvalidData() {
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "AAAA");
|
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "AAAA");
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1");
|
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");
|
queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "nifi.apache.org");
|
||||||
|
|
||||||
|
|
||||||
|
@ -176,7 +176,7 @@ public class TestQueryDNS {
|
||||||
public void testCustomValidator() {
|
public void testCustomValidator() {
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "AAAA");
|
queryDNSTestRunner.setProperty(QueryDNS.DNS_QUERY_TYPE, "AAAA");
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.DNS_RETRIES, "1");
|
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");
|
queryDNSTestRunner.setProperty(QueryDNS.QUERY_INPUT, "nifi.apache.org");
|
||||||
// Note the absence of a QUERY_PARSER_INPUT value
|
// Note the absence of a QUERY_PARSER_INPUT value
|
||||||
queryDNSTestRunner.setProperty(QueryDNS.QUERY_PARSER, QueryDNS.REGEX.getValue());
|
queryDNSTestRunner.setProperty(QueryDNS.QUERY_PARSER, QueryDNS.REGEX.getValue());
|
||||||
|
|
Loading…
Reference in New Issue