From f959ccfeb1db545dc6caaad80afa25f0596538fa Mon Sep 17 00:00:00 2001 From: paweldomas Date: Tue, 17 Sep 2013 11:20:51 +0000 Subject: [PATCH] Applies logging improvements patch submitted by Jakub Adamek. --- src/org/ice4j/ice/Agent.java | 11 ++++++----- src/org/ice4j/ice/Candidate.java | 9 +++++++++ src/org/ice4j/ice/CandidatePair.java | 6 +++--- src/org/ice4j/ice/Component.java | 4 ++-- src/org/ice4j/ice/ConnectivityCheckClient.java | 4 +++- .../ice/harvest/StunCandidateHarvester.java | 13 ++++++++++++- src/org/ice4j/pseudotcp/PseudoTCPBase.java | 16 +++++++++++----- src/org/ice4j/stack/StunClientTransaction.java | 9 +++++++-- src/org/ice4j/stack/StunStack.java | 8 ++++---- 9 files changed, 57 insertions(+), 23 deletions(-) diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 590e47a..552fc11 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -1438,8 +1438,8 @@ public class Agent //so it's now safe to go and see whether this is a new PR cand. if(triggeredPair.getParentComponent().getSelectedPair() == null) { - logger.info("Receive check from " + - triggeredPair.toShortString() + "triggered a check"); + logger.info("Received check from " + + triggeredPair.toShortString() + " triggered a check"); } triggerCheck(triggeredPair); } @@ -1770,9 +1770,10 @@ public class Agent { CandidatePair selectedPair = component.getSelectedPair(); - StringBuffer buf = new StringBuffer( "Harvester selected for "); + StringBuffer buf + = new StringBuffer( "Harvester used for selected pair for "); buf.append(component.toShortString()); - buf.append(" "); + buf.append(": "); if(selectedPair == null) { @@ -2364,7 +2365,7 @@ public class Agent * * @return The number of harvesting time for the harvester given in * parameter. - */ + */ public int getHarvestCount(String harvesterName) { int harvestCount; diff --git a/src/org/ice4j/ice/Candidate.java b/src/org/ice4j/ice/Candidate.java index 894d03c..3f97c59 100644 --- a/src/org/ice4j/ice/Candidate.java +++ b/src/org/ice4j/ice/Candidate.java @@ -742,6 +742,15 @@ public abstract class Candidate return buff.toString(); } + /** + * Returns short String representation of this Candidate. + * @return short String representation of this Candidate. + */ + public String toShortString() + { + return getTransportAddress() + "/" + getType(); + } + /** * Returns an integer indicating the preference that this Candidate * should be considered with for becoming a default candidate. diff --git a/src/org/ice4j/ice/CandidatePair.java b/src/org/ice4j/ice/CandidatePair.java index 944f28f..c236865 100644 --- a/src/org/ice4j/ice/CandidatePair.java +++ b/src/org/ice4j/ice/CandidatePair.java @@ -432,9 +432,9 @@ public class CandidatePair */ public String toShortString() { - return getLocalCandidate().getTransportAddress() + " -> " + - getRemoteCandidate().getTransportAddress() + - " (" + getParentComponent().toShortString() + ")"; + return getLocalCandidate().toShortString() + + " -> " + getRemoteCandidate().toShortString() + + " (" + getParentComponent().toShortString() + ")"; } /** diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java index ed821ec..17024ef 100644 --- a/src/org/ice4j/ice/Component.java +++ b/src/org/ice4j/ice/Component.java @@ -248,8 +248,8 @@ public class Component */ public void addRemoteCandidate(RemoteCandidate candidate) { - logger.info("Add remote candidate for " + toShortString() + ": " + - candidate.getTransportAddress()); + logger.info("Add remote candidate for " + toShortString() + + ": " + candidate.toShortString()); synchronized(remoteCandidates) { diff --git a/src/org/ice4j/ice/ConnectivityCheckClient.java b/src/org/ice4j/ice/ConnectivityCheckClient.java index dbb4547..be23075 100644 --- a/src/org/ice4j/ice/ConnectivityCheckClient.java +++ b/src/org/ice4j/ice/ConnectivityCheckClient.java @@ -170,7 +170,6 @@ class ConnectivityCheckClient //we don't need to do a canReach() verification here as it has been //already verified during the gathering process. - logger.fine("start check for " + candidatePair.toShortString()); Request request = MessageFactory.createBindingRequest(); if(parentAgent.getCompatibilityMode() == CompatibilityMode.GTALK) @@ -264,6 +263,9 @@ class ConnectivityCheckClient TransactionID tran = TransactionID.createNewTransactionID(); tran.setApplicationData(candidatePair); + logger.fine("start check for " + candidatePair.toShortString() + + " tid " + tran); + try { TransportAddress localAddr = localCandidate.getBase(). diff --git a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java index 9488af4..da1a385 100644 --- a/src/org/ice4j/ice/harvest/StunCandidateHarvester.java +++ b/src/org/ice4j/ice/harvest/StunCandidateHarvester.java @@ -269,12 +269,23 @@ public class StunCandidateHarvester logger.finest( "Completed " + component.toShortString() + " harvest: " + toString() - + ". Found " + candidates.size() + " candidates."); + + ". Found " + candidates.size() + + " candidates: " + listCandidates(candidates)); return candidates; } + private String listCandidates(Collection> candidates) + { + StringBuilder retval = new StringBuilder(); + for(Candidate candidate : candidates) + { + retval.append(candidate.toShortString()); + } + return retval.toString(); + } + /** * Sends a binding request to our stun server through the specified * hostCand candidate and adds it to the list of addresses still diff --git a/src/org/ice4j/pseudotcp/PseudoTCPBase.java b/src/org/ice4j/pseudotcp/PseudoTCPBase.java index ad3030f..0051f09 100755 --- a/src/org/ice4j/pseudotcp/PseudoTCPBase.java +++ b/src/org/ice4j/pseudotcp/PseudoTCPBase.java @@ -407,10 +407,10 @@ public class PseudoTCPBase */ public void notifyClock(long now) { - if (logger.isLoggable(Level.FINEST)) + /*if (logger.isLoggable(Level.FINEST)) { logger.log(Level.FINEST, debugName + " update clock " + now); - } + }*/ if (m_state == PseudoTcpState.TCP_CLOSED) { return; @@ -1312,13 +1312,19 @@ public class PseudoTCPBase { if (seg.seq > m_rcv_nxt) { - logger.log(Level.FINER, "too new"); + logger.log(Level.FINER, + "too new, seq.seq=" + seg.seq + + ", seg.len=" + seg.len + + ", m_rcv_nxt=" + m_rcv_nxt); } else { if (seg.seq + seg.len <= m_rcv_nxt) { - logger.log(Level.FINER, "too old"); + logger.log(Level.FINER, + "too old, seq.seq=" + seg.seq + + ", seg.len=" + seg.len + + ", m_rcv_nxt=" + m_rcv_nxt); } } } @@ -1748,7 +1754,7 @@ public class PseudoTCPBase // in-flight data is acknowledged. if (m_use_nagling && (m_snd_nxt > m_snd_una) && (nAvailable < m_mss)) { - logger.log(Level.FINER, "wait untill more data is acked"); + logger.log(Level.FINER, "wait until more data is acked"); return; } diff --git a/src/org/ice4j/stack/StunClientTransaction.java b/src/org/ice4j/stack/StunClientTransaction.java index e68491f..de341b8 100644 --- a/src/org/ice4j/stack/StunClientTransaction.java +++ b/src/org/ice4j/stack/StunClientTransaction.java @@ -230,8 +230,13 @@ class StunClientTransaction try { - logger.fine("retrying transmission of STUN test to " + - requestDestination.getHostAddress()); + logger.fine("retrying transmission of STUN test" + + " tid " + transactionID + + " from " + localAddress + + " to " + requestDestination + + " nextWait " + nextWaitInterval + + " retrans " + (retransmissionCounter+1) + + " of " + maxRetransmissions); sendRequest0(); } catch (Exception ex) diff --git a/src/org/ice4j/stack/StunStack.java b/src/org/ice4j/stack/StunStack.java index 1f668c5..3f86eb8 100644 --- a/src/org/ice4j/stack/StunStack.java +++ b/src/org/ice4j/stack/StunStack.java @@ -760,10 +760,10 @@ public class StunStack else { //do nothing - just drop the phantom response. - logger.fine("Dropped response - " - + "no matching client tran found."); - logger.fine("response tid was - " + tid); - logger.fine("all tids in stock were" + clientTransactions); + logger.fine("Dropped response - no matching client tran found" + + " for tid " + tid + "\n" + + "all tids in stock were " + + clientTransactions.keySet()); } } // indication