continuum-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Venisse <eveni...@apache.org>
Subject Re: svn commit: r788574 - in /continuum/branches/continuum-1.3.x: continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
Date Fri, 26 Jun 2009 05:11:39 GMT
This patch should save lot of memory and cpu for Continuum instance with lot
of projects.
I hope it will be good for vmbuild and I'll continue to search similar
issues.

Emmanuel

On Fri, Jun 26, 2009 at 6:51 AM, <evenisse@apache.org> wrote:

> Author: evenisse
> Date: Fri Jun 26 04:51:32 2009
> New Revision: 788574
>
> URL: http://svn.apache.org/viewvc?rev=788574&view=rev
> Log:
> -Reimplement getProjectsWithDependenciesByGroupId by working only in the DB
> instead of to get all datas and filter them in java
> -Remove unused code
>
> Modified:
>
>  continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
>
>  continuum/branches/continuum-1.3.x/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
>
> Modified:
> continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
> URL:
> http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java?rev=788574&r1=788573&r2=788574&view=diff
>
> ==============================================================================
> ---
> continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
> (original)
> +++
> continuum/branches/continuum-1.3.x/continuum-api/src/main/java/org/apache/continuum/dao/ProjectDao.java
> Fri Jun 26 04:51:32 2009
> @@ -65,8 +65,6 @@
>     List<Project> getProjectsInGroupWithDependencies( int projectGroupId )
>         throws ContinuumStoreException;
>
> -    List<Project> getAllProjectsWithAllDetails();
> -
>     Project getProjectWithAllDetails( int projectId )
>         throws ContinuumStoreException;
>
>
> Modified:
> continuum/branches/continuum-1.3.x/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
> URL:
> http://svn.apache.org/viewvc/continuum/branches/continuum-1.3.x/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java?rev=788574&r1=788573&r2=788574&view=diff
>
> ==============================================================================
> ---
> continuum/branches/continuum-1.3.x/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
> (original)
> +++
> continuum/branches/continuum-1.3.x/continuum-store/src/main/java/org/apache/continuum/dao/ProjectDaoImpl.java
> Fri Jun 26 04:51:32 2009
> @@ -19,6 +19,16 @@
>  * under the License.
>  */
>
> +import java.util.Collection;
> +import java.util.HashMap;
> +import java.util.List;
> +import java.util.Map;
> +
> +import javax.jdo.Extent;
> +import javax.jdo.PersistenceManager;
> +import javax.jdo.Query;
> +import javax.jdo.Transaction;
> +
>  import org.apache.continuum.model.project.ProjectGroupSummary;
>  import org.apache.continuum.model.project.ProjectSummaryResult;
>  import org.apache.maven.continuum.model.project.Project;
> @@ -27,17 +37,6 @@
>  import org.apache.maven.continuum.store.ContinuumStoreException;
>  import org.springframework.stereotype.Repository;
>
> -import javax.jdo.Extent;
> -import javax.jdo.PersistenceManager;
> -import javax.jdo.Query;
> -import javax.jdo.Transaction;
> -import java.util.ArrayList;
> -import java.util.Collection;
> -import java.util.HashMap;
> -import java.util.Iterator;
> -import java.util.List;
> -import java.util.Map;
> -
>  /**
>  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
>  * @version $Id$
> @@ -154,22 +153,33 @@
>         }
>     }
>
> -    // todo get this natively supported in the store
>     public List<Project> getProjectsWithDependenciesByGroupId( int
> projectGroupId )
>     {
> -        List<Project> allProjects =
> -            getAllObjectsDetached( Project.class, "name ascending",
> PROJECT_DEPENDENCIES_FETCH_GROUP );
> +        PersistenceManager pm = getPersistenceManager();
>
> -        List<Project> groupProjects = new ArrayList<Project>();
> +        Transaction tx = pm.currentTransaction();
>
> -        for ( Project project : allProjects )
> +        try
>         {
> -            if ( project.getProjectGroup().getId() == projectGroupId )
> -            {
> -                groupProjects.add( project );
> -            }
> +            tx.begin();
> +
> +            Extent extent = pm.getExtent( Project.class, true );
> +
> +            Query query = pm.newQuery( extent, "projectGroup.id == " +
> projectGroupId );
> +
> +            pm.getFetchPlan().addGroup( PROJECT_DEPENDENCIES_FETCH_GROUP
> );
> +            List<Project> result = (List<Project>) query.execute();
> +
> +            result = (List<Project>) pm.detachCopyAll( result );
> +
> +            tx.commit();
> +
> +            return result;
> +        }
> +        finally
> +        {
> +            rollback( tx );
>         }
> -        return groupProjects;
>     }
>
>     public Project getProjectWithBuilds( int projectId )
> @@ -207,9 +217,9 @@
>
>             query.setOrdering( "name ascending" );
>
> -            List result = (List) query.execute();
> +            List<Project> result = (List<Project>) query.execute();
>
> -            result = (List) pm.detachCopyAll( result );
> +            result = (List<Project>) pm.detachCopyAll( result );
>
>             tx.commit();
>
> @@ -242,9 +252,9 @@
>
>             pm.getFetchPlan().addGroup( PROJECTGROUP_PROJECTS_FETCH_GROUP
> );
>
> -            List result = (List) query.execute();
> +            List<Project> result = (List<Project>) query.execute();
>
> -            result = (List) pm.detachCopyAll( result );
> +            result = (List<Project>) pm.detachCopyAll( result );
>
>             tx.commit();
>
> @@ -256,12 +266,6 @@
>         }
>     }
>
> -
> -    public List<Project> getAllProjectsWithAllDetails()
> -    {
> -        return getAllObjectsDetached( Project.class, "name ascending",
> PROJECT_ALL_DETAILS_FETCH_GROUP );
> -    }
> -
>     public Project getProjectWithAllDetails( int projectId )
>         throws ContinuumStoreException
>     {
> @@ -349,7 +353,7 @@
>             int projectGroupId = result.getProjectGroupId();
>             int size = new Long( result.getSize() ).intValue();
>             int state = result.getProjectState();
> -
> +
>             if ( map.containsKey( projectGroupId ) )
>             {
>                 summary = map.get( projectGroupId );
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message