protected int tryToAdd(FileResource fileResource) throws InterruptedException {

        if (maxFilesToAdd > -1 && added >= maxFilesToAdd) {
            return STOP_NOW;
        }

        if (maxFilesToConsider > -1 && considered > maxFilesToConsider) {
            return STOP_NOW;
        }

        boolean isAdded = false;
        if (select(fileResource.getMetadata())) {
            long start = System.currentTimeMillis();
            while (queue.offer(fileResource, PAUSE_INCREMENT_MILLIS, TimeUnit.MILLISECONDS) == false) {
                long elapsed = System.currentTimeMillis() - start;
                LOG.info("FileResourceCrawler is pausing. Queue is full: {} after {} ms", queue.size(), elapsed);

                if (maxConsecWaitInMillis > -1 && elapsed > maxConsecWaitInMillis) {
                    timedOut = true;
                    String msg = "FileResourceCrawler had to wait longer (" + elapsed + " ms) than allowed (" + maxConsecWaitInMillis + " ms)";
                    LOG.error(msg);
                    throw new InterruptedException(msg);
                }
                if (Thread
                        .currentThread()
                        .isInterrupted()) {
                    LOG.info("FileResourceCrawler shutting down because of interrupted thread.");
                    throw new InterruptedException("FileResourceCrawler interrupted.");
                }
            }
            isAdded = true;
            added++;
        } else {
            LOG.debug("crawler did not select: {}", fileResource.getResourceId());
        }
        considered++;
        return (isAdded) ? ADDED : SKIPPED;
    }
@param fileResource resource to add
@return int status of the attempt (SKIPPED, ADDED, STOP_NOW) to add the resource to the queue.
@throws InterruptedException
tika-batch/src/main/java/org/apache/tika/batch/FileResourceCrawler.java