Adds but does not use processUnreachable to ResponseCollector.
This commit is contained in:
parent
3d5ead7341
commit
fda00cfa8a
@ -6,18 +6,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.ice4j;
|
package org.ice4j;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import java.net.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The interface is used as a callback when sending a request. The response
|
* The interface is used as a callback when sending a request. The response
|
||||||
* collector is then used as a means of dispatching the response.
|
* collector is then used as a means of dispatching the response.
|
||||||
*
|
*
|
||||||
* <p>Organisation: <p> Louis Pasteur University, Strasbourg, France</p>
|
* <p>Organization: Louis Pasteur University, Strasbourg, France</p>
|
||||||
* <p>Network Research Team (http://www-r2.u-strasbg.fr)</p></p>
|
* <p>Network Research Team (http://www-r2.u-strasbg.fr)</p>
|
||||||
* @author Emil Ivov
|
* @author Emil Ivov
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ResponseCollector
|
public interface ResponseCollector
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -32,4 +31,14 @@ public interface ResponseCollector
|
|||||||
* by rfc3489) and that the request should be considered unanswered.
|
* by rfc3489) and that the request should be considered unanswered.
|
||||||
*/
|
*/
|
||||||
public void processTimeout();
|
public void processTimeout();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies this collector that the destination of the request has been
|
||||||
|
* determined to be unreachable and that the request should be considered
|
||||||
|
* unanswered.
|
||||||
|
*
|
||||||
|
* @param exception the <tt>PortUnreachableException</tt> which signaled
|
||||||
|
* that the destination of the request was found to be unreachable
|
||||||
|
*/
|
||||||
|
public void processUnreachable(PortUnreachableException exception);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class Connector
|
|||||||
/**
|
/**
|
||||||
* The message queue is where incoming messages are added.
|
* The message queue is where incoming messages are added.
|
||||||
*/
|
*/
|
||||||
private MessageQueue messageQueue = null;
|
private final MessageQueue messageQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The socket object that used by this access point to access the network.
|
* The socket object that used by this access point to access the network.
|
||||||
@ -55,7 +55,7 @@ class Connector
|
|||||||
* The instance to be notified if errors occur in the network listening
|
* The instance to be notified if errors occur in the network listening
|
||||||
* thread.
|
* thread.
|
||||||
*/
|
*/
|
||||||
private ErrorHandler errorHandler = null;
|
private final ErrorHandler errorHandler;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The address that we are listening to.
|
* The address that we are listening to.
|
||||||
@ -160,6 +160,7 @@ class Connector
|
|||||||
+ "receive a message.",
|
+ "receive a message.",
|
||||||
ex);
|
ex);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
//The exception was most probably caused by calling
|
//The exception was most probably caused by calling
|
||||||
//this.stop() ....
|
//this.stop() ....
|
||||||
|
|||||||
@ -9,8 +9,8 @@ package org.ice4j.stack;
|
|||||||
/**
|
/**
|
||||||
* Generic Error Handler.
|
* Generic Error Handler.
|
||||||
*
|
*
|
||||||
* <p>Organisation: <p> Louis Pasteur University, Strasbourg, France.</p>
|
* <p>Organization: <p> Louis Pasteur University, Strasbourg, France.</p>
|
||||||
* <p>Network Research Team (http://www-r2.u-strasbg.fr)</p></p>
|
* <p>Network Research Team (http://www-r2.u-strasbg.fr)</p>
|
||||||
* @author Emil Ivov
|
* @author Emil Ivov
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
@ -32,5 +32,7 @@ interface ErrorHandler
|
|||||||
* @param message a message describing the error.
|
* @param message a message describing the error.
|
||||||
* @param error the error itself.
|
* @param error the error itself.
|
||||||
*/
|
*/
|
||||||
public void handleFatalError(Runnable callingThread, String message, Throwable error);
|
public void handleFatalError(Runnable callingThread,
|
||||||
|
String message,
|
||||||
|
Throwable error);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,6 @@ import org.ice4j.*;
|
|||||||
*
|
*
|
||||||
* @author Emil Ivov
|
* @author Emil Ivov
|
||||||
*/
|
*/
|
||||||
|
|
||||||
interface MessageEventHandler
|
interface MessageEventHandler
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -14,8 +14,8 @@ import java.util.logging.Logger;
|
|||||||
* access is synchronized and message delivery ( remove() ) is blocking in the
|
* access is synchronized and message delivery ( remove() ) is blocking in the
|
||||||
* case of an empty queue.
|
* case of an empty queue.
|
||||||
*
|
*
|
||||||
* <p>Organisation: Louis Pasteur University, Strasbourg, France</p>
|
* <p>Organization: Louis Pasteur University, Strasbourg, France</p>
|
||||||
* <p>Network Research Team (http://www-r2.u-strasbg.fr)</p></p>
|
* <p>Network Research Team (http://www-r2.u-strasbg.fr)</p>
|
||||||
*
|
*
|
||||||
* @author Emil Ivov
|
* @author Emil Ivov
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
@ -37,7 +37,6 @@ class MessageQueue
|
|||||||
*/
|
*/
|
||||||
MessageQueue()
|
MessageQueue()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -24,7 +24,6 @@ import org.ice4j.message.*;
|
|||||||
*
|
*
|
||||||
* @author Emil Ivov
|
* @author Emil Ivov
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class NetAccessManager
|
class NetAccessManager
|
||||||
implements ErrorHandler
|
implements ErrorHandler
|
||||||
{
|
{
|
||||||
@ -33,6 +32,7 @@ class NetAccessManager
|
|||||||
*/
|
*/
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
Logger.getLogger(NetAccessManager.class.getName());
|
Logger.getLogger(NetAccessManager.class.getName());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All access points currently in use. The table maps
|
* All access points currently in use. The table maps
|
||||||
* <tt>TransportAddress</tt>es to <tt>Connector</tt>s
|
* <tt>TransportAddress</tt>es to <tt>Connector</tt>s
|
||||||
@ -43,7 +43,7 @@ class NetAccessManager
|
|||||||
/**
|
/**
|
||||||
* A synchronized FIFO where incoming messages are stocked for processing.
|
* A synchronized FIFO where incoming messages are stocked for processing.
|
||||||
*/
|
*/
|
||||||
private MessageQueue messageQueue = new MessageQueue();
|
private final MessageQueue messageQueue = new MessageQueue();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A thread pool of message processors.
|
* A thread pool of message processors.
|
||||||
@ -52,7 +52,7 @@ class NetAccessManager
|
|||||||
= new Vector<MessageProcessor>();
|
= new Vector<MessageProcessor>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The instance that should be notified whan an incoming message has been
|
* The instance that should be notified when an incoming message has been
|
||||||
* processed and ready for delivery
|
* processed and ready for delivery
|
||||||
*/
|
*/
|
||||||
private MessageEventHandler messageEventHandler = null;
|
private MessageEventHandler messageEventHandler = null;
|
||||||
@ -119,7 +119,7 @@ class NetAccessManager
|
|||||||
{
|
{
|
||||||
MessageProcessor mp = (MessageProcessor)callingThread;
|
MessageProcessor mp = (MessageProcessor)callingThread;
|
||||||
logger.log( Level.WARNING, "A message processor has unexpectedly "
|
logger.log( Level.WARNING, "A message processor has unexpectedly "
|
||||||
+"stopped. AP:" + mp.toString(), error);
|
+"stopped. AP:" + mp, error);
|
||||||
|
|
||||||
//make sure the guy's dead.
|
//make sure the guy's dead.
|
||||||
mp.stop();
|
mp.stop();
|
||||||
@ -144,7 +144,6 @@ class NetAccessManager
|
|||||||
protected void addSocket(DatagramSocket socket)
|
protected void addSocket(DatagramSocket socket)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
|
|
||||||
//no null check - let it through a null pointer exception
|
//no null check - let it through a null pointer exception
|
||||||
TransportAddress localAddr = new TransportAddress(
|
TransportAddress localAddr = new TransportAddress(
|
||||||
socket.getLocalAddress(), socket.getLocalPort(), Transport.UDP);
|
socket.getLocalAddress(), socket.getLocalPort(), Transport.UDP);
|
||||||
@ -159,7 +158,6 @@ class NetAccessManager
|
|||||||
ap.start();
|
ap.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops and deletes the specified access point.
|
* Stops and deletes the specified access point.
|
||||||
*
|
*
|
||||||
@ -216,7 +214,6 @@ class NetAccessManager
|
|||||||
fillUpThreadPool(initialThreadPoolSize);
|
fillUpThreadPool(initialThreadPoolSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts all message processors
|
* Starts all message processors
|
||||||
*
|
*
|
||||||
@ -236,13 +233,12 @@ class NetAccessManager
|
|||||||
|
|
||||||
mp.start();
|
mp.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts all message processors
|
* Starts all message processors
|
||||||
*
|
*
|
||||||
* @param newSize the new thread poolsize
|
* @param newSize the new thread pool size
|
||||||
*/
|
*/
|
||||||
private void shrinkThreadPool(int newSize)
|
private void shrinkThreadPool(int newSize)
|
||||||
{
|
{
|
||||||
@ -281,5 +277,4 @@ class NetAccessManager
|
|||||||
|
|
||||||
ap.sendMessage(bytes, remoteAddr);
|
ap.sendMessage(bytes, remoteAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,8 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.ice4j.stack;
|
package org.ice4j.stack;
|
||||||
|
|
||||||
import java.util.logging.*;
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
import org.ice4j.message.*;
|
import org.ice4j.message.*;
|
||||||
@ -93,34 +94,34 @@ class StunClientTransaction
|
|||||||
/**
|
/**
|
||||||
* The <tt>StunStack</tt> that created us.
|
* The <tt>StunStack</tt> that created us.
|
||||||
*/
|
*/
|
||||||
private StunStack stackCallback = null;
|
private final StunStack stackCallback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The request that we are retransmitting.
|
* The request that we are retransmitting.
|
||||||
*/
|
*/
|
||||||
private Request request = null;
|
private final Request request;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The destination of the request.
|
* The destination of the request.
|
||||||
*/
|
*/
|
||||||
private TransportAddress requestDestination= null;
|
private final TransportAddress requestDestination;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The id of the transaction.
|
* The id of the transaction.
|
||||||
*/
|
*/
|
||||||
private TransactionID transactionID = null;
|
private final TransactionID transactionID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <tt>TransportAddress</tt> through which the original request was sent
|
* The <tt>TransportAddress</tt> through which the original request was sent
|
||||||
* and that we are supposed to be retransmitting through.
|
* and that we are supposed to be retransmitting through.
|
||||||
*/
|
*/
|
||||||
private TransportAddress localAddress = null;
|
private final TransportAddress localAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The instance to notify when a response has been received in the current
|
* The instance to notify when a response has been received in the current
|
||||||
* transaction or when it has timed out.
|
* transaction or when it has timed out.
|
||||||
*/
|
*/
|
||||||
private ResponseCollector responseCollector = null;
|
private final ResponseCollector responseCollector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the transaction is active or not.
|
* Determines whether the transaction is active or not.
|
||||||
@ -191,8 +192,8 @@ class StunClientTransaction
|
|||||||
retransmissionCounter ++)
|
retransmissionCounter ++)
|
||||||
{
|
{
|
||||||
waitFor(nextWaitInterval);
|
waitFor(nextWaitInterval);
|
||||||
//did someone tell us to get lost?
|
|
||||||
|
|
||||||
|
//did someone tell us to get lost?
|
||||||
if(cancelled)
|
if(cancelled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -209,7 +210,7 @@ class StunClientTransaction
|
|||||||
//has failed
|
//has failed
|
||||||
logger.log(Level.WARNING,
|
logger.log(Level.WARNING,
|
||||||
"A client tran retransmission failed", ex);
|
"A client tran retransmission failed", ex);
|
||||||
};
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//before stating that a transaction has timeout-ed we should first wait
|
//before stating that a transaction has timeout-ed we should first wait
|
||||||
@ -221,7 +222,6 @@ class StunClientTransaction
|
|||||||
|
|
||||||
responseCollector.processTimeout();
|
responseCollector.processTimeout();
|
||||||
stackCallback.removeClientTransaction(this);
|
stackCallback.removeClientTransaction(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -231,9 +231,8 @@ class StunClientTransaction
|
|||||||
* @throws IOException if an error occurs while sending message bytes
|
* @throws IOException if an error occurs while sending message bytes
|
||||||
* through the network socket.
|
* through the network socket.
|
||||||
* @throws IllegalArgumentException if the apDescriptor references an
|
* @throws IllegalArgumentException if the apDescriptor references an
|
||||||
* access point that had not been installed,
|
* access point that had not been installed
|
||||||
* @throws StunException if message encoding fails,
|
* @throws StunException if message encoding fails
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
void sendRequest()
|
void sendRequest()
|
||||||
throws StunException, IllegalArgumentException, IOException
|
throws StunException, IllegalArgumentException, IOException
|
||||||
|
|||||||
@ -46,14 +46,14 @@ public class StunStack
|
|||||||
/**
|
/**
|
||||||
* Stores active client transactions mapped against TransactionID-s.
|
* Stores active client transactions mapped against TransactionID-s.
|
||||||
*/
|
*/
|
||||||
private Hashtable<TransactionID, StunClientTransaction> clientTransactions
|
private final Hashtable<TransactionID, StunClientTransaction> clientTransactions
|
||||||
= new Hashtable<TransactionID, StunClientTransaction>();
|
= new Hashtable<TransactionID, StunClientTransaction>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Currently open server transactions. The vector contains transaction ids
|
* Currently open server transactions. The vector contains transaction ids
|
||||||
* for transactions corresponding to all non-answered received requests.
|
* for transactions corresponding to all non-answered received requests.
|
||||||
*/
|
*/
|
||||||
private Hashtable<TransactionID, StunServerTransaction> serverTransactions
|
private final Hashtable<TransactionID, StunServerTransaction> serverTransactions
|
||||||
= new Hashtable<TransactionID, StunServerTransaction>();
|
= new Hashtable<TransactionID, StunServerTransaction>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -61,7 +61,6 @@ public class StunStack
|
|||||||
*/
|
*/
|
||||||
private EventDispatcher eventDispatcher = new EventDispatcher();
|
private EventDispatcher eventDispatcher = new EventDispatcher();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the singleton StunStack instance. If the stack
|
* Returns a reference to the singleton StunStack instance. If the stack
|
||||||
* had not yet been initialized, a new instance will be created.
|
* had not yet been initialized, a new instance will be created.
|
||||||
@ -95,12 +94,11 @@ public class StunStack
|
|||||||
* @param sock The socket that the new access point should represent.
|
* @param sock The socket that the new access point should represent.
|
||||||
* @throws IOException if we fail to setup the socket.
|
* @throws IOException if we fail to setup the socket.
|
||||||
*/
|
*/
|
||||||
public void addSocket(DatagramSocket sock)
|
public void addSocket(DatagramSocket sock)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
netAccessManager.addSocket(sock);
|
netAccessManager.addSocket(sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stops and deletes the connector listening on the specified local address.
|
* Stops and deletes the connector listening on the specified local address.
|
||||||
@ -201,8 +199,7 @@ public class StunStack
|
|||||||
* through the network socket.
|
* through the network socket.
|
||||||
* @throws IllegalArgumentException if the apDescriptor references an
|
* @throws IllegalArgumentException if the apDescriptor references an
|
||||||
* access point that had not been installed,
|
* access point that had not been installed,
|
||||||
* @throws StunException if message encoding fails,
|
* @throws StunException if message encoding fails
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public void sendRequest( Request request,
|
public void sendRequest( Request request,
|
||||||
TransportAddress sendTo,
|
TransportAddress sendTo,
|
||||||
@ -235,7 +232,7 @@ public class StunStack
|
|||||||
* through the network socket.
|
* through the network socket.
|
||||||
* @throws IllegalArgumentException if the apDescriptor references an
|
* @throws IllegalArgumentException if the apDescriptor references an
|
||||||
* access point that had not been installed,
|
* access point that had not been installed,
|
||||||
* @throws StunException if message encoding fails,
|
* @throws StunException if message encoding fails
|
||||||
*/
|
*/
|
||||||
public void sendResponse(byte[] transactionID,
|
public void sendResponse(byte[] transactionID,
|
||||||
Response response,
|
Response response,
|
||||||
@ -260,9 +257,6 @@ public class StunStack
|
|||||||
{
|
{
|
||||||
sTran.sendResponse(response, sendThrough, sendTo);
|
sTran.sendResponse(response, sendThrough, sendTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +288,6 @@ public class StunStack
|
|||||||
* like to listen on.
|
* like to listen on.
|
||||||
* @param listener The ConfigurationChangeListener to be added
|
* @param listener The ConfigurationChangeListener to be added
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void addRequestListener( TransportAddress localAddress,
|
public void addRequestListener( TransportAddress localAddress,
|
||||||
RequestListener listener)
|
RequestListener listener)
|
||||||
{
|
{
|
||||||
@ -407,7 +400,6 @@ public class StunStack
|
|||||||
+ clientTransactions.toString());
|
+ clientTransactions.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -424,7 +416,6 @@ public class StunStack
|
|||||||
StunClientTransaction tran = clientTransactions.remove(item);
|
StunClientTransaction tran = clientTransactions.remove(item);
|
||||||
if(tran != null)
|
if(tran != null)
|
||||||
tran.cancel();
|
tran.cancel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tids = serverTransactions.keys();
|
tids = serverTransactions.keys();
|
||||||
@ -434,7 +425,6 @@ public class StunStack
|
|||||||
StunServerTransaction tran = serverTransactions.remove(item);
|
StunServerTransaction tran = serverTransactions.remove(item);
|
||||||
if(tran != null)
|
if(tran != null)
|
||||||
tran.expire();
|
tran.expire();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
package org.ice4j.stunclient;
|
package org.ice4j.stunclient;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.net.*;
|
||||||
import java.util.logging.*;
|
import java.util.logging.*;
|
||||||
|
|
||||||
import org.ice4j.*;
|
import org.ice4j.*;
|
||||||
@ -44,12 +45,12 @@ class BlockingRequestSender
|
|||||||
/**
|
/**
|
||||||
* The stack that we are using to send requests through.
|
* The stack that we are using to send requests through.
|
||||||
*/
|
*/
|
||||||
private StunStack stunStack = null;
|
private final StunStack stunStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The transport address that we are bound on.
|
* The transport address that we are bound on.
|
||||||
*/
|
*/
|
||||||
private TransportAddress localAddress = null;
|
private final TransportAddress localAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The <tt>StunMessageEvent</tt> that contains the response matching our
|
* The <tt>StunMessageEvent</tt> that contains the response matching our
|
||||||
@ -58,14 +59,14 @@ class BlockingRequestSender
|
|||||||
private StunMessageEvent responseEvent = null;
|
private StunMessageEvent responseEvent = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether this request sender has comleted its coarse.
|
* Determines whether this request sender has completed its course.
|
||||||
*/
|
*/
|
||||||
private boolean ended = false;
|
private boolean ended = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A lock object that we are using to synchronize sending.
|
* A lock object that we are using to synchronize sending.
|
||||||
*/
|
*/
|
||||||
private Object sendLock = new Object();
|
private final Object sendLock = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new request sender.
|
* Creates a new request sender.
|
||||||
@ -107,6 +108,25 @@ class BlockingRequestSender
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies this collector that the destination of the request has been
|
||||||
|
* determined to be unreachable and that the request should be considered
|
||||||
|
* unanswered.
|
||||||
|
*
|
||||||
|
* @param exception the <tt>PortUnreachableException</tt> which signaled
|
||||||
|
* that the destination of the request was found to be unreachable
|
||||||
|
* @see ResponseCollector#processUnreachable(PortUnreachableException)
|
||||||
|
*/
|
||||||
|
public synchronized void processUnreachable(
|
||||||
|
PortUnreachableException exception)
|
||||||
|
{
|
||||||
|
synchronized(sendLock)
|
||||||
|
{
|
||||||
|
ended = true;
|
||||||
|
notifyAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends the specified request and blocks until a response has been
|
* Sends the specified request and blocks until a response has been
|
||||||
* received or the request transaction has timed out.
|
* received or the request transaction has timed out.
|
||||||
|
|||||||
@ -283,74 +283,75 @@ public class MessageEventDispatchingTest extends TestCase
|
|||||||
/**
|
/**
|
||||||
* A utility class we use to collect incoming responses.
|
* A utility class we use to collect incoming responses.
|
||||||
*/
|
*/
|
||||||
private class PlainResponseCollector implements ResponseCollector
|
private class PlainResponseCollector
|
||||||
|
implements ResponseCollector
|
||||||
{
|
{
|
||||||
/**
|
public final Vector<Object> receivedResponses = new Vector<Object>();
|
||||||
*
|
|
||||||
*/
|
|
||||||
public Vector<Object> receivedResponses = new Vector<Object>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores incoming requests.
|
* Stores incoming requests.
|
||||||
*
|
*
|
||||||
* @param responseEvt the event containing the incoming request.
|
* @param responseEvt the event containing the incoming request.
|
||||||
*/
|
*/
|
||||||
public void processResponse(StunMessageEvent responseEvt)
|
public synchronized void processResponse(StunMessageEvent responseEvt)
|
||||||
{
|
{
|
||||||
synchronized(this)
|
receivedResponses.add(responseEvt);
|
||||||
{
|
notifyAll();
|
||||||
receivedResponses.add(responseEvt);
|
|
||||||
notifyAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates that no response has been received.
|
* Indicates that no response has been received.
|
||||||
*/
|
*/
|
||||||
public void processTimeout()
|
public synchronized void processTimeout()
|
||||||
{
|
{
|
||||||
synchronized(this)
|
receivedResponses.add("timeout");
|
||||||
{
|
notifyAll();
|
||||||
receivedResponses.add(new String("timeout"));
|
}
|
||||||
notifyAll();
|
|
||||||
}
|
/**
|
||||||
|
* Notifies this collector that the destination of the request has been
|
||||||
|
* determined to be unreachable and that the request should be
|
||||||
|
* considered unanswered.
|
||||||
|
*
|
||||||
|
* @param exception the <tt>PortUnreachableException</tt> which signaled
|
||||||
|
* that the destination of the request was found to be unreachable
|
||||||
|
* @see ResponseCollector#processUnreachable(PortUnreachableException)
|
||||||
|
*/
|
||||||
|
public synchronized void processUnreachable(
|
||||||
|
PortUnreachableException exception)
|
||||||
|
{
|
||||||
|
receivedResponses.add("unreachable");
|
||||||
|
notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for a short period of time for a response to arrive
|
* Waits for a short period of time for a response to arrive
|
||||||
*/
|
*/
|
||||||
public void waitForResponse()
|
public synchronized void waitForResponse()
|
||||||
{
|
{
|
||||||
synchronized(this)
|
try
|
||||||
{
|
{
|
||||||
try
|
if (receivedResponses.size() == 0)
|
||||||
{
|
|
||||||
if (receivedResponses.size() > 0)
|
|
||||||
return;
|
|
||||||
wait(50);
|
wait(50);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{}
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Waits for a long period of time for a timeout trigger to fire.
|
* Waits for a long period of time for a timeout trigger to fire.
|
||||||
*/
|
*/
|
||||||
public void waitForTimeout()
|
public synchronized void waitForTimeout()
|
||||||
{
|
{
|
||||||
synchronized(this)
|
try
|
||||||
{
|
{
|
||||||
try
|
if (receivedResponses.size() == 0)
|
||||||
{
|
|
||||||
if (receivedResponses.size() > 0)
|
|
||||||
return;
|
|
||||||
wait(12000);
|
wait(12000);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{}
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -86,8 +86,6 @@ public class TransactionSupportTests extends TestCase
|
|||||||
"");
|
"");
|
||||||
System.setProperty("org.ice4j.ORIGINAL_WAIT_INTERVAL",
|
System.setProperty("org.ice4j.ORIGINAL_WAIT_INTERVAL",
|
||||||
"");
|
"");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void tearDown() throws Exception
|
protected void tearDown() throws Exception
|
||||||
@ -164,8 +162,6 @@ public class TransactionSupportTests extends TestCase
|
|||||||
oldRetransValue);
|
oldRetransValue);
|
||||||
else
|
else
|
||||||
System.clearProperty("org.ice4j.MAX_WAIT_INTERVAL");
|
System.clearProperty("org.ice4j.MAX_WAIT_INTERVAL");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -464,9 +460,10 @@ public class TransactionSupportTests extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlainResponseCollector implements ResponseCollector{
|
private class PlainResponseCollector
|
||||||
|
implements ResponseCollector
|
||||||
public Vector<Object> receivedResponses = new Vector<Object>();
|
{
|
||||||
|
public final Vector<Object> receivedResponses = new Vector<Object>();
|
||||||
|
|
||||||
public void processResponse(StunMessageEvent responseEvt)
|
public void processResponse(StunMessageEvent responseEvt)
|
||||||
{
|
{
|
||||||
@ -475,10 +472,24 @@ public class TransactionSupportTests extends TestCase
|
|||||||
|
|
||||||
public void processTimeout()
|
public void processTimeout()
|
||||||
{
|
{
|
||||||
receivedResponses.add(new String("timeout"));
|
receivedResponses.add("timeout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notifies this collector that the destination of the request has been
|
||||||
|
* determined to be unreachable and that the request should be
|
||||||
|
* considered unanswered.
|
||||||
|
*
|
||||||
|
* @param exception the <tt>PortUnreachableException</tt> which signaled
|
||||||
|
* that the destination of the request was found to be unreachable
|
||||||
|
* @see ResponseCollector#processUnreachable(PortUnreachableException)
|
||||||
|
*/
|
||||||
|
public void processUnreachable(PortUnreachableException exception)
|
||||||
|
{
|
||||||
|
receivedResponses.add("unreachable");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public TransactionSupportTests(String name)
|
public TransactionSupportTests(String name)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -283,40 +283,46 @@ public class ShallowStackTest extends TestCase {
|
|||||||
implements ResponseCollector
|
implements ResponseCollector
|
||||||
{
|
{
|
||||||
Response collectedResponse = null;
|
Response collectedResponse = null;
|
||||||
public void processResponse(StunMessageEvent evt)
|
|
||||||
|
public synchronized void processResponse(StunMessageEvent evt)
|
||||||
{
|
{
|
||||||
synchronized(this)
|
collectedResponse = (Response)evt.getMessage();
|
||||||
{
|
logger.finest("Received response.");
|
||||||
collectedResponse = (Response)evt.getMessage();
|
notifyAll();
|
||||||
logger.finest("Received response.");
|
|
||||||
notifyAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processTimeout()
|
public synchronized void processTimeout()
|
||||||
{
|
{
|
||||||
logger.info("Timeout");
|
logger.info("Timeout");
|
||||||
|
notifyAll();
|
||||||
synchronized(this)
|
|
||||||
{
|
|
||||||
notifyAll();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void waitForResponse()
|
/**
|
||||||
|
* Notifies this collector that the destination of the request has been
|
||||||
|
* determined to be unreachable and that the request should be
|
||||||
|
* considered unanswered.
|
||||||
|
*
|
||||||
|
* @param exception the <tt>PortUnreachableException</tt> which signaled
|
||||||
|
* that the destination of the request was found to be unreachable
|
||||||
|
* @see ResponseCollector#processUnreachable(PortUnreachableException)
|
||||||
|
*/
|
||||||
|
public synchronized void processUnreachable(
|
||||||
|
PortUnreachableException exception)
|
||||||
{
|
{
|
||||||
synchronized(this)
|
logger.info("Unreachable");
|
||||||
|
notifyAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void waitForResponse()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
try
|
if (collectedResponse == null)
|
||||||
{
|
|
||||||
if (collectedResponse != null)
|
|
||||||
return;
|
|
||||||
wait(50);
|
wait(50);
|
||||||
}
|
}
|
||||||
catch (InterruptedException e)
|
catch (InterruptedException e)
|
||||||
{
|
{
|
||||||
logger.log(Level.INFO, "oops", e);
|
logger.log(Level.INFO, "oops", e);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user