db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject cvs commit: db-ojb/src/test/org/apache/ojb/broker PerformanceJdbcFailoverTest.java
Date Thu, 15 May 2003 21:02:35 GMT
thma        2003/05/15 14:02:35

  Modified:    src/test/org/apache/ojb/broker
                        PerformanceJdbcFailoverTest.java
  Log:
  add some more convenience
  
  Revision  Changes    Path
  1.3       +62 -4     db-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcFailoverTest.java
  
  Index: PerformanceJdbcFailoverTest.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/test/org/apache/ojb/broker/PerformanceJdbcFailoverTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PerformanceJdbcFailoverTest.java	15 May 2003 07:50:33 -0000	1.2
  +++ PerformanceJdbcFailoverTest.java	15 May 2003 21:02:35 -0000	1.3
  @@ -44,7 +44,7 @@
       /**
        * the maximum time to wait on db availability.
        */
  -    static int maxWait = 30000;
  +    static int maxWait = 30;
   
   
       /**
  @@ -81,6 +81,15 @@
           {
               iterations = Integer.parseInt(args[1]);
           }
  +        if (args.length > 2)
  +        {
  +            maxRetries = Integer.parseInt(args[2]);
  +        }
  +        if (args.length > 3)
  +        {
  +            maxWait = Integer.parseInt(args[3]);
  +        }
  +
   
           String[] arr = {PerformanceJdbcFailoverTest.class.getName()};
           junit.textui.TestRunner.main(arr);
  @@ -140,7 +149,7 @@
       {
           Connection conn = null;
           long startToWait = System.currentTimeMillis();
  -        System.out.print("{..");
  +        System.out.print("[");
           System.out.flush();
           while (true)
           {
  @@ -155,18 +164,25 @@
                   ConnectionFactory cf =
                           ConnectionFactoryFactory.getInstance().createConnectionFactory();
                   conn = cf.lookupConnection(jcd);
  -                System.out.println(".} Waited for connection " + (System.currentTimeMillis()
- startToWait) + "msecs");
  +                System.out.println("] Waited for connection " + (System.currentTimeMillis()
- startToWait) + "msecs");
                   break;
               }
               catch (Throwable t)
               {
  -                if ((System.currentTimeMillis() - startToWait) > maxWait)
  +            	long now = System.currentTimeMillis(); 
  +                if ((now - startToWait) > (1000* maxWait))
                   {
                       System.out.print("Timeout exceeded in getConnection(), DB not available!");
                       throw new OJBException(t);
                   }
                   else
                   {
  +                	if ((now % 1000) == 0)
  +                	{
  +                		System.out.print("#");
  +                		System.out.flush();
  +                	}
  +        			
                   }
               }
           }
  @@ -206,6 +222,13 @@
               if (actualRetries <= maxRetries)
               {
                   logger.error("error during db operations:", t);
  +                try
  +                {
  +                    conn.close();
  +                }
  +                catch (Throwable ignored)
  +                {
  +                }
                   deleteArticles();
               }
               else
  @@ -273,6 +296,13 @@
               if (actualRetries <= maxRetries)
               {
                   logger.error("error during db operations:", t);
  +	            try
  +	            {
  +	                conn.close();
  +	            }
  +	            catch (Throwable ignored)
  +	            {
  +	            }                
                   insertNewArticles();
               }
               else
  @@ -314,6 +344,13 @@
               if (actualRetries <= maxRetries)
               {
                   logger.error("error during db operations:", t);
  +                try
  +                {
  +                    conn.close();
  +                }
  +                catch (Throwable ignored)
  +                {
  +                }
                   clearTable();
               }
               else
  @@ -388,6 +425,13 @@
               if (actualRetries <= maxRetries)
               {
                   logger.error("error during db operations:", t);
  +	            try
  +	            {
  +	                conn.close();
  +	            }
  +	            catch (Throwable ignored)
  +	            {
  +	            }
                   readArticles();
               }
               else
  @@ -477,6 +521,13 @@
               if (actualRetries <= maxRetries)
               {
                   logger.error("error during db operations:", t);
  +	            try
  +	            {
  +	                conn.close();
  +	            }
  +	            catch (Throwable ignored)
  +	            {
  +	            }                
                   readArticlesByCursor();
               }
               else
  @@ -549,6 +600,13 @@
               if (actualRetries <= maxRetries)
               {
                   logger.error("error during db operations:", t);
  +	            try
  +	            {
  +	                conn.close();
  +	            }
  +	            catch (Throwable ignored)
  +	            {
  +	            }                
                   updateExistingArticles();
               }
               else
  
  
  

Mime
View raw message