Add some log outputs.

This commit is contained in:
seb 2010-12-13 17:20:13 +00:00
parent cfa0e2973d
commit 47d0918dce
7 changed files with 120 additions and 5 deletions

View File

@ -235,6 +235,7 @@ public class Agent
*/ */
public IceMediaStream createMediaStream(String mediaStreamName) public IceMediaStream createMediaStream(String mediaStreamName)
{ {
logger.info("Create media stream for " + mediaStreamName);
IceMediaStream mediaStream IceMediaStream mediaStream
= new IceMediaStream(Agent.this, mediaStreamName); = new IceMediaStream(Agent.this, mediaStreamName);
@ -286,8 +287,15 @@ public class Agent
Component component = stream.createComponent(transport); Component component = stream.createComponent(transport);
logger.info("Create component " + component.toShortString());
gatherCandidates(component, preferredPort, minPort, maxPort); 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 * 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 * before we've make them available to the caller, we have to make sure
@ -333,6 +341,9 @@ public class Agent
throws IllegalArgumentException, throws IllegalArgumentException,
IOException IOException
{ {
logger.info("Gather candidates for component " +
component.toShortString());
hostCandidateHarvester.harvest( hostCandidateHarvester.harvest(
component, component,
preferredPort, minPort, maxPort); preferredPort, minPort, maxPort);
@ -359,6 +370,7 @@ public class Agent
{ {
synchronized(startLock) synchronized(startLock)
{ {
logger.info("Start ICE connectivity establishment");
pruneNonMatchedStreams(); pruneNonMatchedStreams();
initCheckLists(); initCheckLists();
@ -532,6 +544,7 @@ public class Agent
for(IceMediaStream stream : streams) for(IceMediaStream stream : streams)
{ {
logger.info("Init checklist for stream " + stream.getName());
stream.setMaxCheckListSize(maxPerStreamSize); stream.setMaxCheckListSize(maxPerStreamSize);
stream.initCheckList(); stream.initCheckList();
} }
@ -1020,6 +1033,7 @@ public class Agent
} }
else 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 //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. //remote candidates in case we are holding to a new PR one.
this.preDiscoveredPairsQueue.add(triggeredPair); this.preDiscoveredPairsQueue.add(triggeredPair);
@ -1164,7 +1178,6 @@ public class Agent
Component parentComponent = pair.getParentComponent(); Component parentComponent = pair.getParentComponent();
IceMediaStream parentStream = parentComponent.getParentStream(); IceMediaStream parentStream = parentComponent.getParentStream();
//CheckList checkList = parentStream.getCheckList();
//If the pair is not already nominated and if its parent component //If the pair is not already nominated and if its parent component
//does not already contain a nominated pair - nominate it. //does not already contain a nominated pair - nominate it.
@ -1244,6 +1257,8 @@ public class Agent
} }
else if(checkListState == CheckListState.COMPLETED) else if(checkListState == CheckListState.COMPLETED)
{ {
logger.info("CheckList of stream " + stream.getName() +
" is COMPLETED");
atLeastOneListSucceeded = true; atLeastOneListSucceeded = true;
} }
} }
@ -1256,12 +1271,14 @@ public class Agent
{ {
if(getState() == IceProcessingState.RUNNING) if(getState() == IceProcessingState.RUNNING)
{ {
logger.info("ICE state is COMPLETED");
setState(IceProcessingState.COMPLETED); setState(IceProcessingState.COMPLETED);
scheduleTermination(); scheduleTermination();
} }
} }
else else
{ {
logger.info("ICE state is FAILED");
terminate(IceProcessingState.FAILED); terminate(IceProcessingState.FAILED);
} }
} }
@ -1463,6 +1480,7 @@ public class Agent
} }
} }
logger.info("ICE state is TERMINATED");
terminate(IceProcessingState.TERMINATED); terminate(IceProcessingState.TERMINATED);
} }
} }
@ -1514,6 +1532,8 @@ public class Agent
*/ */
public void free() public void free()
{ {
logger.info("Free ICE agent");
/* /*
* Set the IceProcessingState#TERMINATED state on this Agent unless it * Set the IceProcessingState#TERMINATED state on this Agent unless it
* is in a termination state already. * is in a termination state already.

View File

@ -418,6 +418,18 @@ public class CandidatePair
+ "\n\tRemoteCandidate=" + getRemoteCandidate(); + "\n\tRemoteCandidate=" + getRemoteCandidate();
} }
/**
* Returns a short String representation of this <tt>CandidatePair</tt>.
*
* @return a short String representation of the object.
*/
public String toShortString()
{
return getLocalCandidate().getTransportAddress() + " -> " +
getRemoteCandidate().getTransportAddress() +
" (" + getParentComponent().toShortString() + ")";
}
/** /**
* A <tt>Comparator</tt> using the <tt>compareTo</tt> method of the * A <tt>Comparator</tt> using the <tt>compareTo</tt> method of the
* <tt>CandidatePair</tt> * <tt>CandidatePair</tt>

View File

@ -8,6 +8,7 @@ package org.ice4j.ice;
import java.beans.*; import java.beans.*;
import java.util.*; import java.util.*;
import java.util.logging.*;
/** /**
* A check list is a list of <tt>CandidatePair</tt>s with a state (i.e. a * A check list is a list of <tt>CandidatePair</tt>s with a state (i.e. a
@ -22,6 +23,12 @@ import java.util.*;
public class CheckList public class CheckList
extends Vector<CandidatePair> extends Vector<CandidatePair>
{ {
/**
* The logger.
*/
private static final Logger logger =
Logger.getLogger(CheckList.class.getName());
/** /**
* A dummy serialization id. * A dummy serialization id.
*/ */
@ -349,6 +356,10 @@ public class CheckList
{ {
Component cmp = nominatedPair.getParentComponent(); Component cmp = nominatedPair.getParentComponent();
logger.info("Selected pair for stream " +
cmp.toShortString() + ": " +
nominatedPair.toShortString());
cmp.setSelectedPair(nominatedPair); cmp.setSelectedPair(nominatedPair);
Iterator<CandidatePair> pairsIter = iterator(); Iterator<CandidatePair> pairsIter = iterator();

View File

@ -206,6 +206,9 @@ public class Component
*/ */
public void addRemoteCandidate(Candidate candidate) public void addRemoteCandidate(Candidate candidate)
{ {
logger.info("Add remote candidate for " + toShortString() + ": " +
candidate.getTransportAddress());
synchronized(remoteCandidates) synchronized(remoteCandidates)
{ {
remoteCandidates.add(candidate); remoteCandidates.add(candidate);
@ -220,6 +223,9 @@ public class Component
*/ */
public void addUpdateRemoteCandidate(Candidate candidate) public void addUpdateRemoteCandidate(Candidate candidate)
{ {
logger.info("Update remote candidate for " + toShortString() + ": " +
candidate.getTransportAddress());
synchronized(remoteUpdateCandidates) synchronized(remoteUpdateCandidates)
{ {
remoteUpdateCandidates.add(candidate); remoteUpdateCandidates.add(candidate);
@ -427,6 +433,23 @@ public class Component
return buff.toString(); return buff.toString();
} }
/**
* Returns a short <tt>String</tt> representation of this
* <tt>Component</tt>.
*
* @return a short <tt>String</tt> representation of this
* <tt>Component</tt>.
*/
public String toShortString()
{
StringBuffer buff
= new StringBuffer(parentStream.getName());
buff.append(".");
buff.append(componentID);
return buff.toString();
}
/** /**
* Computes the priorities of all <tt>Candidate</tt>s and then sorts them * Computes the priorities of all <tt>Candidate</tt>s and then sorts them
* accordingly. * accordingly.

View File

@ -75,6 +75,7 @@ class ConnectivityCheckClient
.get(0) .get(0)
.getCheckList(); .getCheckList();
logger.info("Start connectivity checks!");
startChecks(firstCheckList); startChecks(firstCheckList);
} }
@ -136,8 +137,12 @@ class ConnectivityCheckClient
//if we are the controlling agent then we need to indicate our //if we are the controlling agent then we need to indicate our
//nominated pairs. //nominated pairs.
if(candidatePair.isNominated()) if(candidatePair.isNominated())
{
logger.fine("Add USE-CANDIDATE in check for: " +
candidatePair.toShortString());
request.addAttribute(AttributeFactory request.addAttribute(AttributeFactory
.createUseCandidateAttribute()); .createUseCandidateAttribute());
}
} }
else else
{ {
@ -220,7 +225,7 @@ class ConnectivityCheckClient
if (!checkSymmetricAddresses(evt)) if (!checkSymmetricAddresses(evt))
{ {
logger.fine("Received a non-symmetric response for pair: " logger.fine("Received a non-symmetric response for pair: "
+ checkedPair +". Failing"); + checkedPair.toShortString() +". Failing");
checkedPair.setStateFailed(); checkedPair.setStateFailed();
} }
//handle error responses. //handle error responses.
@ -285,7 +290,11 @@ class ConnectivityCheckClient
//If there is not a pair in the valid list for each component of the //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. //media stream, the state of the check list is set to Failed.
if ( !stream.validListContainsAllComponents()) if ( !stream.validListContainsAllComponents())
{
logger.info("CheckList for stream " + stream.getName() +
" FAILED");
checkList.setState(CheckListState.FAILED); checkList.setState(CheckListState.FAILED);
}
//For each frozen check list, the agent groups together all of the //For each frozen check list, the agent groups together all of the
//pairs with the same foundation, and for each group, sets 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 " logger.fine("Received a success response with no "
+"XOR_MAPPED_ADDRESS attribute."); +"XOR_MAPPED_ADDRESS attribute.");
logger.info("Pair failed: " + checkedPair.toShortString());
checkedPair.setStateFailed(); checkedPair.setStateFailed();
return; //malformed error response return; //malformed error response
} }
@ -375,6 +385,9 @@ class ConnectivityCheckClient
//remote candidates. This is not necessary; a valid pair will be //remote candidates. This is not necessary; a valid pair will be
//generated from it momentarily //generated from it momentarily
validLocalCandidate = peerReflexiveCandidate; validLocalCandidate = peerReflexiveCandidate;
logger.fine("Receive a peer-reflexive candidate: " +
peerReflexiveCandidate.getTransportAddress());
} }
//check if the resulting valid pair was already in our check lists. //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 //The agent sets the state of the pair that *generated* the check to
//Succeeded. Note that, the pair which *generated* the check may be //Succeeded. Note that, the pair which *generated* the check may be
//different than the valid pair constructed above //different than the valid pair constructed above
logger.info("Pair succeeded: " + checkedPair.toShortString());
checkedPair.setStateSucceeded(); checkedPair.setStateSucceeded();
if(! validPair.isValid()) if(! validPair.isValid())
{
logger.info("Pair validated: " + validPair.toShortString());
parentAgent.validatePair(validPair); parentAgent.validatePair(validPair);
}
//The agent changes the states for all other Frozen pairs for the //The agent changes the states for all other Frozen pairs for the
//same media stream and same foundation to Waiting. //same media stream and same foundation to Waiting.
@ -451,7 +468,11 @@ class ConnectivityCheckClient
checkList.computeInitialCheckListPairStates(); checkList.computeInitialCheckListPairStates();
if (wasFrozen) if (wasFrozen)
{
logger.info("Start checks for checkList of stream " +
stream.getName() + " that was frozen");
startChecks(checkList); startChecks(checkList);
}
} }
//If the agent was a controlling agent, and it had included a USE- //If the agent was a controlling agent, and it had included a USE-
@ -460,6 +481,8 @@ class ConnectivityCheckClient
if(parentAgent.isControlling() if(parentAgent.isControlling()
&& request.containsAttribute(Attribute.USE_CANDIDATE)) && request.containsAttribute(Attribute.USE_CANDIDATE))
{ {
logger.info("Nomination confirmed for pair: " +
validPair.toShortString());
parentAgent.nominationConfirmed( validPair ); parentAgent.nominationConfirmed( validPair );
} }
//If the agent is the controlled agent, the response may be the result //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. //the pair learned from the original request.
else if(checkedPair.useCandidateReceived() else if(checkedPair.useCandidateReceived()
&& ! checkedPair.isNominated()) && ! checkedPair.isNominated())
{
logger.info("Nomination confirmed for pair: " +
validPair.toShortString());
parentAgent.nominationConfirmed( checkedPair ); parentAgent.nominationConfirmed( checkedPair );
}
} }
/** /**
@ -542,7 +569,8 @@ class ConnectivityCheckClient
else else
{ {
logger.fine("Received an unrecoverable error response for pair " 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(); pair.setStateFailed();
} }
} }
@ -559,8 +587,7 @@ class ConnectivityCheckClient
{ {
CandidatePair pair = ((CandidatePair)event.getTransactionID() CandidatePair pair = ((CandidatePair)event.getTransactionID()
.getApplicationData()); .getApplicationData());
logger.fine("timeout for pair=" + pair); logger.info("timeout for pair: " + pair.toShortString() +", failing.");
pair.setStateFailed(); pair.setStateFailed();
updateCheckListAndTimerStates(pair); updateCheckListAndTimerStates(pair);
} }
@ -682,7 +709,11 @@ class ConnectivityCheckClient
= startCheckForPair(pairToCheck); = startCheckForPair(pairToCheck);
if(transactionID == null) if(transactionID == null)
{
logger.info("Pair failed: " +
pairToCheck.toShortString());
pairToCheck.setStateFailed(); pairToCheck.setStateFailed();
}
else else
pairToCheck.setStateInProgress(transactionID); pairToCheck.setStateInProgress(transactionID);
} }

View File

@ -146,6 +146,11 @@ class ConnectivityCheckServer
} }
catch (Exception e) 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, //try to trigger a 500 response although if this one failed,
//then chances are the 500 will fail too. //then chances are the 500 will fail too.
throw new RuntimeException("Failed to send a response", e); throw new RuntimeException("Failed to send a response", e);

View File

@ -8,6 +8,7 @@ package org.ice4j.ice;
import java.beans.*; import java.beans.*;
import java.util.*; import java.util.*;
import java.util.logging.*;
/** /**
* Implements ice4j internal nomination strategies. * Implements ice4j internal nomination strategies.
@ -17,6 +18,12 @@ import java.util.*;
public class DefaultNominator public class DefaultNominator
implements PropertyChangeListener implements PropertyChangeListener
{ {
/**
* The logger.
*/
private static Logger logger =
Logger.getLogger(DefaultNominator.class.getName());
/** /**
* The Agent that created us. * The Agent that created us.
*/ */
@ -91,6 +98,8 @@ public class DefaultNominator
if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName())) if(IceMediaStream.PROPERTY_PAIR_VALIDATED.equals(evt.getPropertyName()))
{ {
CandidatePair validPair = (CandidatePair)evt.getSource(); CandidatePair validPair = (CandidatePair)evt.getSource();
logger.info("Nominate (first valid): " + validPair.toShortString());
parentAgent.nominate(validPair); parentAgent.nominate(validPair);
} }
} }
@ -125,7 +134,11 @@ public class DefaultNominator
{ {
CandidatePair pair = parentStream.getValidPair(component); CandidatePair pair = parentStream.getValidPair(component);
if(pair != null) if(pair != null)
{
logger.info("Nominate (highest priority): " +
validPair.toShortString());
parentAgent.nominate(pair); parentAgent.nominate(pair);
}
} }
} }
} }