diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/CacheConfiguration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/CacheConfiguration.java index 20c18102e..ed4814b02 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/CacheConfiguration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/CacheConfiguration.java @@ -39,6 +39,16 @@ public class CacheConfiguration */ private int timeToLiveSeconds = -1; + /** + * max elements in memory. + */ + private int maxElementsInMemory = -1; + + /** + * max elements on disk. + */ + private int maxElementsOnDisk = -1; + public CacheConfiguration() { // no op @@ -64,6 +74,26 @@ public class CacheConfiguration this.timeToLiveSeconds = timeToLiveSeconds; } + public int getMaxElementsInMemory() + { + return maxElementsInMemory; + } + + public void setMaxElementsInMemory( int maxElementsInMemory ) + { + this.maxElementsInMemory = maxElementsInMemory; + } + + public int getMaxElementsOnDisk() + { + return maxElementsOnDisk; + } + + public void setMaxElementsOnDisk( int maxElementsOnDisk ) + { + this.maxElementsOnDisk = maxElementsOnDisk; + } + @Override public String toString() { @@ -71,6 +101,8 @@ public class CacheConfiguration sb.append( "CacheConfiguration" ); sb.append( "{timeToIdleSeconds=" ).append( timeToIdleSeconds ); sb.append( ", timeToLiveSeconds=" ).append( timeToLiveSeconds ); + sb.append( ", maxElementsInMemory=" ).append( maxElementsInMemory ); + sb.append( ", maxElementsOnDisk=" ).append( maxElementsOnDisk ); sb.append( '}' ); return sb.toString(); } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index f8f83f3c4..3c12a2e84 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -147,6 +147,24 @@ public class DefaultRedbackRuntimeConfigurationAdmin usersCache.setTimeToLiveSeconds( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() ); + if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() < 0 ) + { + redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsInMemory( + usersCache.getMaxElementsInMemory() ); + save = true; + } + usersCache.setMaxElementsInMemory( + redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() ); + + if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() < 0 ) + { + redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsOnDisk( + usersCache.getMaxElementsOnDisk() ); + save = true; + } + usersCache.setMaxElementsOnDisk( + redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() ); + if ( save ) { updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration ); diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index b4d68d721..f98b09a52 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -55,7 +55,7 @@ import java.util.Properties; * @author Olivier Lamy * @since 1.4-M4 */ -@Service( "archivaRuntimeConfigurationService#rest" ) +@Service("archivaRuntimeConfigurationService#rest") public class DefaultRedbackRuntimeConfigurationService extends AbstractRestService implements RedbackRuntimeConfigurationService @@ -64,18 +64,18 @@ public class DefaultRedbackRuntimeConfigurationService private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin; @Inject - @Named( value = "userManager#configurable" ) + @Named(value = "userManager#configurable") private UserManager userManager; @Inject private ApplicationContext applicationContext; @Inject - @Named( value = "ldapConnectionFactory#configurable" ) + @Named(value = "ldapConnectionFactory#configurable") private LdapConnectionFactory ldapConnectionFactory; @Inject - @Named( value = "cache#users" ) + @Named(value = "cache#users") private Cache usersCache; @@ -144,6 +144,10 @@ public class DefaultRedbackRuntimeConfigurationService redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() ); usersCache.setTimeToLiveSeconds( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() ); + usersCache.setMaxElementsInMemory( + redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() ); + usersCache.setMaxElementsOnDisk( + redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() ); return Boolean.TRUE; } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties index f90f02e12..35b0ecdc4 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/resources/org/apache/archiva/i18n/default.properties @@ -639,5 +639,7 @@ redback.runtime.usersCacheTimeToLiveSeconds.help.content= redback.runtime.usersCacheTimeToIdleSeconds.label=Time to Idle (seconds) redback.runtime.usersCacheTimeToIdleSeconds.help.title= redback.runtime.usersCacheTimeToIdleSeconds.help.content= +redback.runtime.maxElementsInMemory.label=Max Elements in memory +redback.runtime.maxElementsOnDisk.label=Max Elements on disk diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js index 0db8054b1..dbbbed316 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/archiva/general-admin.js @@ -1504,6 +1504,16 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" digits: true, min: 1, required: true + }, + maxElementsInMemory : { + digits: true, + min: 1, + required: true + }, + maxElementsOnDisk : { + digits: true, + min: 1, + required: true } }, showErrors: function(validator, errorMap, errorList) { @@ -1563,7 +1573,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" } - CacheConfiguration=function(timeToIdleSeconds,timeToLiveSeconds){ + CacheConfiguration=function(timeToIdleSeconds,timeToLiveSeconds,maxElementsInMemory,maxElementsOnDisk){ var self=this; this.modified=ko.observable(false); @@ -1573,13 +1583,19 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" this.timeToLiveSeconds=ko.observable(timeToLiveSeconds); this.timeToLiveSeconds.subscribe(function(newValue){self.modified(true)}); + this.maxElementsInMemory=ko.observable(maxElementsInMemory); + this.maxElementsInMemory.subscribe(function(newValue){self.modified(true)}); + + this.maxElementsOnDisk=ko.observable(maxElementsOnDisk); + this.maxElementsOnDisk.subscribe(function(newValue){self.modified(true)}); + } mapCacheConfiguration=function(data){ if(!data){ return new CacheConfiguration(); } - return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds); + return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds,data.maxElementsInMemory,data.maxElementsOnDisk); } }); \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html index f37f670f4..0a6463046 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/js/templates/archiva/general-admin.html @@ -1054,6 +1054,22 @@ +
+ +
+ +
+
+ +
+ +
+ +
+
+