@@ -277,37 +277,37 @@ public void onConnectionSuccess(Mqtt5Client client, OnConnectionSuccessReturn on
277277 int clientIdx = clients .indexOf (client );
278278
279279 if (connAckData .getReasonCode () == ConnAckPacket .ConnectReasonCode .SUCCESS ) {
280- PrintLog ("[Lifecycle event] Client ID " + clientIdx + " connection success..." );
280+ // PrintLog("[Lifecycle event] Client ID " + clientIdx + " connection success...");
281281 clientsData .get (clientIdx ).clientId = negotiatedSettings .getAssignedClientID ();
282282 clientsData .get (clientIdx ).connectedFuture .complete (null );
283283 clientsData .get (clientIdx ).stopFuture = new CompletableFuture <>();
284284 } else {
285- PrintLog ("[Lifecycle event] Client ID " + clientIdx + " ConnAckPacket code: " + connAckData .getReasonCode ().toString ());
285+ // PrintLog("[Lifecycle event] Client ID " + clientIdx + " ConnAckPacket code: " + connAckData.getReasonCode().toString());
286286 clientsData .get (clientIdx ).connectedFuture .completeExceptionally (new Exception ("Connection failure" ));
287287 }
288288 }
289289
290290 @ Override
291291 public void onConnectionFailure (Mqtt5Client client , OnConnectionFailureReturn onConnectionFailureReturn ) {
292292 int clientIdx = clients .indexOf (client );
293- PrintLog ("[Lifecycle event] Client ID " + clientIdx + " connection failed with errorCode : " + onConnectionFailureReturn .getErrorCode ());
293+ // PrintLog("[Lifecycle event] Client ID " + clientIdx + " connection failed with errorCode : " + onConnectionFailureReturn.getErrorCode());
294294 clientsData .get (clientIdx ).connectedFuture .completeExceptionally (new Exception ("Connection failure" ));
295295 clientsData .get (clientIdx ).subscribedToTopics = false ;
296296 }
297297
298298 @ Override
299299 public void onDisconnection (Mqtt5Client client , OnDisconnectionReturn onDisconnectionReturn ) {
300300 int clientIdx = clients .indexOf (client );
301- PrintLog ("[Lifecycle event] Client ID " + clientIdx + " connection disconnected..." );
302- PrintLog ("[Lifecycle event] Client ID " + clientIdx + " Disconnection error code: " + Integer .toString (onDisconnectionReturn .getErrorCode ()));
301+ // PrintLog("[Lifecycle event] Client ID " + clientIdx + " connection disconnected...");
302+ // PrintLog("[Lifecycle event] Client ID " + clientIdx + " Disconnection error code: " + Integer.toString(onDisconnectionReturn.getErrorCode()));
303303 clientsData .get (clientIdx ).connectedFuture = new CompletableFuture <>();
304304 clientsData .get (clientIdx ).subscribedToTopics = false ;
305305 }
306306
307307 @ Override
308308 public void onStopped (Mqtt5Client client , OnStoppedReturn onStoppedReturn ) {
309309 int clientIdx = clients .indexOf (client );
310- PrintLog ("[Lifecycle event] Client ID " + clientIdx + " connection stopped..." );
310+ // PrintLog("[Lifecycle event] Client ID " + clientIdx + " connection stopped...");
311311 clientsData .get (clientIdx ).connectedFuture = new CompletableFuture <>();
312312 clientsData .get (clientIdx ).stopFuture .complete (null );
313313 clientsData .get (clientIdx ).subscribedToTopics = false ;
@@ -319,8 +319,8 @@ static final class CanaryPublishEvents implements Mqtt5ClientOptions.PublishEven
319319 public void onMessageReceived (Mqtt5Client client , PublishReturn publishReturn ) {
320320 PublishPacket publishPacket = publishReturn .getPublishPacket ();
321321 int clientIdx = clients .indexOf (client );
322- PrintLog ("[Publish event] Client ID " + clientIdx + " message received:\n " +
323- " Topic: " + publishPacket .getTopic () + "\n " );
322+ // PrintLog("[Publish event] Client ID " + clientIdx + " message received:\n" +
323+ // " Topic: " + publishPacket.getTopic() + "\n");
324324 }
325325 }
326326
@@ -415,68 +415,68 @@ public static void setupOperations() {
415415
416416 public static void OperationNull (int clientIdx ) {
417417 // Do nothing!
418- PrintLog ("[OP] Null called for client ID " + clientIdx );
418+ // PrintLog("[OP] Null called for client ID " + clientIdx);
419419 return ;
420420 }
421421
422422 public static void OperationStart (int clientIdx ) {
423423 Mqtt5Client client = clients .get (clientIdx );
424424 if (clientsData .get (clientIdx ).isWaitingForOperation == true ) {
425- PrintLog ("[OP] Start called for client ID " + clientIdx + " but already has operation..." );
425+ // PrintLog("[OP] Start called for client ID " + clientIdx + " but already has operation...");
426426 return ;
427427 }
428428 if (client .getIsConnected () == true ) {
429- PrintLog ("[OP] Start called for client ID " + clientIdx + " but is already connected/started!" );
429+ // PrintLog("[OP] Start called for client ID " + clientIdx + " but is already connected/started!");
430430 return ;
431431 }
432432
433433 clientsData .get (clientIdx ).isWaitingForOperation = true ;
434- PrintLog ("[OP] About to start client ID " + clientIdx );
434+ // PrintLog("[OP] About to start client ID " + clientIdx);
435435 client .start ();
436436 try {
437437 clientsData .get (clientIdx ).connectedFuture .get (operationFutureWaitTime , TimeUnit .SECONDS );
438438 } catch (Exception ex ) {
439- PrintLog ("[OP] Start had an exception! Exception: " + ex );
439+ // PrintLog("[OP] Start had an exception! Exception: " + ex);
440440 ex .printStackTrace ();
441441 if (configFilePrinter != null ) {
442442 ex .printStackTrace (configFilePrinter );
443443 }
444444 }
445- PrintLog ("[OP] Started client ID " + clientIdx );
445+ // PrintLog("[OP] Started client ID " + clientIdx);
446446 clientsData .get (clientIdx ).isWaitingForOperation = false ;
447447 }
448448
449449 public static void OperationStop (int clientIdx ) {
450450 Mqtt5Client client = clients .get (clientIdx );
451451 if (clientsData .get (clientIdx ).isWaitingForOperation == true ) {
452- PrintLog ("[OP] Stop called for client ID " + clientIdx + " but already has operation..." );
452+ // PrintLog("[OP] Stop called for client ID " + clientIdx + " but already has operation...");
453453 return ;
454454 }
455455 if (client .getIsConnected () == false ) {
456- PrintLog ("[OP] Stop called for client ID " + clientIdx + " but is already disconnected/stopped!" );
456+ // PrintLog("[OP] Stop called for client ID " + clientIdx + " but is already disconnected/stopped!");
457457 return ;
458458 }
459459
460460 clientsData .get (clientIdx ).isWaitingForOperation = true ;
461- PrintLog ("[OP] About to stop client ID " + clientIdx );
461+ // PrintLog("[OP] About to stop client ID " + clientIdx);
462462 client .stop ();
463463 try {
464464 clientsData .get (clientIdx ).stopFuture .get (operationFutureWaitTime , TimeUnit .SECONDS );
465465 } catch (Exception ex ) {
466- PrintLog ("[OP] Stop had an exception! Exception: " + ex );
466+ // PrintLog("[OP] Stop had an exception! Exception: " + ex);
467467 ex .printStackTrace ();
468468 if (configFilePrinter != null ) {
469469 ex .printStackTrace (configFilePrinter );
470470 }
471471 }
472- PrintLog ("[OP] Stopped client ID " + clientIdx );
472+ // PrintLog("[OP] Stopped client ID " + clientIdx);
473473 clientsData .get (clientIdx ).isWaitingForOperation = false ;
474474 }
475475
476476 public static void OperationSubscribe (int clientIdx ) {
477477 Mqtt5Client client = clients .get (clientIdx );
478478 if (clientsData .get (clientIdx ).isWaitingForOperation == true ) {
479- PrintLog ("[OP] Subscribe called for client ID " + clientIdx + " but already has operation..." );
479+ // PrintLog("[OP] Subscribe called for client ID " + clientIdx + " but already has operation...");
480480 return ;
481481 }
482482 if (client .getIsConnected () == false ) {
@@ -488,28 +488,28 @@ public static void OperationSubscribe(int clientIdx) {
488488 }
489489
490490 clientsData .get (clientIdx ).isWaitingForOperation = true ;
491- PrintLog ("[OP] About to subscribe client ID " + clientIdx );
491+ // PrintLog("[OP] About to subscribe client ID " + clientIdx);
492492 SubscribePacketBuilder subscribePacketBuilder = new SubscribePacketBuilder ();
493493 subscribePacketBuilder .withSubscription (clientsData .get (clientIdx ).clientId , QOS .AT_LEAST_ONCE );
494494 subscribePacketBuilder .withSubscription (clientsData .get (clientIdx ).sharedTopic , QOS .AT_LEAST_ONCE );
495495 try {
496496 client .subscribe (subscribePacketBuilder .build ()).get (operationFutureWaitTime , TimeUnit .SECONDS );
497497 } catch (Exception ex ) {
498- PrintLog ("[OP] Subscribe had an exception! Exception: " + ex );
498+ // PrintLog("[OP] Subscribe had an exception! Exception: " + ex);
499499 ex .printStackTrace ();
500500 if (configFilePrinter != null ) {
501501 ex .printStackTrace (configFilePrinter );
502502 }
503503 }
504504 clientsData .get (clientIdx ).subscribedToTopics = true ;
505- PrintLog ("[OP] Subscribed client ID " + clientIdx );
505+ // PrintLog("[OP] Subscribed client ID " + clientIdx);
506506 clientsData .get (clientIdx ).isWaitingForOperation = false ;
507507 }
508508
509509 public static void OperationUnsubscribe (int clientIdx ) {
510510 Mqtt5Client client = clients .get (clientIdx );
511511 if (clientsData .get (clientIdx ).isWaitingForOperation == true ) {
512- PrintLog ("[OP] Unsubscribe called for client ID " + clientIdx + " but already has operation..." );
512+ // PrintLog("[OP] Unsubscribe called for client ID " + clientIdx + " but already has operation...");
513513 return ;
514514 }
515515 if (client .getIsConnected () == false ) {
@@ -521,28 +521,28 @@ public static void OperationUnsubscribe(int clientIdx) {
521521 }
522522
523523 clientsData .get (clientIdx ).isWaitingForOperation = true ;
524- PrintLog ("[OP] About to unsubscribe client ID " + clientIdx );
524+ // PrintLog("[OP] About to unsubscribe client ID " + clientIdx);
525525 UnsubscribePacketBuilder unsubscribePacketBuilder = new UnsubscribePacketBuilder ();
526526 unsubscribePacketBuilder .withSubscription (clientsData .get (clientIdx ).clientId );
527527 unsubscribePacketBuilder .withSubscription (clientsData .get (clientIdx ).sharedTopic );
528528 try {
529529 client .unsubscribe (unsubscribePacketBuilder .build ()).get (operationFutureWaitTime , TimeUnit .SECONDS );
530530 } catch (Exception ex ) {
531- PrintLog ("[OP] Unsubscribe had an exception! Exception: " + ex );
531+ // PrintLog("[OP] Unsubscribe had an exception! Exception: " + ex);
532532 ex .printStackTrace ();
533533 if (configFilePrinter != null ) {
534534 ex .printStackTrace (configFilePrinter );
535535 }
536536 }
537537 clientsData .get (clientIdx ).subscribedToTopics = false ;
538- PrintLog ("[OP] Unsubscribed client ID " + clientIdx );
538+ // PrintLog("[OP] Unsubscribed client ID " + clientIdx);
539539 clientsData .get (clientIdx ).isWaitingForOperation = false ;
540540 }
541541
542542 public static void OperationUnsubscribeBad (int clientIdx ) {
543543 Mqtt5Client client = clients .get (clientIdx );
544544 if (clientsData .get (clientIdx ).isWaitingForOperation == true ) {
545- PrintLog ("[OP] Unsubscribe bad called for client ID " + clientIdx + " but already has operation..." );
545+ // PrintLog("[OP] Unsubscribe bad called for client ID " + clientIdx + " but already has operation...");
546546 return ;
547547 }
548548 if (client .getIsConnected () == false ) {
@@ -551,26 +551,26 @@ public static void OperationUnsubscribeBad(int clientIdx) {
551551 }
552552
553553 clientsData .get (clientIdx ).isWaitingForOperation = true ;
554- PrintLog ("[OP] About to unsubscribe (bad) client ID " + clientIdx );
554+ // PrintLog("[OP] About to unsubscribe (bad) client ID " + clientIdx);
555555 UnsubscribePacketBuilder unsubscribePacketBuilder = new UnsubscribePacketBuilder ("Non_existent_topic_here" );
556556 try {
557557 client .unsubscribe (unsubscribePacketBuilder .build ()).get (operationFutureWaitTime , TimeUnit .SECONDS );
558558 } catch (Exception ex ) {
559- PrintLog ("[OP] Unsubscribe (bad) had an exception! Exception: " + ex );
559+ // PrintLog("[OP] Unsubscribe (bad) had an exception! Exception: " + ex);
560560 ex .printStackTrace ();
561561 if (configFilePrinter != null ) {
562562 ex .printStackTrace (configFilePrinter );
563563 }
564564 }
565- PrintLog ("[OP] Unsubscribed (bad) client ID " + clientIdx );
565+ // PrintLog("[OP] Unsubscribed (bad) client ID " + clientIdx);
566566 clientsData .get (clientIdx ).isWaitingForOperation = false ;
567567 }
568568
569569 // Note: Handles QoS 0, QoS 1, and topic filter based on passed-in input
570570 public static void OperationPublish (int clientIdx , QOS qos , String topic ) {
571571 Mqtt5Client client = clients .get (clientIdx );
572572 if (clientsData .get (clientIdx ).isWaitingForOperation == true ) {
573- PrintLog ("[OP] Publish called for client ID " + clientIdx + " with QoS" + qos + " with topic " + topic + " - but already has operation..." );
573+ // PrintLog("[OP] Publish called for client ID " + clientIdx + " with QoS" + qos + " with topic " + topic + " - but already has operation...");
574574 return ;
575575 }
576576 if (client .getIsConnected () == false ) {
@@ -579,7 +579,7 @@ public static void OperationPublish(int clientIdx, QOS qos, String topic) {
579579 }
580580
581581 clientsData .get (clientIdx ).isWaitingForOperation = true ;
582- PrintLog ("[OP] About to publish client ID " + clientIdx + " with QoS " + qos + " with topic " + topic );
582+ // PrintLog("[OP] About to publish client ID " + clientIdx + " with QoS " + qos + " with topic " + topic);
583583
584584 int payload_size = random .nextInt (MAX_PAYLOAD_SIZE );
585585 byte [] payload_bytes = new byte [payload_size ];
@@ -599,13 +599,13 @@ public static void OperationPublish(int clientIdx, QOS qos, String topic) {
599599 try {
600600 client .publish (publishPacketBuilder .build ()).get (operationFutureWaitTime , TimeUnit .SECONDS );
601601 } catch (Exception ex ) {
602- PrintLog ("[OP] Publish with QoS " + qos + " with topic " + topic + " had an exception! Exception: " + ex );
602+ // PrintLog("[OP] Publish with QoS " + qos + " with topic " + topic + " had an exception! Exception: " + ex);
603603 ex .printStackTrace ();
604604 if (configFilePrinter != null ) {
605605 ex .printStackTrace (configFilePrinter );
606606 }
607607 }
608- PrintLog ("[OP] Published client ID " + clientIdx + " with QoS " + qos + " with topic " + topic );
608+ // PrintLog("[OP] Published client ID " + clientIdx + " with QoS " + qos + " with topic " + topic);
609609 clientsData .get (clientIdx ).isWaitingForOperation = false ;
610610 }
611611
@@ -682,7 +682,7 @@ public static void PerformOperation(CANARY_OPERATIONS operation, int clientIdx)
682682 OperationPublishToSharedTopicQoS1 (clientIdx );
683683 break ;
684684 default :
685- PrintLog ("Client ID " + clientIdx + " ERROR - Unknown operation! Performing null" );
685+ // PrintLog("Client ID " + clientIdx + " ERROR - Unknown operation! Performing null");
686686 OperationNull (clientIdx );
687687 break ;
688688 }
@@ -738,7 +738,7 @@ public static void main(String[] args) {
738738
739739 // Test loop
740740 // ====================
741- PrintLog ("Starting canary test loop..." );
741+ // PrintLog("Starting canary test loop...");
742742
743743 // Print initial memory usage report
744744 PrintMemoryUsageReport (0 , 0 );
@@ -772,7 +772,7 @@ public static void main(String[] args) {
772772 try {
773773 Thread .sleep (configTps );
774774 } catch (Exception ex ) {
775- PrintLog ("[OP] Could not sleep for " + (configTps ) + " seconds due to exception! Exception: " + ex );
775+ // PrintLog("[OP] Could not sleep for " + (configTps) + " seconds due to exception! Exception: " + ex);
776776 exitWithError (1 );
777777 }
778778 }
0 commit comments