You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nifi.apache.org by jo...@apache.org on 2021/12/07 15:17:57 UTC

[nifi] branch main updated: NIFI-9093 This closes #5578. GetSplunk Processor hangs addressed by adding timeouts. changed the required flag to false on ConnectTimeout and ReadTimeout properties

This is an automated email from the ASF dual-hosted git repository.

joewitt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 70822b9  NIFI-9093 This closes #5578. GetSplunk Processor hangs addressed by adding timeouts. changed the required flag to false on ConnectTimeout and ReadTimeout properties
70822b9 is described below

commit 70822b9c8d9105518f759f44ff4f828fc3fb6732
Author: ahmed shaaban <ah...@localhost.localdomain>
AuthorDate: Mon Dec 6 23:17:02 2021 +0200

    NIFI-9093 This closes #5578. GetSplunk Processor hangs addressed by adding timeouts.
    changed the required flag to false on ConnectTimeout and ReadTimeout properties
    
    Signed-off-by: Joe Witt <jo...@apache.org>
---
 .../apache/nifi/processors/splunk/GetSplunk.java   | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/nifi-nar-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java b/nifi-nar-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
index f1721b4..58ab04f 100644
--- a/nifi-nar-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
+++ b/nifi-nar-bundles/nifi-splunk-bundle/nifi-splunk-processors/src/main/java/org/apache/nifi/processors/splunk/GetSplunk.java
@@ -65,6 +65,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TimeZone;
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 @TriggerSerially
@@ -105,6 +106,20 @@ public class GetSplunk extends AbstractProcessor {
             .addValidator(StandardValidators.PORT_VALIDATOR)
             .defaultValue("8089")
             .build();
+    public static final PropertyDescriptor CONNECT_TIMEOUT = new PropertyDescriptor.Builder()
+            .name("Connection Timeout")
+            .description("Max wait time for connection to the Splunk server.")
+            .required(false)
+            .defaultValue("5 secs")
+            .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+            .build();
+    public static final PropertyDescriptor READ_TIMEOUT = new PropertyDescriptor.Builder()
+            .name("Read Timeout")
+            .description("Max wait time for response from the Splunk server.")
+            .required(false)
+            .defaultValue("15 secs")
+            .addValidator(StandardValidators.TIME_PERIOD_VALIDATOR)
+            .build();
     public static final PropertyDescriptor QUERY = new PropertyDescriptor.Builder()
             .name("Query")
             .description("The query to execute. Typically beginning with a <search> command followed by a search clause, " +
@@ -256,6 +271,8 @@ public class GetSplunk extends AbstractProcessor {
         descriptors.add(SCHEME);
         descriptors.add(HOSTNAME);
         descriptors.add(PORT);
+        descriptors.add(CONNECT_TIMEOUT);
+        descriptors.add(READ_TIMEOUT);
         descriptors.add(QUERY);
         descriptors.add(TIME_FIELD_STRATEGY);
         descriptors.add(TIME_RANGE_STRATEGY);
@@ -516,6 +533,12 @@ public class GetSplunk extends AbstractProcessor {
         final int port = context.getProperty(PORT).asInteger();
         serviceArgs.setPort(port);
 
+        final int connect_timeout = context.getProperty(CONNECT_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        serviceArgs.add("connectTimeout",connect_timeout);
+
+        final int read_timeout = context.getProperty(READ_TIMEOUT).asTimePeriod(TimeUnit.MILLISECONDS).intValue();
+        serviceArgs.add("readTimeout",read_timeout);
+
         final String app = context.getProperty(APP).getValue();
         if (!StringUtils.isBlank(app)) {
             serviceArgs.setApp(app);