continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r693263 - in /continuum/trunk: continuum-api/src/main/java/org/apache/continuum/dao/ continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-model/src/main/mdo/ continuum-store/src/main/java/org/apache/continuum/dao/
Date Mon, 08 Sep 2008 20:48:00 GMT
Author: olamy
Date: Mon Sep  8 13:47:59 2008
New Revision: 693263

URL: http://svn.apache.org/viewvc?rev=693263&view=rev
Log:
[CONTINUUM-1871] Continuum does not execute builds when last BUILDRESULT.END_TIME=0

use new dao method to prevent too huge loading if last build result end time == 0
use StringBuilder in a toString method to prevent too huge String creation for concatenation


Modified:
    continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
    continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    continuum/trunk/continuum-model/src/main/mdo/continuum.xml
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java

Modified: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java?rev=693263&r1=693262&r2=693263&view=diff
==============================================================================
--- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
(original)
+++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/dao/BuildResultDao.java
Mon Sep  8 13:47:59 2008
@@ -55,6 +55,15 @@
 
     List<BuildResult> getBuildResultsForProject( int projectId, long startIndex, long
endIndex );
 
+    /**
+     * @since 1.2
+     * @param projectId
+     * @param startIndex
+     * @return the returned list will contains all BuildResult for this project after the
startId
+     */
+    List<BuildResult> getBuildResultsForProjectFromId( int projectId, long startId
)
+        throws ContinuumStoreException;   
+    
     List<BuildResult> getBuildResultsForProject( int projectId, long fromDate );
 
     Map<Integer, BuildResult> getLatestBuildResultsByProjectGroupId( int projectGroupId
);

Modified: continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=693263&r1=693262&r2=693263&view=diff
==============================================================================
--- continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
(original)
+++ continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
Mon Sep  8 13:47:59 2008
@@ -350,13 +350,12 @@
 
             context.setOldBuildResult( oldBuildResult );
 
-            // FIXME CONTINUUM-1871 if continuum is killed the oldBuildResult will have a
endTime 0
-            // and all ScmResult will be in memory and the contains method use toString from
ChangeSet 
-            // which do a lot String concat
-            
+            // CONTINUUM-1871 olamy if continuum is killed during building oldBuildResult
will have a endTime 0
+            // this means all changes since the project has been loaded in continuum will
be in memory
+            // now we will load all BuildResult with an Id bigger or equals than the oldBuildResult
one
             if ( oldBuildResult != null )
             {
-                context.setOldScmResult( getOldScmResult( projectId, oldBuildResult.getEndTime()
) );
+                context.setOldScmResult( getOldScmResults( projectId, oldBuildResult.getBuildNumber(),
oldBuildResult.getEndTime() ) );
             }
         }
         catch ( ContinuumStoreException e )
@@ -774,9 +773,12 @@
         }
     }
 
-    private ScmResult getOldScmResult( int projectId, long fromDate )
+    private ScmResult getOldScmResults( int projectId, long startId, long fromDate )
+        throws ContinuumStoreException
     {
-        List<BuildResult> results = buildResultDao.getBuildResultsForProject( projectId,
fromDate );
+        // TODO CONTINUUM-1871 use a new method in dao : buildResultDao.getBuildResultsForProject(
projectId, buildResultId )
+        // which load all buildResult with Id >= buildResultId
+        List<BuildResult> results = buildResultDao.getBuildResultsForProjectFromId(
projectId, startId );
 
         ScmResult res = new ScmResult();
 
@@ -797,8 +799,7 @@
                             if ( changeSet.getDate() < fromDate )
                             {
                                 continue;
-                            }
-
+                            }                            
                             if ( !res.getChanges().contains( changeSet ) )
                             {
                                 res.addChange( changeSet );

Modified: continuum/trunk/continuum-model/src/main/mdo/continuum.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-model/src/main/mdo/continuum.xml?rev=693263&r1=693262&r2=693263&view=diff
==============================================================================
--- continuum/trunk/continuum-model/src/main/mdo/continuum.xml (original)
+++ continuum/trunk/continuum-model/src/main/mdo/continuum.xml Mon Sep  8 13:47:59 2008
@@ -764,24 +764,34 @@
             /**
              * @return Returns string representation of the changeset
              */
-            // FIXME CONTINUUM-1871 use at least a StringBuilder here
             public String toString()
             {
-                String result = author + "\n" + date + "\n";
+                StringBuilder result = new StringBuilder();
+                if ( author != null )
+                {
+                    result.append( author ).append( "\n" );
+                }
+                result.append( date ).append( "\n" );
 
                 if ( files != null )
                 {
                     for ( java.util.Iterator i = files.iterator(); i.hasNext(); )
                     {
                         ChangeFile file = (ChangeFile) i.next();
-
-                        result += file + "\n";
+                        
+                        if (file != null)
+                        {
+                            result.append( file ).append( "\n" );
+                        }
                     }
                 }
 
-                result += comment;
+                if ( comment != null )
+                {
+                    result.append( comment );
+                }
 
-                return result;
+                return result.toString();
             }
 
             /**

Modified: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java?rev=693263&r1=693262&r2=693263&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
(original)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/BuildResultDaoImpl.java
Mon Sep  8 13:47:59 2008
@@ -411,7 +411,7 @@
         PersistenceManager pm = getPersistenceManager();
 
         Transaction tx = pm.currentTransaction();
-
+        
         try
         {
             tx.begin();
@@ -444,6 +444,47 @@
             rollback( tx );
         }
     }
+    
+    public List<BuildResult> getBuildResultsForProjectFromId( int projectId, long startId
)
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        pm.getFetchPlan().addGroup( BUILD_RESULT_WITH_DETAILS_FETCH_GROUP );
+        
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildResult.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareParameters( "int projectId, int buildNumber" );
+           
+            query.setFilter( "this.project.id == projectId && this.buildNumber >=
buildNumber" );
+            
+            query.setOrdering( "this.startTime descending" );
+
+            List result = (List) query.execute( projectId, startId );
+
+            result = (List) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            return result;
+        }
+        catch ( Exception e )
+        {
+            throw new ContinuumStoreException( e.getMessage(), e );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
 
     public List<BuildResult> getBuildResultsForProject( int projectId, long fromDate
)
     {



Mime
View raw message