@@ -534,7 +534,10 @@ public synchronized void broadcast(Message msg) throws InterruptedException {
534
534
long start =Utils .getCurrentTimestamp ();
535
535
while ((!hm .isEmpty ())&&(start +BROADCAST_TIMEOUT >Utils .getCurrentTimestamp ())) {
536
536
ArrayList <Map .Entry <AccountKey ,Connection >> left =new ArrayList <>(hm .entrySet ());
537
+
538
+ // Shuffle order for sending
537
539
Utils .shuffle (left );
540
+
538
541
for (Map .Entry <AccountKey ,Connection > me : left ) {
539
542
Connection pc =me .getValue ();
540
543
try {
@@ -545,10 +548,11 @@ public synchronized void broadcast(Message msg) throws InterruptedException {
545
548
// log.warn("Delayed sending to peer because of full Buffer");
546
549
}
547
550
} catch (ClosedChannelException e ) {
548
- log .debug ("Closed channel during broadcast" );
551
+ log .trace ("Closed channel during broadcast" );
549
552
pc .close ();
550
553
} catch (IOException e ) {
551
- log .warn ("IO Error in broadcast: " , e );
554
+ // probably the connection was forcibly closed
555
+ log .debug ("Closed channel during broadcast" ,e );
552
556
pc .close ();
553
557
}
554
558
}
@@ -608,6 +612,7 @@ public Connection connectToPeer(InetSocketAddress hostAddress) {
608
612
}
609
613
} catch (IOException | TimeoutException e ) {
610
614
// ignore any errors from the peer connections
615
+ return null ;
611
616
} catch (UnresolvedAddressException e ) {
612
617
log .info ("Unable to resolve host address: " +hostAddress );
613
618
}
@@ -668,8 +673,10 @@ public void alertBadMessage(Message m, String message) {
668
673
* @param key
669
674
*/
670
675
public void alertMissing (Message m , MissingDataException e , AccountKey key ) {
671
- String message = "Missing data " +e .getMissingHash ()+" from " +m .getOriginString ();
672
- log .warn (message );
676
+ if (log .isDebugEnabled ()) {
677
+ String message = "Missing data " +e .getMissingHash ()+" from " +m .getOriginString ();
678
+ log .debug (message );
679
+ }
673
680
674
681
// TODO: possibly fire off request to specific Peer? Unclear if this improves things generally, but might avoid polling
675
682
0 commit comments