db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olegn...@apache.org
Subject cvs commit: jakarta-ojb/src/test/org/apache/ojb OJB.properties
Date Mon, 09 Dec 2002 22:00:11 GMT
olegnitz    2002/12/09 14:00:11

  Modified:    src/java/org/apache/ojb/broker/accesslayer
                        ConnectionManager.java ConnectionManagerIF.java
               src/java/org/apache/ojb/broker/util/batch
                        BatchConnection.java
               src/java/org/apache/ojb/broker/util/configuration/impl
                        OjbConfiguration.java
               src/java/org/apache/ojb/odmg ObjectEnvelopeTable.java
                        OdmgConfiguration.java TransactionImpl.java
               src/test/org/apache/ojb OJB.properties
  Log:
  BatchMode parameter for ODMG in OJB.properties has been removed (just no reason to have
it).
  Thus the batch support code in ODMG is simplified and made a bit more reliable.
  
  Revision  Changes    Path
  1.16      +10 -1     jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManager.java
  
  Index: ConnectionManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManager.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ConnectionManager.java	2 Dec 2002 17:09:16 -0000	1.15
  +++ ConnectionManager.java	9 Dec 2002 22:00:08 -0000	1.16
  @@ -309,4 +309,13 @@
           }
       }
   
  +    /**
  +     * Clear batch (if the batch mode where used).
  +     */
  +    public void clearBatch() {
  +        if (batchCon != null)
  +        {
  +            batchCon.clearBatch();
  +        }
  +    }
   }
  
  
  
  1.7       +5 -0      jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java
  
  Index: ConnectionManagerIF.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/accesslayer/ConnectionManagerIF.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ConnectionManagerIF.java	2 Dec 2002 17:09:16 -0000	1.6
  +++ ConnectionManagerIF.java	9 Dec 2002 22:00:08 -0000	1.7
  @@ -110,4 +110,9 @@
        * Execute batch (if the batch mode where used).
        */
       public void executeBatch();
  +    
  +    /**
  +     * Clear batch (if the batch mode where used).
  +     */
  +    public void clearBatch();
   }
  
  
  
  1.5       +8 -1      jakarta-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java
  
  Index: BatchConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/util/batch/BatchConnection.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BatchConnection.java	9 Dec 2002 08:12:48 -0000	1.4
  +++ BatchConnection.java	9 Dec 2002 22:00:08 -0000	1.5
  @@ -169,6 +169,7 @@
       public void executeBatch() throws SQLException
       {
           BatchPreparedStatement batchStmt;
  +
           try
           {
               for (Iterator it = _order.iterator(); it.hasNext(); )
  @@ -182,6 +183,12 @@
               _order.clear();
               _statements.clear();
           }
  +    }
  +
  +    public void clearBatch()
  +    {
  +        _order.clear();
  +        _statements.clear();
       }
   
       public void commit() throws SQLException
  
  
  
  1.16      +1 -12     jakarta-ojb/src/java/org/apache/ojb/broker/util/configuration/impl/OjbConfiguration.java
  
  Index: OjbConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/broker/util/configuration/impl/OjbConfiguration.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- OjbConfiguration.java	2 Dec 2002 17:09:17 -0000	1.15
  +++ OjbConfiguration.java	9 Dec 2002 22:00:09 -0000	1.16
  @@ -134,7 +134,6 @@
   
       // ODMG configuration
       private boolean useImplicitLocking;
  -    private boolean useBatchMode;
       private boolean lockAssociationAsWrites;
       private Class oqlCollectionClass;
       private Class lockManagerClass;
  @@ -361,9 +360,6 @@
           // load configuration for ImplicitLocking parameter:
           useImplicitLocking = getBoolean("ImplicitLocking", false);
   
  -        // load configuration for BatchMode parameter:
  -        useBatchMode = getBoolean("BatchMode", true);
  -
           // load configuration for LockAssociations parameter:
           lockAssociationAsWrites =
                   (getString("LockAssociations", "WRITE").equalsIgnoreCase("WRITE") ? true
: false);
  @@ -423,11 +419,4 @@
           return useImplicitLocking;
       }
   
  -    /**
  -     * @see org.apache.ojb.odmg.OdmgConfiguration#useBatchMode()
  -     */
  -    public boolean useBatchMode()
  -    {
  -        return useBatchMode;
  -    }
   }
  
  
  
  1.9       +13 -0     jakarta-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java
  
  Index: ObjectEnvelopeTable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/ObjectEnvelopeTable.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- ObjectEnvelopeTable.java	24 Nov 2002 23:24:39 -0000	1.8
  +++ ObjectEnvelopeTable.java	9 Dec 2002 22:00:09 -0000	1.9
  @@ -57,6 +57,7 @@
   import org.apache.ojb.broker.Identity;
   import org.apache.ojb.broker.ManageableCollection;
   import org.apache.ojb.broker.PersistenceBroker;
  +import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
   import org.apache.ojb.broker.metadata.CollectionDescriptor;
   import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
  @@ -136,6 +137,9 @@
       public void commit() throws TransactionAbortedException
       {
           PersistenceBroker broker = transaction.getBroker();
  +        ConnectionManagerIF connMan = broker.getConnectionManager();
  +        boolean saveBatchMode = connMan.isBatchMode();
  +
           try
           {
               if(log.isDebugEnabled())
  @@ -155,6 +159,9 @@
               // reordered to solve referential integrity dependencies, then the objects
are
               // written into the database.
   
  +            // 0. turn on the batch mode
  +            connMan.setBatchMode(true);
  +
               // 1. upgrade locks
               Iterator iter = mvOrderOfIds.iterator();
               while (iter.hasNext())
  @@ -184,13 +191,19 @@
                   // in a distributed environment all broker caches must invalidate the Object
                   broker.invalidate(new Identity(mod.getObject(), transaction.getBroker()));
               }
  +
  +            // 4. execute batch
  +            connMan.executeBatch();
           }
           catch (Throwable t)
           {
   // we do that in TransactionImpl#abort()
   //            broker.abortTransaction();
  +            connMan.clearBatch();
               log.error("Commit on object level failed for tx " + transaction, t);
               throw new TransactionAbortedException(t.getMessage());
  +        } finally {
  +            connMan.setBatchMode(saveBatchMode);
           }
       }
   
  
  
  
  1.6       +1 -6      jakarta-ojb/src/java/org/apache/ojb/odmg/OdmgConfiguration.java
  
  Index: OdmgConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/OdmgConfiguration.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- OdmgConfiguration.java	2 Dec 2002 17:09:17 -0000	1.5
  +++ OdmgConfiguration.java	9 Dec 2002 22:00:10 -0000	1.6
  @@ -88,9 +88,4 @@
        */
       public boolean useImplicitLocking();
   
  -    /**
  -     * defines if batch updates should be used.
  -     */
  -    public boolean useBatchMode();
  -
   }
  
  
  
  1.29      +1 -25     jakarta-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java
  
  Index: TransactionImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/java/org/apache/ojb/odmg/TransactionImpl.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- TransactionImpl.java	2 Dec 2002 17:09:17 -0000	1.28
  +++ TransactionImpl.java	9 Dec 2002 22:00:10 -0000	1.29
  @@ -62,7 +62,6 @@
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.VirtualProxy;
  -import org.apache.ojb.broker.accesslayer.ConnectionManagerIF;
   import org.apache.ojb.broker.accesslayer.IndirectionHandler;
   import org.apache.ojb.broker.accesslayer.MaterializationListener;
   import org.apache.ojb.broker.metadata.ClassDescriptor;
  @@ -118,7 +117,6 @@
       private Hashtable myNrm = null;
       private boolean useWriteLocks;
       private boolean useImplicitLocking;
  -    private boolean useBatchMode;
       private String txGUID;
       protected PersistenceBroker broker = null;
       private HashMap registeredForLock = new HashMap();
  @@ -314,7 +312,6 @@
       private synchronized void doCommitOnObjects() throws org.odmg.TransactionAbortedException
       {
           ObjectEnvelope item;
  -        ConnectionManagerIF connMan = null;
   
           // Notify objects of impending commits.
           Enumeration enum = objectEnvelopeTable.elements();
  @@ -324,29 +321,9 @@
               item.beforeCommit();
           }
           
  -        // Do we need to turn on the batch mode?
  -        if (useBatchMode)
  -        {
  -            connMan = getBroker().getConnectionManager();
  -            connMan.setBatchMode(true);
  -        }
  -
           // Now perfom the real work
           objectEnvelopeTable.commit();
   
  -        // if if use batch mode, it's time to execute the batch
  -        if (useBatchMode)
  -        {
  -            try
  -            {
  -                connMan.executeBatch();
  -            }
  -            catch (Exception ex)
  -            {
  -                throw new TransactionAbortedException(ex.toString());
  -            }
  -        }
  -
           // Now, we notify everything the commit is done.
           enum = objectEnvelopeTable.elements();
           while (enum.hasMoreElements())
  @@ -1142,7 +1119,6 @@
   
           useWriteLocks = odmgConfig.lockAssociationAsWrites();
           useImplicitLocking = odmgConfig.useImplicitLocking();
  -        useBatchMode = odmgConfig.useBatchMode();
       }
   
   // arminw: commented out unused methods
  
  
  
  1.34      +0 -4      jakarta-ojb/src/test/org/apache/ojb/OJB.properties
  
  Index: OJB.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-ojb/src/test/org/apache/ojb/OJB.properties,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- OJB.properties	2 Dec 2002 17:21:19 -0000	1.33
  +++ OJB.properties	9 Dec 2002 22:00:10 -0000	1.34
  @@ -264,10 +264,6 @@
   #LockAssociations=READ
   LockAssociations=WRITE
   #
  -# The BatchMode entry defines if batch updates will be used to improve
  -# performance.
  -BatchMode=true
  -#
   #
   #----------------------------------------------------------------------------------------
   # Logging
  
  
  

Mime
View raw message