Skip to content

Commit

Permalink
Improvements to logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Apr 18, 2024
1 parent 211dc73 commit 92982d7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion convex-core/src/main/java/convex/core/util/Shutdown.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class Shutdown {
public void run() {
Shutdown.runHooks();
}
}));
},"Convex Shutdown"));
} catch(IllegalStateException e) {
// Ignore, already shutting down
}
Expand Down
15 changes: 11 additions & 4 deletions convex-peer/src/main/java/convex/peer/ConnectionManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ public synchronized void broadcast(Message msg) throws InterruptedException {
long start=Utils.getCurrentTimestamp();
while ((!hm.isEmpty())&&(start+BROADCAST_TIMEOUT>Utils.getCurrentTimestamp())) {
ArrayList<Map.Entry<AccountKey,Connection>> left=new ArrayList<>(hm.entrySet());

// Shuffle order for sending
Utils.shuffle(left);

for (Map.Entry<AccountKey,Connection> me: left) {
Connection pc=me.getValue();
try {
Expand All @@ -545,10 +548,11 @@ public synchronized void broadcast(Message msg) throws InterruptedException {
// log.warn("Delayed sending to peer because of full Buffer");
}
} catch (ClosedChannelException e) {
log.debug("Closed channel during broadcast");
log.trace("Closed channel during broadcast");
pc.close();
} catch (IOException e) {
log.warn("IO Error in broadcast: ", e);
// probably the connection was forcibly closed
log.debug("Closed channel during broadcast",e);
pc.close();
}
}
Expand Down Expand Up @@ -608,6 +612,7 @@ public Connection connectToPeer(InetSocketAddress hostAddress) {
}
} catch (IOException | TimeoutException e) {
// ignore any errors from the peer connections
return null;
} catch (UnresolvedAddressException e) {
log.info("Unable to resolve host address: "+hostAddress);
}
Expand Down Expand Up @@ -668,8 +673,10 @@ public void alertBadMessage(Message m, String message) {
* @param key
*/
public void alertMissing(Message m, MissingDataException e, AccountKey key) {
String message= "Missing data "+e.getMissingHash()+" from "+m.getOriginString();
log.warn(message);
if (log.isDebugEnabled()) {
String message= "Missing data "+e.getMissingHash()+" from "+m.getOriginString();
log.debug(message);
}

// TODO: possibly fire off request to specific Peer? Unclear if this improves things generally, but might avoid polling

Expand Down
4 changes: 2 additions & 2 deletions convex-peer/src/main/java/convex/peer/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ private void establishController() {
}
AccountStatus as=peer.getConsensusState().getAccount(controlAddress);
if (as==null) {
log.warn("Peer Controller Account does not exist: "+controlAddress);
} else if (!as.getAccountKey().equals(getKeyPair().getAccountKey())) {
log.warn("Peer Controller Account does not currently exist (perhaps pending sync?): "+controlAddress);
} else if (!Utils.equals(as.getAccountKey(),getKeyPair().getAccountKey())) {
// TODO: not a problem?
log.warn("Server keypair does not match keypair for control account: "+controlAddress);
}
Expand Down

0 comments on commit 92982d7

Please sign in to comment.