From: Joakim Erdfelt Date: Mon, 13 Aug 2007 19:40:06 +0000 (+0000) Subject: [MRM-465] (Load Testing) When asking for pages that require the effective-pom in... X-Git-Tag: archiva-1.0-beta-2~72 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=da086173f75d4e0ecf70737ab256af8a2b076ed6;p=archiva.git [MRM-465] (Load Testing) When asking for pages that require the effective-pom in high load, app becomes unresponsive. Added an ehcache around the effective-pom resolution process. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@565484 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-base/archiva-repository-layer/pom.xml b/archiva-base/archiva-repository-layer/pom.xml index f8c47986f..b2263d06a 100644 --- a/archiva-base/archiva-repository-layer/pom.xml +++ b/archiva-base/archiva-repository-layer/pom.xml @@ -106,6 +106,19 @@ descriptor + + merge + + merge-descriptors + + + ${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml + + ${basedir}/src/main/resources/META-INF/plexus/components-fragment.xml + ${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml + + + diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java index cb7768f3b..8a5b8f8be 100644 --- a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java @@ -29,6 +29,7 @@ import org.apache.maven.archiva.repository.project.ProjectModelException; import org.apache.maven.archiva.repository.project.ProjectModelFilter; import org.apache.maven.archiva.repository.project.ProjectModelMerge; import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory; +import org.codehaus.plexus.cache.Cache; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.console.ConsoleLogger; @@ -56,6 +57,11 @@ public class EffectiveProjectModelFilter * @plexus.requirement */ private ProjectModelResolverFactory resolverFactory; + + /** + * @plexus.requirement role-hint="effective-project-cache" + */ + private Cache effectiveProjectCache; /** * Take the provided {@link ArchivaProjectModel} and build the effective {@link ArchivaProjectModel}. @@ -81,9 +87,21 @@ public class EffectiveProjectModelFilter { throw new IllegalStateException( "Unable to build effective pom with no project model resolvers defined." ); } + + ArchivaProjectModel effectiveProject; + String projectKey = toProjectKey( project ); + + synchronized( effectiveProjectCache ) + { + if( effectiveProjectCache.hasKey( projectKey ) ) + { + effectiveProject = (ArchivaProjectModel) effectiveProjectCache.get( projectKey ); + return effectiveProject; + } + } // Clone submitted project (so that we don't mess with it) - ArchivaProjectModel effectiveProject = ArchivaModelCloner.clone( project ); + effectiveProject = ArchivaModelCloner.clone( project ); // Setup Expression Evaluation pieces. effectiveProject = expressionFilter.filter( effectiveProject ); @@ -95,6 +113,11 @@ public class EffectiveProjectModelFilter // Resolve dependency versions from dependency management. applyDependencyManagement( effectiveProject ); + + synchronized( effectiveProjectCache ) + { + effectiveProjectCache.put( projectKey, effectiveProject ); + } // Return what we got. return effectiveProject; @@ -157,6 +180,16 @@ public class EffectiveProjectModelFilter VersionedReference parentRef = pom.getParentProject(); getLogger().debug( "Has parent: " + parentRef ); + + String pomKey = VersionedReference.toKey( parentRef ); + + synchronized( effectiveProjectCache ) + { + if( effectiveProjectCache.hasKey( pomKey ) ) + { + return (ArchivaProjectModel) effectiveProjectCache.get( pomKey ); + } + } // Find parent using resolvers. ArchivaProjectModel parentProject = this.resolverFactory.getCurrentResolverStack().findProject( parentRef ); @@ -173,6 +206,11 @@ public class EffectiveProjectModelFilter // TODO: Document this via monitor. mixedProject = mixinSuperPom( pom ); } + + synchronized( effectiveProjectCache ) + { + effectiveProjectCache.put( pomKey, mixedProject ); + } } else { @@ -187,7 +225,7 @@ public class EffectiveProjectModelFilter mixedProject = mixinSuperPom( pom ); } - + return mixedProject; } @@ -232,4 +270,15 @@ public class EffectiveProjectModelFilter return key.toString(); } + + private String toProjectKey( ArchivaProjectModel project ) + { + StringBuffer key = new StringBuffer(); + + key.append( project.getGroupId() ).append( ":" ); + key.append( project.getArtifactId() ).append( ":" ); + key.append( project.getVersion() ); + + return key.toString(); + } } diff --git a/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml b/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml new file mode 100644 index 000000000..ed63a3b82 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml @@ -0,0 +1,25 @@ + + + + org.codehaus.plexus.cache.Cache + effective-project-cache + org.codehaus.plexus.cache.ehcache.EhcacheCache + Effective Project Cache + + 600 + true + ${java.io.tmpdir}/archiva/effectiveproject + true + 1000 + LRU + effective-project-cache + false + + + 2700 + + 1800 + + + +