mirror of https://github.com/apache/maven.git
PR: MNG-1109
better handling for timeout and other transfer failed exceptions that are recoverable (ie metadata), and then blacklist the repository for performance. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@306560 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6d14b4c4f3
commit
1d42338bb7
|
@ -139,6 +139,11 @@
|
|||
<!--
|
||||
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
|
||||
-->
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<!--
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.maven.artifact.manager;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.wagon.ConnectionException;
|
||||
|
@ -72,6 +73,8 @@ public class DefaultWagonManager
|
|||
|
||||
private boolean online = true;
|
||||
|
||||
private ArtifactRepositoryFactory repositoryFactory;
|
||||
|
||||
public Wagon getWagon( String protocol )
|
||||
throws UnsupportedProtocolException
|
||||
{
|
||||
|
@ -253,7 +256,15 @@ public class DefaultWagonManager
|
|||
|
||||
ArtifactRepositoryPolicy policy = artifact.isSnapshot() ? repository.getSnapshots() : repository.getReleases();
|
||||
|
||||
if ( policy.isEnabled() )
|
||||
if ( !policy.isEnabled() )
|
||||
{
|
||||
getLogger().debug( "Skipping disabled repository " + repository.getId() );
|
||||
}
|
||||
else if ( repository.isBlacklisted() )
|
||||
{
|
||||
getLogger().debug( "Skipping blacklisted repository " + repository.getId() );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().debug( "Trying repository " + repository.getId() );
|
||||
getRemoteFile( repository, artifact.getFile(), remotePath, downloadMonitor, policy.getChecksumPolicy() );
|
||||
|
@ -261,10 +272,6 @@ public class DefaultWagonManager
|
|||
|
||||
artifact.setResolved( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
getLogger().debug( "Skipping disabled repository " + repository.getId() );
|
||||
}
|
||||
}
|
||||
|
||||
public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository, File destination,
|
||||
|
@ -289,8 +296,9 @@ public class DefaultWagonManager
|
|||
ArtifactRepository mirror = getMirror( repository.getId() );
|
||||
if ( mirror != null )
|
||||
{
|
||||
repository = new DefaultArtifactRepository( mirror.getId(), mirror.getUrl(), repository.getLayout(),
|
||||
repository.getSnapshots(), repository.getReleases() );
|
||||
repository = repositoryFactory.createArtifactRepository( mirror.getId(), mirror.getUrl(),
|
||||
repository.getLayout(), repository.getSnapshots(),
|
||||
repository.getReleases() );
|
||||
}
|
||||
|
||||
String protocol = repository.getProtocol();
|
||||
|
|
|
@ -40,6 +40,8 @@ public class DefaultArtifactRepository
|
|||
|
||||
private boolean uniqueVersion;
|
||||
|
||||
private boolean blacklisted;
|
||||
|
||||
/**
|
||||
* Create a local repository or a test repository.
|
||||
*
|
||||
|
@ -139,4 +141,14 @@ public class DefaultArtifactRepository
|
|||
{
|
||||
return uniqueVersion;
|
||||
}
|
||||
|
||||
public boolean isBlacklisted()
|
||||
{
|
||||
return blacklisted;
|
||||
}
|
||||
|
||||
public void setBlacklisted( boolean blacklisted )
|
||||
{
|
||||
this.blacklisted = blacklisted;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,9 @@ package org.apache.maven.artifact.repository;
|
|||
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author jdcasey
|
||||
*/
|
||||
|
@ -29,8 +32,11 @@ public class DefaultArtifactRepositoryFactory
|
|||
|
||||
private String globalChecksumPolicy;
|
||||
|
||||
private final Map artifactRepositories = new HashMap();
|
||||
|
||||
public ArtifactRepository createDeploymentArtifactRepository( String id, String url,
|
||||
ArtifactRepositoryLayout repositoryLayout, boolean uniqueVersion )
|
||||
ArtifactRepositoryLayout repositoryLayout,
|
||||
boolean uniqueVersion )
|
||||
{
|
||||
return new DefaultArtifactRepository( id, url, repositoryLayout, uniqueVersion );
|
||||
}
|
||||
|
@ -40,6 +46,16 @@ public class DefaultArtifactRepositoryFactory
|
|||
ArtifactRepositoryPolicy snapshots,
|
||||
ArtifactRepositoryPolicy releases )
|
||||
{
|
||||
if ( artifactRepositories.containsKey( id ) )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) artifactRepositories.get( id );
|
||||
// TODO: this should be an if there are duplicates?
|
||||
if ( repository.getUrl().equals( url ) )
|
||||
{
|
||||
return repository;
|
||||
}
|
||||
}
|
||||
|
||||
if ( snapshots == null )
|
||||
{
|
||||
snapshots = new ArtifactRepositoryPolicy();
|
||||
|
@ -62,7 +78,12 @@ public class DefaultArtifactRepositoryFactory
|
|||
releases.setChecksumPolicy( globalChecksumPolicy );
|
||||
}
|
||||
|
||||
return new DefaultArtifactRepository( id, url, repositoryLayout, snapshots, releases );
|
||||
DefaultArtifactRepository repository = new DefaultArtifactRepository( id, url, repositoryLayout, snapshots,
|
||||
releases );
|
||||
|
||||
artifactRepositories.put( id, repository );
|
||||
|
||||
return repository;
|
||||
}
|
||||
|
||||
public void setGlobalUpdatePolicy( String updatePolicy )
|
||||
|
|
|
@ -70,6 +70,10 @@ public class DefaultRepositoryMetadataManager
|
|||
{
|
||||
getLogger().debug( "Skipping disabled repository " + repository.getId() );
|
||||
}
|
||||
else if ( repository.isBlacklisted() )
|
||||
{
|
||||
getLogger().debug( "Skipping blacklisted repository " + repository.getId() );
|
||||
}
|
||||
else
|
||||
{
|
||||
File file = new File( localRepository.getBasedir(),
|
||||
|
@ -111,7 +115,7 @@ public class DefaultRepositoryMetadataManager
|
|||
ArtifactRepositoryPolicy policy = metadata.isSnapshot() ? repository.getSnapshots()
|
||||
: repository.getReleases();
|
||||
|
||||
if ( policy.isEnabled() )
|
||||
if ( policy.isEnabled() && !repository.isBlacklisted() )
|
||||
{
|
||||
if ( loadMetadata( metadata, repository, localRepository, previousMetadata ) )
|
||||
{
|
||||
|
@ -260,7 +264,6 @@ public class DefaultRepositoryMetadataManager
|
|||
|
||||
private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository, File file,
|
||||
String checksumPolicy )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
if ( !wagonManager.isOnline() )
|
||||
{
|
||||
|
@ -284,7 +287,11 @@ public class DefaultRepositoryMetadataManager
|
|||
}
|
||||
catch ( TransferFailedException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException( "Unable to retrieve metadata", e );
|
||||
getLogger().warn( metadata + " could not be found on repository: " + repository.getId() +
|
||||
" due to an error: " + e.getCause().getMessage() );
|
||||
getLogger().info( "Repository '" + repository.getId() + "' will be blacklisted" );
|
||||
getLogger().debug( "Exception", e );
|
||||
repository.setBlacklisted( true );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,11 @@
|
|||
<component>
|
||||
<role>org.apache.maven.artifact.manager.WagonManager</role>
|
||||
<implementation>org.apache.maven.artifact.manager.DefaultWagonManager</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
|
|
|
@ -51,4 +51,8 @@ public interface ArtifactRepository
|
|||
String getKey();
|
||||
|
||||
boolean isUniqueVersion();
|
||||
|
||||
void setBlacklisted( boolean blackListed );
|
||||
|
||||
boolean isBlacklisted();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue