axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hawk...@apache.org
Subject cvs commit: ws-axis/c/tests/utils/monitor/org/apache/test TestClientListener.java
Date Wed, 16 Mar 2005 15:54:11 GMT
hawkeye     2005/03/16 07:54:11

  Modified:    c/tests/utils/monitor/org/apache/test
                        TestClientListener.java
  Log:
  Added a timeout so if monitor fails to connect to server then it sleeps five times then
  retries
  
  Revision  Changes    Path
  1.3       +29 -8     ws-axis/c/tests/utils/monitor/org/apache/test/TestClientListener.java
  
  Index: TestClientListener.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/tests/utils/monitor/org/apache/test/TestClientListener.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestClientListener.java	17 Feb 2005 19:36:23 -0000	1.2
  +++ TestClientListener.java	16 Mar 2005 15:54:11 -0000	1.3
  @@ -16,7 +16,7 @@
    */
   
   public class TestClientListener implements Runnable {
  -
  +    private int CREATE_SOCKET_TO_SERVER_RETRY=5;
   	int listenPort = 0;
   	int servicePort = 0;
   	String serviceHost = null;
  @@ -72,13 +72,34 @@
   				//server.setSoTimeout(500);
   				try {
   					clientSocket = server.accept();
  -					try {
  -						serviceSocket = new Socket(serviceHost, servicePort);
  -					} catch (Exception se) {
  -						System.err.println("Failed to open socket to service");
  -						stayAlive = false;
  -						continue;
  -					}
  +					
  +					// Now create the socket to the server
  +					int retry=CREATE_SOCKET_TO_SERVER_RETRY;
  +					do
  +                    {
  +					    try 
  +					    {
  +					        serviceSocket = new Socket(serviceHost, servicePort);
  +					    } 
  +					    catch (Exception se) 
  +					    {
  +					        System.err.println("Failed to open socket to service");
  +					        se.printStackTrace(System.err);
  +					        if(retry<=0)
  +					        {
  +					            stayAlive = false;
  +					            continue;
  +					        }
  +					        else
  +					        {
  +					            // go to sleep
  +					            System.err.println( "Going to sleep");
  +							    Thread.currentThread().sleep(2500);
  +							    System.err.println( "Woke up ");
  +					        }
  +					    }
  +                    }while(serviceSocket==null && retry-- >0);
  +					
   					requestReader = new TestClientThread(clientSocket, serviceSocket, CAPTURE_REQUEST);
   					responseReader = new TestClientThread(clientSocket, serviceSocket, CAPTURE_RESPONSE);
   					requestReader.start();
  
  
  

Mime
View raw message