NIFI-408: Instead of yielding for 100 milliseconds when data is not available, Root Group Port should poll with a max wait time of 100 milliseconds and if no data is available return without yielding.

This commit is contained in:
Mark Payne 2015-03-23 15:11:41 -04:00
parent 12fa9e79f7
commit d6408046bc
1 changed files with 8 additions and 3 deletions

View File

@ -28,6 +28,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Lock;
@ -63,7 +64,6 @@ import org.apache.nifi.reporting.BulletinRepository;
import org.apache.nifi.reporting.Severity;
import org.apache.nifi.scheduling.SchedulingStrategy;
import org.apache.nifi.user.NiFiUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -126,9 +126,14 @@ public class StandardRootGroupPort extends AbstractPort implements RootGroupPort
@Override
public void onTrigger(final ProcessContext context, final ProcessSessionFactory sessionFactory) {
final FlowFileRequest flowFileRequest = requestQueue.poll();
final FlowFileRequest flowFileRequest;
try {
flowFileRequest = requestQueue.poll(100, TimeUnit.MILLISECONDS);
} catch (final InterruptedException ie) {
return;
}
if ( flowFileRequest == null ) {
context.yield();
return;
}