ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seanfi...@apache.org
Subject svn commit: r1645744 - in /ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util: JdbcConnectionFactory.java UmlsUserApprover.java
Date Mon, 15 Dec 2014 20:42:41 GMT
Author: seanfinan
Date: Mon Dec 15 20:42:40 2014
New Revision: 1645744

URL: http://svn.apache.org/r1645744
Log:
Changed standard out dynamic progress dots to log4j

Modified:
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
    ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java?rev=1645744&r1=1645743&r2=1645744&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/JdbcConnectionFactory.java
Mon Dec 15 20:42:40 2014
@@ -21,6 +21,8 @@ public enum JdbcConnectionFactory {
    INSTANCE;
 
    static final private Logger LOGGER = Logger.getLogger( "JdbcConnectionFactory" );
+   static final private Logger DOT_LOGGER = Logger.getLogger( "ProgressAppender" );
+   static final private Logger EOL_LOGGER = Logger.getLogger( "ProgressDone" );
 
    static private final String HSQL_FILE_PREFIX = "jdbc:hsqldb:file:";
    static private final String HSQL_DB_EXT = ".script";
@@ -84,9 +86,9 @@ public enum JdbcConnectionFactory {
          LOGGER.error( "Could not create Driver " + jdbcDriver, multE );
          throw new SQLException( multE );
       }
-      LOGGER.info( "Connecting to database ...");
+      LOGGER.info( "Connecting to " + jdbcUrl + ":" );
       final Timer timer = new Timer();
-      timer.scheduleAtFixedRate( new DotPlotter(), 1000, 1000 );
+      timer.scheduleAtFixedRate( new DotPlotter(), 333, 333 );
       try {
          // DO NOT use try with resources here.
          // Try with resources uses a closable and closes it when exiting the try block
@@ -94,23 +96,26 @@ public enum JdbcConnectionFactory {
          connection = DriverManager.getConnection( trueJdbcUrl, jdbcUser, jdbcPass );
       } catch ( SQLException sqlE ) {
          timer.cancel();
+         EOL_LOGGER.error( "" );
          LOGGER.error( "  Could not create Connection with " + trueJdbcUrl + " as " + jdbcUser,
sqlE );
          throw sqlE;
       }
       timer.cancel();
-      LOGGER.info( "  Database connected");
+      EOL_LOGGER.info( "" );
+      LOGGER.info( " Database connected" );
       CONNECTIONS.put( jdbcUrl, connection );
       return connection;
    }
 
    static private class DotPlotter extends TimerTask {
       private int _count = 0;
+
+      @Override
       public void run() {
-         System.out.print( "." );
+         DOT_LOGGER.info( "." );
          _count++;
-         if ( _count >= 50 ) {
-            _count = 0;
-            System.out.println();
+         if ( _count % 50 == 0 ) {
+            EOL_LOGGER.info( " " + _count );
          }
       }
    }

Modified: ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java
URL: http://svn.apache.org/viewvc/ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java?rev=1645744&r1=1645743&r2=1645744&view=diff
==============================================================================
--- ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java
(original)
+++ ctakes/trunk/ctakes-dictionary-lookup-fast/src/main/java/org/apache/ctakes/dictionary/lookup2/util/UmlsUserApprover.java
Mon Dec 15 20:42:40 2014
@@ -57,8 +57,9 @@ public enum UmlsUserApprover {
    private final static String USER_PARAM = "umlsUser";
    private final static String PASS_PARAM = "umlsPass";
 
-
    static final private Logger LOGGER = Logger.getLogger( "UmlsUserApprover" );
+   static final private Logger DOT_LOGGER = Logger.getLogger( "ProgressAppender" );
+   static final private Logger EOL_LOGGER = Logger.getLogger( "ProgressDone" );
 
    // cache of valid users
    static private final Collection<String> _validUsers = new ArrayList<>();
@@ -119,8 +120,8 @@ public enum UmlsUserApprover {
       }
       final Timer timer = new Timer();
       try {
-         LOGGER.info( "Checking UMLS Account at " + umlsUrl + " for user " + user );
-         timer.scheduleAtFixedRate( new DotPlotter(), 1000, 1000 );
+         LOGGER.info( "Checking UMLS Account at " + umlsUrl + " for user " + user + ":" );
+         timer.scheduleAtFixedRate( new DotPlotter(), 333, 333 );
          final URL url = new URL( umlsUrl );
          final URLConnection connection = url.openConnection();
          connection.setDoOutput( true );
@@ -140,6 +141,7 @@ public enum UmlsUserApprover {
          writer.close();
          reader.close();
          timer.cancel();
+         EOL_LOGGER.error( "" );
          if ( isValidUser ) {
             LOGGER.info( "  UMLS Account at " + umlsUrl + " for user " + user + " has been
validated" );
             _validUsers.add( cacheCode );
@@ -149,6 +151,7 @@ public enum UmlsUserApprover {
          return isValidUser;
       } catch ( IOException ioE ) {
          timer.cancel();
+         EOL_LOGGER.error( "" );
          LOGGER.error( ioE.getMessage() );
          return false;
       }
@@ -156,12 +159,13 @@ public enum UmlsUserApprover {
 
    static private class DotPlotter extends TimerTask {
       private int _count = 0;
+
+      @Override
       public void run() {
-         System.out.print( "." );
+         DOT_LOGGER.info( "." );
          _count++;
-         if ( _count >= 50 ) {
-            _count = 0;
-            System.out.println();
+         if ( _count % 50 == 0 ) {
+            EOL_LOGGER.info( " " + _count );
          }
       }
    }



Mime
View raw message