openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r526192 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/ openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/ openjpa-jdbc/src/main/...
Date Fri, 06 Apr 2007 15:08:40 GMT
Author: awhite
Date: Fri Apr  6 08:08:39 2007
New Revision: 526192

URL: http://svn.apache.org/viewvc?view=rev&rev=526192
Log:
Move LockManager API back to using int timeouts, since that's the way they're
handled elsewhere (FetchConfiguration, Broker, etc). Only use the lock timeout
on a forUpdate query if it is greater than the configured query timeout. 
Selects that are made *only* to lock a row (rather than to query data, with 
locking as a side effect) still use the lock timeout exclusively, ignoring the 
query timeout.


Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
    incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
    incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java?view=diff&rev=526192&r1=526191&r2=526192
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/kernel/PessimisticLockManager.java
Fri Apr  6 08:08:39 2007
@@ -86,7 +86,7 @@
             setLockLevel(sm, LOCK_DATASTORE_ONLY);
     }
 
-    protected void lockInternal(OpenJPAStateManager sm, int level, long timeout,
+    protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
         Object sdata) {
         // we can skip any already-locked instance regardless of level because
         // we treat all locks the same (though super doesn't)
@@ -103,7 +103,7 @@
      * Lock the specified instance row by issuing a "SELECT ... FOR UPDATE"
      * statement.
      */
-    private void lockRow(OpenJPAStateManager sm, long timeout) {
+    private void lockRow(OpenJPAStateManager sm, int timeout) {
         // assert that the dictionary supports the "SELECT ... FOR UPDATE"
         // construct; if not, and we the assertion does not throw an
         // exception, then just return without locking
@@ -136,7 +136,7 @@
                     if (log.isWarnEnabled())
                         log.warn(_loc.get("millis-query-timeout"));
                 }
-                stmnt.setQueryTimeout((int) (timeout / 1000));
+                stmnt.setQueryTimeout(timeout / 1000);
             }
             rs = stmnt.executeQuery();
             if (!rs.next())
@@ -145,19 +145,10 @@
             throw SQLExceptions.getStore(se, dict);
         } finally {
             if (stmnt != null)
-                try {
-                    stmnt.close();
-                } catch (SQLException se) {
-                }
+                try { stmnt.close(); } catch (SQLException se) {}
             if (rs != null)
-                try {
-                    rs.close();
-                } catch (SQLException se) {
-                }
-            try {
-                conn.close();
-            } catch (SQLException se) {
-            }
+                try { rs.close(); } catch (SQLException se) {}
+            try { conn.close(); } catch (SQLException se) {}
         }
     }
 

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java?view=diff&rev=526192&r1=526191&r2=526192
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/sql/SelectImpl.java
Fri Apr  6 08:08:39 2007
@@ -340,8 +340,19 @@
             else
                 stmnt = sql.prepareStatement(conn, rsType, -1);
 
-            if (forUpdate)
+            // if this is a locking select and the lock timeout is greater than
+            // the configured query timeout, use the lock timeout
+            if (forUpdate && _dict.supportsQueryTimeout && fetch != null

+                && fetch.getLockTimeout() > stmnt.getQueryTimeout() * 1000) {
+                int timeout = fetch.getLockTimeout();
+                if (timeout < 1000) {
+                    timeout = 1000; 
+                    Log log = _conf.getLog(JDBCConfiguration.LOG_JDBC);
+                    if (log.isWarnEnabled())
+                        log.warn(_loc.get("millis-query-timeout"));
+                }
                 stmnt.setQueryTimeout(fetch.getLockTimeout() / 1000);
+            }
             rs = stmnt.executeQuery();
         } catch (SQLException se) {
             // clean up statement

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties?view=diff&rev=526192&r1=526191&r2=526192
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/kernel/localizer.properties
Fri Apr  6 08:08:39 2007
@@ -48,11 +48,8 @@
 start-trans-for-lock: Though you are using optimistic transactions, OpenJPA is \
 	now beginning a datastore transaction because you have requested a lock \
 	on some data.
-millis-timeout: JDBC lock manager does not support millisecond-granularity \
-	timeouts.  Use timeouts that are multiples of 1000 for even second values.
-millis-query-timeout: JDBC lock manager does not support \
-	millisecond-granularity timeouts.  Use timeouts that are multiples \
-	of 1000 for even second values.
+millis-query-timeout: JDBC locking does not support millisecond-granularity \
+    timeouts.  Use timeouts that are multiples of 1000 for even second values.
 batch-not-supported: The update count for the statement was an invalid \
 	value ({0}). This indicates that your database or JDBC driver does not \
 	have complete support for executing batch statements. Batch \
@@ -101,4 +98,4 @@
     Connection.TRANSACTION_NONE, Connection.TRANSACTION_READ_UNCOMMITTED, \ 
     Connection.TRANSACTION_READ_COMMITTED, \
     Connection.TRANSACTION_REPEATABLE_READ, or \
-    Connection.TRANSACTION_SERIALIZABLE. Specified value: {0}.
\ No newline at end of file
+    Connection.TRANSACTION_SERIALIZABLE. Specified value: {0}.

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties?view=diff&rev=526192&r1=526191&r2=526192
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/resources/org/apache/openjpa/jdbc/sql/localizer.properties
Fri Apr  6 08:08:39 2007
@@ -161,4 +161,6 @@
     worked around by setting the "SupportsTimestampNanos" DBDictionary \
     property to "true".
 isolation-level-config-not-supported: This DBDictionary does not support \
-    customization of isolation levels on a per-query basis. DBDictionary: {0}.
\ No newline at end of file
+    customization of isolation levels on a per-query basis. DBDictionary: {0}.
+millis-query-timeout: JDBC locking does not support millisecond-granularity \
+    timeouts.  Use timeouts that are multiples of 1000 for even second values.

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java?view=diff&rev=526192&r1=526191&r2=526192
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/VersionLockManager.java
Fri Apr  6 08:08:39 2007
@@ -90,7 +90,7 @@
      *
      * @see StoreContext#transactional
      */
-    protected void lockInternal(OpenJPAStateManager sm, int level, long timeout,
+    protected void lockInternal(OpenJPAStateManager sm, int level, int timeout,
         Object sdata) {
         // Set lock level first to prevent infinite recursion with
         // transactional(..) call



Mime
View raw message