mirror of https://github.com/apache/archiva.git
file lock manager must be configurable
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1550639 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
49c91d619d
commit
679725dd5d
|
@ -1485,6 +1485,14 @@
|
||||||
<type>CacheConfiguration</type>
|
<type>CacheConfiguration</type>
|
||||||
</association>
|
</association>
|
||||||
</field>
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>fileLockConfiguration</name>
|
||||||
|
<description>the FileLocking configuration</description>
|
||||||
|
<version>1.4.0+</version>
|
||||||
|
<association>
|
||||||
|
<type>FileLockConfiguration</type>
|
||||||
|
</association>
|
||||||
|
</field>
|
||||||
</fields>
|
</fields>
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
|
@ -1661,6 +1669,27 @@
|
||||||
</fields>
|
</fields>
|
||||||
</class>
|
</class>
|
||||||
|
|
||||||
|
<class>
|
||||||
|
<name>FileLockConfiguration</name>
|
||||||
|
<version>1.4.0+</version>
|
||||||
|
<description>File Locking configuration.</description>
|
||||||
|
<fields>
|
||||||
|
<field>
|
||||||
|
<name>skipLocking</name>
|
||||||
|
<description>skipping the locking mechanism</description>
|
||||||
|
<version>1.4.0+</version>
|
||||||
|
<type>boolean</type>
|
||||||
|
<defaultValue>true</defaultValue>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>lockingTimeout</name>
|
||||||
|
<description>maximum time to wait to get the file lock (0 infinite)</description>
|
||||||
|
<version>1.4.0+</version>
|
||||||
|
<type>int</type>
|
||||||
|
<defaultValue>0</defaultValue>
|
||||||
|
</field>
|
||||||
|
</fields>
|
||||||
|
</class>
|
||||||
|
|
||||||
<class>
|
<class>
|
||||||
<name>CacheConfiguration</name>
|
<name>CacheConfiguration</name>
|
||||||
|
|
|
@ -29,6 +29,11 @@ public class ArchivaRuntimeConfiguration
|
||||||
{
|
{
|
||||||
private CacheConfiguration urlFailureCacheConfiguration;
|
private CacheConfiguration urlFailureCacheConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
private FileLockConfiguration fileLockConfiguration;
|
||||||
|
|
||||||
public ArchivaRuntimeConfiguration()
|
public ArchivaRuntimeConfiguration()
|
||||||
{
|
{
|
||||||
// no op
|
// no op
|
||||||
|
@ -44,13 +49,24 @@ public class ArchivaRuntimeConfiguration
|
||||||
this.urlFailureCacheConfiguration = urlFailureCacheConfiguration;
|
this.urlFailureCacheConfiguration = urlFailureCacheConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileLockConfiguration getFileLockConfiguration()
|
||||||
|
{
|
||||||
|
return fileLockConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileLockConfiguration( FileLockConfiguration fileLockConfiguration )
|
||||||
|
{
|
||||||
|
this.fileLockConfiguration = fileLockConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder( "ArchivaRuntimeConfiguration{" );
|
||||||
sb.append( "ArchivaRuntimeConfiguration" );
|
sb.append( "urlFailureCacheConfiguration=" ).append( urlFailureCacheConfiguration );
|
||||||
sb.append( "{urlFailureCacheConfiguration=" ).append( urlFailureCacheConfiguration );
|
sb.append( ", fileLockConfiguration=" ).append( fileLockConfiguration );
|
||||||
sb.append( '}' );
|
sb.append( '}' );
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
// =================== DO NOT EDIT THIS FILE ====================
|
||||||
|
// Generated by Modello 1.7,
|
||||||
|
// any modifications will be overwritten.
|
||||||
|
// ==============================================================
|
||||||
|
|
||||||
|
package org.apache.archiva.admin.model.beans;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File Locking configuration.
|
||||||
|
*
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
@XmlRootElement( name = "fileLockConfiguration" )
|
||||||
|
public class FileLockConfiguration
|
||||||
|
implements Serializable
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* skipping the locking mechanism.
|
||||||
|
*/
|
||||||
|
private boolean skipLocking = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* maximum time to wait to get the file lock (0 infinite).
|
||||||
|
*/
|
||||||
|
private int lockingTimeout = 0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get maximum time to wait to get the file lock (0 infinite).
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int getLockingTimeout()
|
||||||
|
{
|
||||||
|
return this.lockingTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get skipping the locking mechanism.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public boolean isSkipLocking()
|
||||||
|
{
|
||||||
|
return this.skipLocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set maximum time to wait to get the file lock (0 infinite).
|
||||||
|
*
|
||||||
|
* @param lockingTimeout
|
||||||
|
*/
|
||||||
|
public void setLockingTimeout( int lockingTimeout )
|
||||||
|
{
|
||||||
|
this.lockingTimeout = lockingTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set skipping the locking mechanism.
|
||||||
|
*
|
||||||
|
* @param skipLocking
|
||||||
|
*/
|
||||||
|
public void setSkipLocking( boolean skipLocking )
|
||||||
|
{
|
||||||
|
this.skipLocking = skipLocking;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -22,6 +22,7 @@ import net.sf.beanlib.provider.replicator.BeanReplicator;
|
||||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
|
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
|
||||||
import org.apache.archiva.admin.model.beans.CacheConfiguration;
|
import org.apache.archiva.admin.model.beans.CacheConfiguration;
|
||||||
|
import org.apache.archiva.admin.model.beans.FileLockConfiguration;
|
||||||
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
||||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||||
import org.apache.archiva.configuration.Configuration;
|
import org.apache.archiva.configuration.Configuration;
|
||||||
|
@ -58,6 +59,12 @@ public class DefaultArchivaRuntimeConfigurationAdmin
|
||||||
|
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
|
|
||||||
|
// NPE free
|
||||||
|
if ( archivaRuntimeConfiguration.getFileLockConfiguration() == null )
|
||||||
|
{
|
||||||
|
archivaRuntimeConfiguration.setFileLockConfiguration( new FileLockConfiguration() );
|
||||||
|
}
|
||||||
|
|
||||||
// NPE free
|
// NPE free
|
||||||
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration() == null )
|
if ( archivaRuntimeConfiguration.getUrlFailureCacheConfiguration() == null )
|
||||||
{
|
{
|
||||||
|
@ -179,6 +186,13 @@ public class DefaultArchivaRuntimeConfigurationAdmin
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( archivaRuntimeConfiguration.getFileLockConfiguration() != null )
|
||||||
|
{
|
||||||
|
res.setFileLockConfiguration(
|
||||||
|
new BeanReplicator().replicateBean( archivaRuntimeConfiguration.getFileLockConfiguration(),
|
||||||
|
org.apache.archiva.configuration.FileLockConfiguration.class ) );
|
||||||
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,9 @@ package org.apache.archiva.rest.services;
|
||||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||||
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
|
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
|
||||||
import org.apache.archiva.admin.model.beans.CacheConfiguration;
|
import org.apache.archiva.admin.model.beans.CacheConfiguration;
|
||||||
|
import org.apache.archiva.admin.model.beans.FileLockConfiguration;
|
||||||
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
||||||
|
import org.apache.archiva.common.filelock.FileLockManager;
|
||||||
import org.apache.archiva.redback.components.cache.Cache;
|
import org.apache.archiva.redback.components.cache.Cache;
|
||||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||||
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
|
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
|
||||||
|
@ -46,6 +48,10 @@ public class DefaultArchivaRuntimeConfigurationService
|
||||||
@Named( value = "cache#url-failures-cache" )
|
@Named( value = "cache#url-failures-cache" )
|
||||||
private Cache usersCache;
|
private Cache usersCache;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named( value = "fileLockManager#default" )
|
||||||
|
private FileLockManager fileLockManager;
|
||||||
|
|
||||||
public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
|
public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
|
||||||
throws ArchivaRestServiceException
|
throws ArchivaRestServiceException
|
||||||
{
|
{
|
||||||
|
@ -73,6 +79,15 @@ public class DefaultArchivaRuntimeConfigurationService
|
||||||
usersCache.setMaxElementsOnDisk( cacheConfiguration.getMaxElementsOnDisk() );
|
usersCache.setMaxElementsOnDisk( cacheConfiguration.getMaxElementsOnDisk() );
|
||||||
usersCache.setMaxElementsInMemory( cacheConfiguration.getMaxElementsInMemory() );
|
usersCache.setMaxElementsInMemory( cacheConfiguration.getMaxElementsInMemory() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileLockConfiguration fileLockConfiguration = archivaRuntimeConfiguration.getFileLockConfiguration();
|
||||||
|
if ( fileLockConfiguration != null )
|
||||||
|
{
|
||||||
|
fileLockManager.setTimeout( fileLockConfiguration.getLockingTimeout() );
|
||||||
|
fileLockConfiguration.setSkipLocking( fileLockConfiguration.isSkipLocking() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( RepositoryAdminException e )
|
catch ( RepositoryAdminException e )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue