ozeigermann    2003/11/26 03:13:59

  Modified:    src/stores/org/apache/slide/store/txfile/rm/impl
                        FileResourceManager.java
               src/stores/org/apache/slide/store/txfile
                        AbstractTxFileStoreService.java
  Log:
  Made default transaction timeout configurable in Domain.xml.
  Paramter name is timeout, value is in seconds.
  
  
  Revision  Changes    Path
  1.5       +21 -8     
jakarta-slide/src/stores/org/apache/slide/store/txfile/rm/impl/FileResourceManager.java
  
  Index: FileResourceManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txfile/rm/impl/FileResourceManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FileResourceManager.java  14 Nov 2003 16:25:06 -0000      1.4
  +++ FileResourceManager.java  26 Nov 2003 11:13:59 -0000      1.5
  @@ -250,6 +250,7 @@
       protected boolean cleanUp = true;
       protected boolean dirty = false;
       protected int operationMode = OPERATION_MODE_STOPPED;
  +    protected long defaultTimeout = DEFAULT_TIMEOUT_MSECS; 
   
       protected StoreLogger logger;
   
  @@ -357,8 +358,20 @@
           return (level == ISOLATION_LEVEL_READ_COMMITTED || level == 
ISOLATION_LEVEL_REPEATABLE_READ);
       }
   
  +    /**
  +     * Gets the default transaction timeout in <em>milliseconds</em>.
  +     */
       public long getDefaultTransactionTimeout() {
  -        return DEFAULT_TIMEOUT_MSECS;
  +        return defaultTimeout;
  +    }
  +
  +    /**
  +     * Sets the default transaction timeout.
  +     * 
  +     * @param timeout timeout in <em>milliseconds</em>
  +     */
  +    public void setDefaultTransactionTimeout(long timeout) {
  +        defaultTimeout = timeout;
       }
   
       public long getTransactionTimeout(Object txId) throws ResourceManagerException {
  @@ -366,7 +379,7 @@
           long msecs = 0;
           TransactionContext context = getContext(txId);
           if (context == null) {
  -            msecs = DEFAULT_TIMEOUT_MSECS;
  +            msecs = getDefaultTransactionTimeout();
           } else {
               msecs = ((TransactionContext) context).timeoutMSecs;
           }
  @@ -431,7 +444,7 @@
       }
   
       public synchronized boolean stop(int mode) throws 
ResourceManagerSystemException {
  -        return stop(mode, DEFAULT_TIMEOUT_MSECS * DEFAULT_COMMIT_TIMEOUT_FACTOR);
  +        return stop(mode, getDefaultTransactionTimeout() * 
DEFAULT_COMMIT_TIMEOUT_FACTOR);
       }
   
       public synchronized boolean stop(int mode, long timeOut) throws 
ResourceManagerSystemException {
  @@ -1333,7 +1346,7 @@
           protected Object txId;
           protected int status = STATUS_ACTIVE;
           protected int isolationLevel = DEFAULT_ISOLATION_LEVEL;
  -        protected long timeoutMSecs = DEFAULT_TIMEOUT_MSECS;
  +        protected long timeoutMSecs = getDefaultTransactionTimeout();
           protected long startTime;
           protected long commitTime = -1L;
           protected Thread txThread;
  @@ -1430,7 +1443,7 @@
                               LOCK_COMMIT,
                               true,
                               true,
  -                            DEFAULT_TIMEOUT_MSECS * DEFAULT_COMMIT_TIMEOUT_FACTOR)) 
{
  +                    getDefaultTransactionTimeout() * 
DEFAULT_COMMIT_TIMEOUT_FACTOR)) {
                           throw new ResourceManagerException(
                               "Could not upgrade to commit lock for resource at '"
                                   + lock.getResourceId().toString()
  
  
  
  1.6       +19 -3     
jakarta-slide/src/stores/org/apache/slide/store/txfile/AbstractTxFileStoreService.java
  
  Index: AbstractTxFileStoreService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/stores/org/apache/slide/store/txfile/AbstractTxFileStoreService.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractTxFileStoreService.java   21 Nov 2003 11:50:13 -0000      1.5
  +++ AbstractTxFileStoreService.java   26 Nov 2003 11:13:59 -0000      1.6
  @@ -98,6 +98,7 @@
   
       protected static final String STORE_DIR_PARAMETER = "rootpath";
       protected static final String WORK_DIR_PARAMETER = "workpath";
  +    protected static final String TIMEOUT_PARAMETER = "timeout";
   
       protected FileResourceManager rm;
       protected boolean started = false;
  @@ -133,6 +134,21 @@
               "File Store configured to " + storeDir + ", working directory " + 
workDir,
               LOG_CHANNEL,
               Logger.INFO);
  +
  +        String timeoutString = (String) parameters.get(TIMEOUT_PARAMETER);
  +        if (timeoutString != null) {
  +            try {
  +                int timeout = Integer.parseInt(timeoutString);
  +                rm.setDefaultTransactionTimeout(timeout * 1000);
  +                getLogger().log("Set timeout to " + timeoutString, LOG_CHANNEL, 
Logger.INFO);
  +            } catch (NumberFormatException nfe) {
  +                getLogger().log(
  +                    "Can not set timeout, '" + timeoutString + "' must be an 
integer!",
  +                    LOG_CHANNEL,
  +                    Logger.WARNING);
  +            }
  +        }
  +
       }
   
       public String toString() {
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to