continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r349960 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-core/src/main/java/org/apache/maven/continuum/utils/ continuum-store/src/m...
Date Wed, 30 Nov 2005 14:48:15 GMT
Author: evenisse
Date: Wed Nov 30 06:48:04 2005
New Revision: 349960

URL: http://svn.apache.org/viewcvs?rev=349960&view=rev
Log:
PR: CONTINUUM-477

End of performance improvement of enqueuing projects

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
    maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=349960&r1=349959&r2=349960&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
Wed Nov 30 06:48:04 2005
@@ -100,6 +100,9 @@
     Project getProject( int projectId )
         throws ContinuumStoreException, ContinuumObjectNotFoundException;
 
+    Map getProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
+        throws ContinuumStoreException;
+
     void updateProject( Project project )
         throws ContinuumStoreException;
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=349960&r1=349959&r2=349960&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Wed Nov 30 06:48:04 2005
@@ -341,11 +341,18 @@
         throws ContinuumException
     {
         Collection projectsList = null;
+        Map projectsMap = null;
 
         try
         {
+            projectsMap = store.getProjectIdsAndBuildDefinitionIdsBySchedule( schedule.getId()
);
+
             projectsList = getProjectsInBuildOrder();
         }
+        catch ( ContinuumStoreException e )
+        {
+            throw new ContinuumException( "Can't get project list for schedule " + schedule.getName(),
e );
+        }
         catch ( CycleDetectedException e )
         {
             getLogger().warn( "Cycle detected while sorting projects for building, falling
back to unsorted build." );
@@ -357,20 +364,12 @@
         {
             Project p = (Project) projectIterator.next();
 
+            int buildDefId = ( (Integer) projectsMap.get( new Integer( p.getId() ) ) ).intValue();
+
             if ( !isInBuildingQueue( p.getId() ) && !isInCheckoutQueue( p.getId()
) )
             {
-                Project project = getProjectWithAllDetails( p.getId() );
-
-                for ( Iterator bdIterator = project.getBuildDefinitions().iterator(); bdIterator.hasNext();
)
-                {
-                    BuildDefinition buildDef = (BuildDefinition) bdIterator.next();
-
-                    if ( schedule.getId() == buildDef.getSchedule().getId() )
-                    {
-                        //TODO: Fix trigger name
-                        buildProject( project.getId(), buildDef.getId(), ContinuumProjectState.TRIGGER_UNKNOWN,
false );
-                    }
-                }
+                //TODO: Fix trigger name
+                buildProject( p.getId(), buildDefId, ContinuumProjectState.TRIGGER_UNKNOWN,
false );
             }
         }
     }
@@ -548,7 +547,18 @@
     public List getProjectsInBuildOrder()
         throws CycleDetectedException, ContinuumException
     {
-        return ProjectSorter.getSortedProjects( getProjects() );
+        return getProjectsInBuildOrder( getProjects() );
+    }
+
+    private List getProjectsInBuildOrder( Collection projects )
+        throws CycleDetectedException, ContinuumException
+    {
+        if ( projects == null || projects.isEmpty() )
+        {
+            return new ArrayList();
+        }
+
+        return ProjectSorter.getSortedProjects( projects );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java?rev=349960&r1=349959&r2=349960&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/utils/ProjectSorter.java
Wed Nov 30 06:48:04 2005
@@ -139,7 +139,7 @@
         {
             artifactId = project.getArtifactId();
         }
-        
+
         String id = groupId + ":" + artifactId + ":" + project.getVersion();
 
         return id;

Modified: maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=349960&r1=349959&r2=349960&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
(original)
+++ maven/continuum/trunk/continuum-store/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
Wed Nov 30 06:48:04 2005
@@ -141,6 +141,57 @@
         }
     }
 
+    public Map getProjectIdsAndBuildDefinitionIdsBySchedule( int scheduleId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( Project.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareParameters( "int scheduleId" );
+
+            query.declareImports( "import org.apache.maven.continuum.model.project.BuildDefinition"
);
+
+            query.declareVariables ("BuildDefinition buildDef");
+
+            query.setFilter( "buildDefinitions.contains(buildDef) && buildDef.schedule.id
== scheduleId" );
+
+            query.setResult( "this.id, buildDef.id" );
+
+            List result = (List) query.execute( new Integer( scheduleId ) );
+
+            Map projects = new HashMap();
+
+            if ( result != null && !result.isEmpty() )
+            {
+                getLogger().info( "nb result : " + result.size() );
+                for ( Iterator i = result.iterator(); i.hasNext(); )
+                {
+                    Object[] obj = (Object[]) i.next();
+
+                    projects.put( (Integer) obj[0], (Integer) obj[1] );
+                }
+
+                return projects;
+            }
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+
+        return null;
+    }
 
     public void updateBuildResult( BuildResult build )
         throws ContinuumStoreException



Mime
View raw message