maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r306560 - in /maven/components/trunk: maven-artifact-ant/src/main/resources/META-INF/plexus/ maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/ maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/ ...
Date Thu, 06 Oct 2005 09:40:29 GMT
Author: brett
Date: Thu Oct  6 02:40:13 2005
New Revision: 306560

URL: http://svn.apache.org/viewcvs?rev=306560&view=rev
Log:
PR: MNG-1109
better handling for timeout and other transfer failed exceptions that are recoverable (ie
metadata), and then blacklist the repository for performance.

Modified:
    maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
    maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
    maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
    maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java

Modified: maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/components/trunk/maven-artifact-ant/src/main/resources/META-INF/plexus/components.xml
Thu Oct  6 02:40:13 2005
@@ -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>
 
     <!--

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
(original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/manager/DefaultWagonManager.java
Thu Oct  6 02:40:13 2005
@@ -19,6 +19,7 @@
 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 @@
 
     private boolean online = true;
 
+    private ArtifactRepositoryFactory repositoryFactory;
+
     public Wagon getWagon( String protocol )
         throws UnsupportedProtocolException
     {
@@ -253,7 +256,15 @@
 
         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 @@
 
             artifact.setResolved( true );
         }
-        else
-        {
-            getLogger().debug( "Skipping disabled repository " + repository.getId() );
-        }
     }
 
     public void getArtifactMetadata( ArtifactMetadata metadata, ArtifactRepository repository,
File destination,
@@ -289,8 +296,9 @@
         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();

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
(original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepository.java
Thu Oct  6 02:40:13 2005
@@ -40,6 +40,8 @@
 
     private boolean uniqueVersion;
 
+    private boolean blacklisted;
+
     /**
      * Create a local repository or a test repository.
      *
@@ -138,5 +140,15 @@
     public boolean isUniqueVersion()
     {
         return uniqueVersion;
+    }
+
+    public boolean isBlacklisted()
+    {
+        return blacklisted;
+    }
+
+    public void setBlacklisted( boolean blacklisted )
+    {
+        this.blacklisted = blacklisted;
     }
 }

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
(original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/DefaultArtifactRepositoryFactory.java
Thu Oct  6 02:40:13 2005
@@ -18,6 +18,9 @@
 
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * @author jdcasey
  */
@@ -29,8 +32,11 @@
 
     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 @@
                                                         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 @@
             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 )

Modified: maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
(original)
+++ maven/components/trunk/maven-artifact-manager/src/main/java/org/apache/maven/artifact/repository/metadata/DefaultRepositoryMetadataManager.java
Thu Oct  6 02:40:13 2005
@@ -70,6 +70,10 @@
                 {
                     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 @@
             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 @@
 
     private void resolveAlways( ArtifactMetadata metadata, ArtifactRepository repository,
File file,
                                 String checksumPolicy )
-        throws ArtifactMetadataRetrievalException
     {
         if ( !wagonManager.isOnline() )
         {
@@ -284,7 +287,11 @@
         }
         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 );
         }
     }
 

Modified: maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/components/trunk/maven-artifact-manager/src/main/resources/META-INF/plexus/components.xml
Thu Oct  6 02:40:13 2005
@@ -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>

Modified: maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java?rev=306560&r1=306559&r2=306560&view=diff
==============================================================================
--- maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
(original)
+++ maven/components/trunk/maven-artifact/src/main/java/org/apache/maven/artifact/repository/ArtifactRepository.java
Thu Oct  6 02:40:13 2005
@@ -51,4 +51,8 @@
     String getKey();
 
     boolean isUniqueVersion();
+
+    void setBlacklisted( boolean blackListed );
+
+    boolean isBlacklisted();
 }



Mime
View raw message