configure maxElementsInMemory and maxElementsOnDisk

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1426342 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-27 22:04:22 +00:00
parent 62992df826
commit ce9d2fce63
6 changed files with 94 additions and 6 deletions

View File

@ -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();
}

View File

@ -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 );

View File

@ -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;
}

View File

@ -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

View File

@ -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);
}
});

View File

@ -1054,6 +1054,22 @@
</div>
</div>
<div class="control-group">
<label class="control-label" for="maxElementsInMemory">${$.i18n.prop('redback.runtime.maxElementsInMemory.label')}</label>
<div class="controls">
<input type="text" class="xlarge required numeric" data-bind="value: redbackRuntimeConfiguration().usersCacheConfiguration().maxElementsInMemory"
id="maxElementsInMemory" name="maxElementsInMemory" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="maxElementsOnDisk">${$.i18n.prop('redback.runtime.maxElementsOnDisk.label')}</label>
<div class="controls">
<input type="text" class="xlarge required numeric" data-bind="value: redbackRuntimeConfiguration().usersCacheConfiguration().maxElementsOnDisk"
id="maxElementsOnDisk" name="maxElementsOnDisk" />
</div>
</div>
</form>