NIFI-12092 Add backoff parameters to JettyWebsocketClient reconnect#7761
NIFI-12092 Add backoff parameters to JettyWebsocketClient reconnect#7761Lehel44 wants to merge 4 commits intoapache:mainfrom
Conversation
| connectCount = configurationContext.getProperty(CONNECTION_ATTEMPT_COUNT).evaluateAttributeExpressions().asInteger(); | ||
| maximumBackoffMillis = configurationContext.getProperty(MAXIMUM_BACKOFF_TIME).asTimePeriod(TimeUnit.MILLISECONDS); | ||
| initialBackoffMillis = configurationContext.getProperty(INITIAL_BACKOFF_TIME).asTimePeriod(TimeUnit.MILLISECONDS); | ||
| backoffJitterMillis = (long) (initialBackoffMillis * BACKOFF_JITTER_FACTOR * ThreadLocalRandom.current().nextDouble(-1, 1)); |
There was a problem hiding this comment.
Generally we want to avoid using ThreadLocal as a mechanism in NiFi though in this case it might be fine. That said what is the need for a random number generated here? Can we just toss out this random and have an explicit value?
There was a problem hiding this comment.
Since it is only used at the initialization I can change it to Random to adhere to the guidelines.
There's a maintaining thread (maintainSessions method) that periodically checks and re-establishes connections for active sessions. When there are numerous active sessions, this could strain the server. By introducing randomness or jitter to the retry intervals, clients are less likely to retry simultaneously, spreading out the load more evenly and reducing the chances of congestion.
There was a problem hiding this comment.
To be honest I would keep it simple.
I wouldn't make this more complicated for the users unless really necessary.
The number of connection attempts are limited by the number of timer driven threads and most likely the real number of concurrent attempts would be much lower.
We really only need a delay and a simple hard-coded 1-2 sec should be suffice in my opinion. We can add a very simple jitter via a simple Random if we really want.
Summary
NIFI-12092
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation