summaryrefslogtreecommitdiffstats
path: root/archiva-base/archiva-repository-layer
diff options
context:
space:
mode:
authorJoakim Erdfelt <joakime@apache.org>2007-08-13 19:40:06 +0000
committerJoakim Erdfelt <joakime@apache.org>2007-08-13 19:40:06 +0000
commitda086173f75d4e0ecf70737ab256af8a2b076ed6 (patch)
tree82b35cd6d88bee925b03fa39bc493c6f75e60cdf /archiva-base/archiva-repository-layer
parente1a18ba96ff546ebf8406e3e5db1718964c52c79 (diff)
downloadarchiva-da086173f75d4e0ecf70737ab256af8a2b076ed6.tar.gz
archiva-da086173f75d4e0ecf70737ab256af8a2b076ed6.zip
[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
Diffstat (limited to 'archiva-base/archiva-repository-layer')
-rw-r--r--archiva-base/archiva-repository-layer/pom.xml13
-rw-r--r--archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/project/filters/EffectiveProjectModelFilter.java53
-rw-r--r--archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components-fragment.xml25
3 files changed, 89 insertions, 2 deletions
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 @@
<goal>descriptor</goal>
</goals>
</execution>
+ <execution>
+ <id>merge</id>
+ <goals>
+ <goal>merge-descriptors</goal>
+ </goals>
+ <configuration>
+ <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+ <descriptors>
+ <descriptor>${basedir}/src/main/resources/META-INF/plexus/components-fragment.xml</descriptor>
+ <descriptor>${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml</descriptor>
+ </descriptors>
+ </configuration>
+ </execution>
</executions>
</plugin>
</plugins>
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 @@
+<component-set>
+ <components>
+ <component>
+ <role>org.codehaus.plexus.cache.Cache</role>
+ <role-hint>effective-project-cache</role-hint>
+ <implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
+ <description>Effective Project Cache</description>
+ <configuration>
+ <disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
+ <disk-persistent>true</disk-persistent>
+ <disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path>
+ <eternal>true</eternal>
+ <max-elements-in-memory>1000</max-elements-in-memory>
+ <memory-eviction-policy>LRU</memory-eviction-policy>
+ <name>effective-project-cache</name>
+ <overflow-to-disk>false</overflow-to-disk>
+ <!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) -->
+ <!-- 45 minutes = 2700 seconds -->
+ <time-to-idle-seconds>2700</time-to-idle-seconds>
+ <!-- 30 minutes = 1800 seconds -->
+ <time-to-live-seconds>1800</time-to-live-seconds>
+ </configuration>
+ </component>
+ </components>
+</component-set>