nifi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joew...@apache.org
Subject [31/50] [abbrv] incubator-nifi git commit: NIFI-382: Made nifi.bored.yield.duration property
Date Mon, 02 Mar 2015 04:04:10 GMT
NIFI-382: Made nifi.bored.yield.duration property


Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/5aef55b5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/5aef55b5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/5aef55b5

Branch: refs/heads/NIFI-360
Commit: 5aef55b5f973a290a70aa3607dbcbba47b03fe79
Parents: a956623
Author: Mark Payne <markap14@hotmail.com>
Authored: Wed Feb 25 12:01:31 2015 -0500
Committer: Mark Payne <markap14@hotmail.com>
Committed: Wed Feb 25 12:01:31 2015 -0500

----------------------------------------------------------------------
 nifi/nifi-assembly/pom.xml                            |  1 +
 .../java/org/apache/nifi/util/NiFiProperties.java     |  5 +++++
 .../scheduling/TimerDrivenSchedulingAgent.java        | 14 +++++++++++---
 .../src/main/resources/conf/nifi.properties           |  2 ++
 4 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5aef55b5/nifi/nifi-assembly/pom.xml
----------------------------------------------------------------------
diff --git a/nifi/nifi-assembly/pom.xml b/nifi/nifi-assembly/pom.xml
index 8d16d5e..9a55cbc 100644
--- a/nifi/nifi-assembly/pom.xml
+++ b/nifi/nifi-assembly/pom.xml
@@ -173,6 +173,7 @@
         <nifi.flowcontroller.graceful.shutdown.period>10 sec</nifi.flowcontroller.graceful.shutdown.period>
         <nifi.flowservice.writedelay.interval>500 ms</nifi.flowservice.writedelay.interval>
         <nifi.administrative.yield.duration>30 sec</nifi.administrative.yield.duration>
+        <nifi.bored.yield.duration>10 millis</nifi.bored.yield.duration>
 
         <nifi.flow.configuration.file>./conf/flow.xml.gz</nifi.flow.configuration.file>
         <nifi.flow.configuration.archive.dir>./conf/archive/</nifi.flow.configuration.archive.dir>

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5aef55b5/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
b/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
index 10e348d..87a82d4 100644
--- a/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
+++ b/nifi/nifi-commons/nifi-properties/src/main/java/org/apache/nifi/util/NiFiProperties.java
@@ -63,6 +63,7 @@ public class NiFiProperties extends Properties {
     public static final String TEMPLATE_DIRECTORY = "nifi.templates.directory";
     public static final String ADMINISTRATIVE_YIELD_DURATION = "nifi.administrative.yield.duration";
     public static final String PERSISTENT_STATE_DIRECTORY = "nifi.persistent.state.directory";
+    public static final String BORED_YIELD_DURATION = "nifi.bored.yield.duration";
 
     // content repository properties
     public static final String REPOSITORY_CONTENT_PREFIX = "nifi.content.repository.directory.";
@@ -200,6 +201,7 @@ public class NiFiProperties extends Properties {
     public static final String DEFAULT_ADMINISTRATIVE_YIELD_DURATION = "30 sec";
     public static final String DEFAULT_PERSISTENT_STATE_DIRECTORY = "./conf/state";
     public static final String DEFAULT_COMPONENT_STATUS_SNAPSHOT_FREQUENCY = "5 mins";
+    public static final String DEFAULT_BORED_YIELD_DURATION = "10 millis";
 
     // cluster common defaults
     public static final String DEFAULT_CLUSTER_PROTOCOL_HEARTBEAT_INTERVAL = "5 sec";
@@ -873,4 +875,7 @@ public class NiFiProperties extends Properties {
         return value;
     }
 
+    public String getBoredYieldDuration() {
+        return getProperty(BORED_YIELD_DURATION, DEFAULT_BORED_YIELD_DURATION);
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5aef55b5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
index 17fb9f8..f3eecbd 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/scheduling/TimerDrivenSchedulingAgent.java
@@ -37,12 +37,13 @@ import org.apache.nifi.processor.ProcessContext;
 import org.apache.nifi.processor.StandardProcessContext;
 import org.apache.nifi.processor.exception.ProcessException;
 import org.apache.nifi.util.FormatUtils;
+import org.apache.nifi.util.NiFiProperties;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class TimerDrivenSchedulingAgent implements SchedulingAgent {
     private static final Logger logger = LoggerFactory.getLogger(TimerDrivenSchedulingAgent.class);
-    private static final long NO_WORK_YIELD_NANOS = TimeUnit.MILLISECONDS.toNanos(10L);
+    private final long noWorkYieldNanos;
     
     private final FlowController flowController;
     private final FlowEngine flowEngine;
@@ -56,6 +57,13 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
         this.flowEngine = flowEngine;
         this.contextFactory = contextFactory;
         this.encryptor = encryptor;
+        
+        final String boredYieldDuration = NiFiProperties.getInstance().getBoredYieldDuration();
+        try {
+            noWorkYieldNanos = FormatUtils.getTimeDuration(boredYieldDuration, TimeUnit.NANOSECONDS);
+        } catch (final IllegalArgumentException e) {
+            throw new RuntimeException("Failed to create SchedulingAgent because the " +
NiFiProperties.BORED_YIELD_DURATION + " property is set to an invalid time duration: " + boredYieldDuration);
+        }
     }
 
     @Override
@@ -141,7 +149,7 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
                                 }
                             }
                         }
-                    } else if ( shouldYield ) {
+                    } else if ( noWorkYieldNanos > 0L && shouldYield ) {
                         // Component itself didn't yield but there was no work to do, so
the framework will choose
                         // to yield the component automatically for a short period of time.
                         final ScheduledFuture<?> scheduledFuture = futureRef.get();
@@ -155,7 +163,7 @@ public class TimerDrivenSchedulingAgent implements SchedulingAgent {
                         if (scheduledFuture.cancel(false)) {
                             synchronized (scheduleState) {
                                 if ( scheduleState.isScheduled() ) {
-                                    final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this,
NO_WORK_YIELD_NANOS, 
+                                    final ScheduledFuture<?> newFuture = flowEngine.scheduleWithFixedDelay(this,
noWorkYieldNanos, 
                                             connectable.getSchedulingPeriod(TimeUnit.NANOSECONDS),
TimeUnit.NANOSECONDS);
                                     
                                     scheduleState.replaceFuture(scheduledFuture, newFuture);

http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/5aef55b5/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
----------------------------------------------------------------------
diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
index fa55623..fd16cb5 100644
--- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
+++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-resources/src/main/resources/conf/nifi.properties
@@ -21,6 +21,8 @@ nifi.flowcontroller.autoResumeState=${nifi.flowcontroller.autoResumeState}
 nifi.flowcontroller.graceful.shutdown.period=${nifi.flowcontroller.graceful.shutdown.period}
 nifi.flowservice.writedelay.interval=${nifi.flowservice.writedelay.interval}
 nifi.administrative.yield.duration=${nifi.administrative.yield.duration}
+# If a component has no work to do (is "bored"), how long should we wait before checking
again for work?
+nifi.bored.yield.duration=${nifi.bored.yield.duration}
 
 nifi.authority.provider.configuration.file=${nifi.authority.provider.configuration.file}
 nifi.reporting.task.configuration.file=${nifi.reporting.task.configuration.file}


Mime
View raw message