Exemple #1
0
        private void Collect(ProblemReporter report)
        {
            bool collect = Collects(report.Type());

            if (collect)
            {
                // This type of problem is collected and we're within the max threshold, so it's OK
                long count = _badEntries.incrementAndGet();
                if (_tolerance == UNLIMITED_TOLERANCE || count <= _tolerance)
                {
                    // We're within the threshold
                    if (_logBadEntries)
                    {
                        // Send this to the logger... but first apply some back pressure if queue is growing big
                        while (_queueSize.sum() >= _backPressureThreshold)
                        {
                            LockSupport.parkNanos(TimeUnit.MILLISECONDS.toNanos(10));
                        }
                        _logger.send(report);
                        _queueSize.add(1);
                    }
                    return;                              // i.e. don't treat this as an exception
                }
            }

            InputException exception = report.Exception();

            throw collect?withMessage(exception, format( "Too many bad entries %d, where last one was: %s", _badEntries.longValue(), exception.Message )) : exception;
        }