From 47d0918dce39d134de0517d8ff46001def60d2aa Mon Sep 17 00:00:00 2001 From: seb Date: Mon, 13 Dec 2010 17:20:13 +0000 Subject: [PATCH] Add some log outputs. --- src/org/ice4j/ice/Agent.java | 22 ++++++++++- src/org/ice4j/ice/CandidatePair.java | 12 ++++++ src/org/ice4j/ice/CheckList.java | 11 ++++++ src/org/ice4j/ice/Component.java | 23 +++++++++++ .../ice4j/ice/ConnectivityCheckClient.java | 39 +++++++++++++++++-- .../ice4j/ice/ConnectivityCheckServer.java | 5 +++ src/org/ice4j/ice/DefaultNominator.java | 13 +++++++ 7 files changed, 120 insertions(+), 5 deletions(-) diff --git a/src/org/ice4j/ice/Agent.java b/src/org/ice4j/ice/Agent.java index 9725c66..976a845 100644 --- a/src/org/ice4j/ice/Agent.java +++ b/src/org/ice4j/ice/Agent.java @@ -235,6 +235,7 @@ public class Agent */ public IceMediaStream createMediaStream(String mediaStreamName) { + logger.info("Create media stream for " + mediaStreamName); IceMediaStream mediaStream = new IceMediaStream(Agent.this, mediaStreamName); @@ -286,8 +287,15 @@ public class Agent Component component = stream.createComponent(transport); + logger.info("Create component " + component.toShortString()); + gatherCandidates(component, preferredPort, minPort, maxPort); + for(Candidate candidate : component.getLocalCandidates()) + { + logger.info("\t" + candidate.getTransportAddress()); + } + /* * Lyubomir: After we've gathered the LocalCandidate for a Component and * before we've make them available to the caller, we have to make sure @@ -333,6 +341,9 @@ public class Agent throws IllegalArgumentException, IOException { + logger.info("Gather candidates for component " + + component.toShortString()); + hostCandidateHarvester.harvest( component, preferredPort, minPort, maxPort); @@ -359,6 +370,7 @@ public class Agent { synchronized(startLock) { + logger.info("Start ICE connectivity establishment"); pruneNonMatchedStreams(); initCheckLists(); @@ -532,6 +544,7 @@ public class Agent for(IceMediaStream stream : streams) { + logger.info("Init checklist for stream " + stream.getName()); stream.setMaxCheckListSize(maxPerStreamSize); stream.initCheckList(); } @@ -1020,6 +1033,7 @@ public class Agent } else { + logger.fine("Receive STUN checks before our ICE has started"); //we are not started yet so we'd better wait until we get the //remote candidates in case we are holding to a new PR one. this.preDiscoveredPairsQueue.add(triggeredPair); @@ -1164,7 +1178,6 @@ public class Agent Component parentComponent = pair.getParentComponent(); IceMediaStream parentStream = parentComponent.getParentStream(); - //CheckList checkList = parentStream.getCheckList(); //If the pair is not already nominated and if its parent component //does not already contain a nominated pair - nominate it. @@ -1244,6 +1257,8 @@ public class Agent } else if(checkListState == CheckListState.COMPLETED) { + logger.info("CheckList of stream " + stream.getName() + + " is COMPLETED"); atLeastOneListSucceeded = true; } } @@ -1256,12 +1271,14 @@ public class Agent { if(getState() == IceProcessingState.RUNNING) { + logger.info("ICE state is COMPLETED"); setState(IceProcessingState.COMPLETED); scheduleTermination(); } } else { + logger.info("ICE state is FAILED"); terminate(IceProcessingState.FAILED); } } @@ -1463,6 +1480,7 @@ public class Agent } } + logger.info("ICE state is TERMINATED"); terminate(IceProcessingState.TERMINATED); } } @@ -1514,6 +1532,8 @@ public class Agent */ public void free() { + logger.info("Free ICE agent"); + /* * Set the IceProcessingState#TERMINATED state on this Agent unless it * is in a termination state already. diff --git a/src/org/ice4j/ice/CandidatePair.java b/src/org/ice4j/ice/CandidatePair.java index 3a92572..a0c715c 100644 --- a/src/org/ice4j/ice/CandidatePair.java +++ b/src/org/ice4j/ice/CandidatePair.java @@ -418,6 +418,18 @@ public class CandidatePair + "\n\tRemoteCandidate=" + getRemoteCandidate(); } + /** + * Returns a short String representation of this CandidatePair. + * + * @return a short String representation of the object. + */ + public String toShortString() + { + return getLocalCandidate().getTransportAddress() + " -> " + + getRemoteCandidate().getTransportAddress() + + " (" + getParentComponent().toShortString() + ")"; + } + /** * A Comparator using the compareTo method of the * CandidatePair diff --git a/src/org/ice4j/ice/CheckList.java b/src/org/ice4j/ice/CheckList.java index b202422..79244ad 100644 --- a/src/org/ice4j/ice/CheckList.java +++ b/src/org/ice4j/ice/CheckList.java @@ -8,6 +8,7 @@ package org.ice4j.ice; import java.beans.*; import java.util.*; +import java.util.logging.*; /** * A check list is a list of CandidatePairs with a state (i.e. a @@ -22,6 +23,12 @@ import java.util.*; public class CheckList extends Vector { + /** + * The logger. + */ + private static final Logger logger = + Logger.getLogger(CheckList.class.getName()); + /** * A dummy serialization id. */ @@ -349,6 +356,10 @@ public class CheckList { Component cmp = nominatedPair.getParentComponent(); + logger.info("Selected pair for stream " + + cmp.toShortString() + ": " + + nominatedPair.toShortString()); + cmp.setSelectedPair(nominatedPair); Iterator pairsIter = iterator(); diff --git a/src/org/ice4j/ice/Component.java b/src/org/ice4j/ice/Component.java index 40168c5..604f426 100644 --- a/src/org/ice4j/ice/Component.java +++ b/src/org/ice4j/ice/Component.java @@ -206,6 +206,9 @@ public class Component */ public void addRemoteCandidate(Candidate candidate) { + logger.info("Add remote candidate for " + toShortString() + ": " + + candidate.getTransportAddress()); + synchronized(remoteCandidates) { remoteCandidates.add(candidate); @@ -220,6 +223,9 @@ public class Component */ public void addUpdateRemoteCandidate(Candidate candidate) { + logger.info("Update remote candidate for " + toShortString() + ": " + + candidate.getTransportAddress()); + synchronized(remoteUpdateCandidates) { remoteUpdateCandidates.add(candidate); @@ -427,6 +433,23 @@ public class Component return buff.toString(); } + /** + * Returns a short String representation of this + * Component. + * + * @return a short String representation of this + * Component. + */ + public String toShortString() + { + StringBuffer buff + = new StringBuffer(parentStream.getName()); + buff.append("."); + buff.append(componentID); + + return buff.toString(); + } + /** * Computes the priorities of all Candidates and then sorts them * accordingly. diff --git a/src/org/ice4j/ice/ConnectivityCheckClient.java b/src/org/ice4j/ice/ConnectivityCheckClient.java index 9e2d741..8f8b31b 100644 --- a/src/org/ice4j/ice/ConnectivityCheckClient.java +++ b/src/org/ice4j/ice/ConnectivityCheckClient.java @@ -75,6 +75,7 @@ class ConnectivityCheckClient .get(0) .getCheckList(); + logger.info("Start connectivity checks!"); startChecks(firstCheckList); } @@ -136,8 +137,12 @@ class ConnectivityCheckClient //if we are the controlling agent then we need to indicate our //nominated pairs. if(candidatePair.isNominated()) + { + logger.fine("Add USE-CANDIDATE in check for: " + + candidatePair.toShortString()); request.addAttribute(AttributeFactory .createUseCandidateAttribute()); + } } else { @@ -220,7 +225,7 @@ class ConnectivityCheckClient if (!checkSymmetricAddresses(evt)) { logger.fine("Received a non-symmetric response for pair: " - + checkedPair +". Failing"); + + checkedPair.toShortString() +". Failing"); checkedPair.setStateFailed(); } //handle error responses. @@ -285,7 +290,11 @@ class ConnectivityCheckClient //If there is not a pair in the valid list for each component of the //media stream, the state of the check list is set to Failed. if ( !stream.validListContainsAllComponents()) + { + logger.info("CheckList for stream " + stream.getName() + + " FAILED"); checkList.setState(CheckListState.FAILED); + } //For each frozen check list, the agent groups together all of the //pairs with the same foundation, and for each group, sets the @@ -327,6 +336,7 @@ class ConnectivityCheckClient { logger.fine("Received a success response with no " +"XOR_MAPPED_ADDRESS attribute."); + logger.info("Pair failed: " + checkedPair.toShortString()); checkedPair.setStateFailed(); return; //malformed error response } @@ -375,6 +385,9 @@ class ConnectivityCheckClient //remote candidates. This is not necessary; a valid pair will be //generated from it momentarily validLocalCandidate = peerReflexiveCandidate; + + logger.fine("Receive a peer-reflexive candidate: " + + peerReflexiveCandidate.getTransportAddress()); } //check if the resulting valid pair was already in our check lists. @@ -401,10 +414,14 @@ class ConnectivityCheckClient //The agent sets the state of the pair that *generated* the check to //Succeeded. Note that, the pair which *generated* the check may be //different than the valid pair constructed above + logger.info("Pair succeeded: " + checkedPair.toShortString()); checkedPair.setStateSucceeded(); if(! validPair.isValid()) + { + logger.info("Pair validated: " + validPair.toShortString()); parentAgent.validatePair(validPair); + } //The agent changes the states for all other Frozen pairs for the //same media stream and same foundation to Waiting. @@ -451,7 +468,11 @@ class ConnectivityCheckClient checkList.computeInitialCheckListPairStates(); if (wasFrozen) + { + logger.info("Start checks for checkList of stream " + + stream.getName() + " that was frozen"); startChecks(checkList); + } } //If the agent was a controlling agent, and it had included a USE- @@ -460,6 +481,8 @@ class ConnectivityCheckClient if(parentAgent.isControlling() && request.containsAttribute(Attribute.USE_CANDIDATE)) { + logger.info("Nomination confirmed for pair: " + + validPair.toShortString()); parentAgent.nominationConfirmed( validPair ); } //If the agent is the controlled agent, the response may be the result @@ -469,7 +492,11 @@ class ConnectivityCheckClient //the pair learned from the original request. else if(checkedPair.useCandidateReceived() && ! checkedPair.isNominated()) + { + logger.info("Nomination confirmed for pair: " + + validPair.toShortString()); parentAgent.nominationConfirmed( checkedPair ); + } } /** @@ -542,7 +569,8 @@ class ConnectivityCheckClient else { logger.fine("Received an unrecoverable error response for pair " - + pair + " will mark the pair as FAILED."); + + pair.toShortString() + + " will mark the pair as FAILED."); pair.setStateFailed(); } } @@ -559,8 +587,7 @@ class ConnectivityCheckClient { CandidatePair pair = ((CandidatePair)event.getTransactionID() .getApplicationData()); - logger.fine("timeout for pair=" + pair); - + logger.info("timeout for pair: " + pair.toShortString() +", failing."); pair.setStateFailed(); updateCheckListAndTimerStates(pair); } @@ -682,7 +709,11 @@ class ConnectivityCheckClient = startCheckForPair(pairToCheck); if(transactionID == null) + { + logger.info("Pair failed: " + + pairToCheck.toShortString()); pairToCheck.setStateFailed(); + } else pairToCheck.setStateInProgress(transactionID); } diff --git a/src/org/ice4j/ice/ConnectivityCheckServer.java b/src/org/ice4j/ice/ConnectivityCheckServer.java index a5c3580..40e1c4e 100644 --- a/src/org/ice4j/ice/ConnectivityCheckServer.java +++ b/src/org/ice4j/ice/ConnectivityCheckServer.java @@ -146,6 +146,11 @@ class ConnectivityCheckServer } catch (Exception e) { + logger.log( + Level.INFO, + "Failed to send " + response + + " through " + evt.getLocalAddress(), + e); //try to trigger a 500 response although if this one failed, //then chances are the 500 will fail too. throw new RuntimeException("Failed to send a response", e); diff --git a/src/org/ice4j/ice/DefaultNominator.java b/src/org/ice4j/ice/DefaultNominator.java index 16f374a..bceb752 100644 --- a/src/org/ice4j/ice/DefaultNominator.java +++ b/src/org/ice4j/ice/DefaultNominator.java @@ -8,6 +8,7 @@ package org.ice4j.ice; import java.beans.*; import java.util.*; +import java.util.logging.*; /** * Implements ice4j internal nomination strategies. @@ -17,6 +18,12 @@ import java.util.*; public class DefaultNominator implements PropertyChangeListener { + /** + * The logger. + */ + private static Logger logger = + Logger.getLogger(DefaultNominator.class.getName()); + /** * The Agent that created us. */ @@ -91,6 +98,8 @@ public class DefaultNominator if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName())) { CandidatePair validPair = (CandidatePair)evt.getSource(); + + logger.info("Nominate (first valid): " + validPair.toShortString()); parentAgent.nominate(validPair); } } @@ -125,7 +134,11 @@ public class DefaultNominator { CandidatePair pair = parentStream.getValidPair(component); if(pair != null) + { + logger.info("Nominate (highest priority): " + + validPair.toShortString()); parentAgent.nominate(pair); + } } } }