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 <joewitt@apache.org>
This commit is contained in:
ahmed shaaban 2021-12-06 23:17:02 +02:00 committed by Joe Witt
parent 1eb4264e34
commit 70822b9c8d
No known key found for this signature in database
GPG Key ID: 9093BF854F811A1A
1 changed files with 23 additions and 0 deletions

View File

@ -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);