Lehel44 commented on code in PR #7761:
URL: https://github.com/apache/nifi/pull/7761#discussion_r1334846848


##########
nifi-nar-bundles/nifi-websocket-bundle/nifi-websocket-services-jetty/src/main/java/org/apache/nifi/websocket/jetty/JettyWebSocketClient.java:
##########
@@ -229,6 +260,11 @@ protected List<PropertyDescriptor> 
getSupportedPropertyDescriptors() {
     public void startClient(final ConfigurationContext context) throws 
Exception {
         configurationContext = context;
 
+        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));

Review 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 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.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to