mirror of https://github.com/apache/archiva.git
add a service to know repositories ids running a remote download
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1541794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d19a302344
commit
c230bdbe41
|
@ -236,4 +236,9 @@ public class DefaultDownloadRemoteIndexScheduler
|
|||
{
|
||||
this.taskScheduler = taskScheduler;
|
||||
}
|
||||
|
||||
public List<String> getRunningRemoteDownloadIds()
|
||||
{
|
||||
return runningRemoteDownloadIds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ package org.apache.archiva.scheduler.indexing;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @since 1.4-M1
|
||||
|
@ -26,4 +28,6 @@ public interface DownloadRemoteIndexScheduler
|
|||
{
|
||||
void scheduleDownloadRemote( String repositoryId, boolean now, boolean fullDownload )
|
||||
throws DownloadRemoteIndexException;
|
||||
|
||||
List<String> getRunningRemoteDownloadIds();
|
||||
}
|
||||
|
|
|
@ -232,16 +232,19 @@ public class DownloadRemoteIndexTask
|
|||
request.setLocalIndexCacheDir( indexCacheDirectory );
|
||||
|
||||
this.indexUpdater.fetchAndUpdateIndex( request );
|
||||
stopWatch.stop();
|
||||
log.info( "time update index from remote for repository {}: {} s", this.remoteRepository.getId(),
|
||||
( stopWatch.getTime() / 1000 ) );
|
||||
|
||||
// index packing optionnal ??
|
||||
//IndexPackingRequest indexPackingRequest =
|
||||
// new IndexPackingRequest( indexingContext, indexingContext.getIndexDirectoryFile() );
|
||||
//indexPacker.packIndex( indexPackingRequest );
|
||||
|
||||
indexingContext.updateTimestamp( true );
|
||||
|
||||
stopWatch.stop();
|
||||
log.info( "time update index from remote for repository {}: {} s", this.remoteRepository.getId(),
|
||||
( stopWatch.getTime() / 1000 ) );
|
||||
|
||||
|
||||
}
|
||||
catch ( MalformedURLException e )
|
||||
{
|
||||
|
@ -263,7 +266,7 @@ public class DownloadRemoteIndexTask
|
|||
deleteDirectoryQuiet( tempIndexDirectory );
|
||||
this.runningRemoteDownloadIds.remove( this.remoteRepository.getId() );
|
||||
}
|
||||
log.info( "end download remote index for remote repository " + this.remoteRepository.getId() );
|
||||
log.info( "end download remote index for remote repository {}", this.remoteRepository.getId() );
|
||||
}
|
||||
|
||||
private void deleteDirectoryQuiet( File f )
|
||||
|
@ -304,7 +307,7 @@ public class DownloadRemoteIndexTask
|
|||
{
|
||||
if ( response.getStatusLine().getStatusCode() != HttpStatus.SC_OK )
|
||||
{
|
||||
throw new ClientProtocolException( "Upload failed: " + response.getStatusLine() );
|
||||
throw new ClientProtocolException( "Download failed: " + response.getStatusLine() );
|
||||
}
|
||||
long endTime = System.currentTimeMillis();
|
||||
log.info( "end of transfer file {} {} kb: {}s", resourceName, this.totalLength / 1024,
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.archiva.maven2.model.Artifact;
|
|||
import org.apache.archiva.redback.authorization.RedbackAuthorization;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
|
||||
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
|
||||
import org.apache.archiva.rest.api.model.StringList;
|
||||
import org.apache.archiva.security.common.ArchivaRoleConstants;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -34,6 +35,7 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
|
@ -166,5 +168,13 @@ public interface RepositoriesService
|
|||
@PathParam ("repositoryId") String repositoryId )
|
||||
throws ArchivaRestServiceException;
|
||||
|
||||
/**
|
||||
* @since 2.0
|
||||
*/
|
||||
@Path ("runningRemoteDownloadIds")
|
||||
@GET
|
||||
@Produces ({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN })
|
||||
@RedbackAuthorization (noPermission = true)
|
||||
StringList getRunningRemoteDownloadIds();
|
||||
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import org.apache.archiva.repository.scanner.RepositoryScanStatistics;
|
|||
import org.apache.archiva.repository.scanner.RepositoryScanner;
|
||||
import org.apache.archiva.repository.scanner.RepositoryScannerException;
|
||||
import org.apache.archiva.rest.api.model.ArtifactTransferRequest;
|
||||
import org.apache.archiva.rest.api.model.StringList;
|
||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||
import org.apache.archiva.rest.api.services.RepositoriesService;
|
||||
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
|
||||
|
@ -1153,6 +1154,12 @@ public class DefaultRepositoriesService
|
|||
checksum.fixChecksums( algorithms );
|
||||
}
|
||||
|
||||
@Override
|
||||
public StringList getRunningRemoteDownloadIds()
|
||||
{
|
||||
return new StringList( downloadRemoteIndexScheduler.getRunningRemoteDownloadIds() );
|
||||
}
|
||||
|
||||
public ManagedRepositoryAdmin getManagedRepositoryAdmin()
|
||||
{
|
||||
return managedRepositoryAdmin;
|
||||
|
|
|
@ -56,7 +56,7 @@ public class DownloadMergedIndexNonDefaultPathTest
|
|||
public static void setAppServerBase()
|
||||
{
|
||||
previousAppServerBase = System.getProperty( "appserver.base" );
|
||||
System.setProperty( "appserver.base", "target/" + DownloadMergedIndexNonDefaultPathTest.class.getName() );
|
||||
System.setProperty( "appserver.base", System.getProperty( "basedir" ) + "/target/" + DownloadMergedIndexNonDefaultPathTest.class.getName() );
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
@ -175,11 +175,17 @@ public class DownloadMergedIndexNonDefaultPathTest
|
|||
repositoriesService.scheduleDownloadRemoteIndex( remoteId, true, true );
|
||||
|
||||
// wait a bit
|
||||
/*
|
||||
timeout = 20000;
|
||||
while ( timeout > 0 )
|
||||
{
|
||||
Thread.sleep( 500 );
|
||||
timeout -= 500;
|
||||
}*/
|
||||
// wait the end
|
||||
while ( !repositoriesService.getRunningRemoteDownloadIds().getStrings().isEmpty() )
|
||||
{
|
||||
Thread.sleep( 500 );
|
||||
}
|
||||
|
||||
SearchService searchService = getSearchService();
|
||||
|
|
Loading…
Reference in New Issue