Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,12 @@ public List<String> getAllowHttpJobTypes()
{
return new ArrayList<>();
}

@Override
public List<String> getEgressSites()
{
return new ArrayList<>();
}
};

@Inject
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<partylineVersion>1.16</partylineVersion>
<pathmappedStorageVersion>2.5</pathmappedStorageVersion>
<weftVersion>1.24</weftVersion>
<jhttpcVersion>1.14</jhttpcVersion>
<jhttpcVersion>1.15-SNAPSHOT</jhttpcVersion>
<infinispanVersion>9.4.7.Final</infinispanVersion>
<weldVersion>3.1.9.Final</weldVersion>
<byteman.version>4.0.20</byteman.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public DownloadJob createDownloadJob( final ConcreteResource resource, final Tra
{
return new HttpDownload( getUrl( resource ), getHttpLocation( resource.getLocation(), download ), target,
transferSizes, eventMetadata, http, mapper, metricRegistry, metricConfig,
proxySitesCache );
globalProxyConfig.getEgressSites(), proxySitesCache );
}

@Override
Expand Down Expand Up @@ -165,7 +165,8 @@ public ListingJob createListingJob( final ConcreteResource resource, final Trans
{
return new HttpListing( getUrl( resource ),
new ConcreteResource( getHttpLocation( resource.getLocation(), listing ),
resource.getPath() ), http, proxySitesCache );
resource.getPath() ), http, globalProxyConfig.getEgressSites(),
proxySitesCache );
}

private HttpLocation getHttpLocation( final Location repository, HttpJobType httpJobType )
Expand All @@ -189,7 +190,7 @@ public ExistenceJob createExistenceJob( final ConcreteResource resource, final T
throws TransferException
{
return new HttpExistence( getUrl( resource ), getHttpLocation( resource.getLocation(), existence ), target,
http, mapper, proxySitesCache );
http, mapper, globalProxyConfig.getEgressSites(), proxySitesCache );
}

private String getUrl( final ConcreteResource resource )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ public interface GlobalProxyConfig
String getUser();

List<String> getAllowHttpJobTypes();

List<String> getEgressSites();
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import static org.commonjava.o11yphant.trace.TraceManager.addFieldToActiveSpan;

Expand All @@ -73,14 +74,18 @@ public abstract class AbstractHttpJob

protected boolean success;

private final List<String> egressSites;

private final ProxySitesCache proxySitesCache;

protected AbstractHttpJob( final String url, final HttpLocation location, final Http http,
ProxySitesCache proxySitesCache, final Integer... successStatuses )
final List<String> egressSites, ProxySitesCache proxySitesCache,
final Integer... successStatuses )
{
this.url = url;
this.location = location;
this.http = http;
this.egressSites = egressSites;
this.proxySitesCache = proxySitesCache;

if ( successStatuses.length < 1 )
Expand Down Expand Up @@ -158,7 +163,7 @@ else if ( !doProxy ) // never do with proxy, retry with proxy
{
tries = 1;
doProxy = true;
if ( proxySitesCache != null )
if ( proxySitesCache != null && ( egressSites == null || !egressSites.contains( site ) ) )
{
proxySitesCache.saveProxySite( site );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import static org.apache.commons.io.IOUtils.closeQuietly;
Expand Down Expand Up @@ -68,7 +69,7 @@ public HttpDownload( final String url, final HttpLocation location, final Transf
final Map<Transfer, Long> transferSizes, final EventMetadata eventMetadata, final Http http,
final ObjectMapper mapper )
{
this( url, location, target, transferSizes, eventMetadata, http, mapper, true, null, null, null );
this( url, location, target, transferSizes, eventMetadata, http, mapper, true, null, null, null, null );
}

public HttpDownload( final String url, final HttpLocation location, final Transfer target,
Expand All @@ -77,25 +78,27 @@ public HttpDownload( final String url, final HttpLocation location, final Transf
final TransportMetricConfig transportMetricConfig )
{
this( url, location, target, transferSizes, eventMetadata, http, mapper, true, metricRegistry,
transportMetricConfig, null );
transportMetricConfig, null, null );
}

public HttpDownload( final String url, final HttpLocation location, final Transfer target,
final Map<Transfer, Long> transferSizes, final EventMetadata eventMetadata, final Http http,
final ObjectMapper mapper, final MetricRegistry metricRegistry,
final TransportMetricConfig transportMetricConfig, ProxySitesCache proxySitesCache )
final TransportMetricConfig transportMetricConfig, final List<String> egressSites,
ProxySitesCache proxySitesCache )
{
this( url, location, target, transferSizes, eventMetadata, http, mapper, true, metricRegistry,
transportMetricConfig, proxySitesCache );
transportMetricConfig, egressSites, proxySitesCache );
}

public HttpDownload( final String url, final HttpLocation location, final Transfer target,
final Map<Transfer, Long> transferSizes, final EventMetadata eventMetadata, final Http http,
final ObjectMapper mapper, final boolean deleteFilesOnPath,
final MetricRegistry metricRegistry, final TransportMetricConfig transportMetricConfig,
ProxySitesCache proxySitesCache )
final List<String> egressSites, ProxySitesCache proxySitesCache )
{
super( url, location, http, proxySitesCache );

super( url, location, http, egressSites, proxySitesCache );
this.request = new HttpGet( url );
this.target = target;
this.transferSizes = transferSizes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import org.commonjava.maven.galley.transport.htcli.Http;
import org.commonjava.maven.galley.transport.htcli.model.HttpLocation;

import java.util.List;

import static org.commonjava.o11yphant.trace.TraceManager.addFieldToActiveSpan;

public final class HttpExistence
Expand All @@ -38,13 +40,13 @@ public final class HttpExistence
public HttpExistence( final String url, final HttpLocation location, final Transfer transfer, final Http http,
final ObjectMapper mapper )
{
this( url, location, transfer, http, mapper, null );
this( url, location, transfer, http, mapper, null, null );
}

public HttpExistence( final String url, final HttpLocation location, final Transfer transfer, final Http http,
final ObjectMapper mapper, ProxySitesCache proxySitesCache )
final ObjectMapper mapper, final List<String> egressSites, ProxySitesCache proxySitesCache )
{
super( url, location, http, proxySitesCache );
super( url, location, http, egressSites, proxySitesCache );
this.transfer = transfer;
this.mapper = mapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import static org.apache.commons.io.IOUtils.closeQuietly;
Expand All @@ -60,13 +61,13 @@ public class HttpListing

public HttpListing( final String url, final ConcreteResource resource, final Http http )
{
this( url, resource, http, null );
this( url, resource, http, null, null );
}

public HttpListing( final String url, final ConcreteResource resource, final Http http,
ProxySitesCache proxySitesCache )
final List<String> egressSites, ProxySitesCache proxySitesCache )
{
super( url, (HttpLocation) resource.getLocation(), http, proxySitesCache );
super( url, (HttpLocation) resource.getLocation(), http, egressSites, proxySitesCache );
this.resource = resource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import org.apache.http.entity.ContentType;
import org.apache.http.entity.InputStreamEntity;
import org.commonjava.maven.galley.TransferException;
import org.commonjava.maven.galley.spi.proxy.ProxySitesCache;
import org.commonjava.maven.galley.spi.transport.PublishJob;
import org.commonjava.maven.galley.transport.htcli.Http;
import org.commonjava.maven.galley.transport.htcli.model.HttpLocation;
import org.commonjava.maven.galley.util.ContentTypeUtils;

import java.io.InputStream;
import java.util.ArrayList;

import static org.commonjava.o11yphant.trace.TraceManager.addFieldToActiveSpan;

Expand All @@ -46,7 +46,7 @@ public final class HttpPublish
public HttpPublish( final String url, final HttpLocation location, final InputStream stream, final long length,
final String contentType, final Http http )
{
super( url, location, http, null, HttpStatus.SC_OK, HttpStatus.SC_CREATED );
super( url, location, http, null, null, HttpStatus.SC_OK, HttpStatus.SC_CREATED );
this.stream = stream;
this.length = length;
this.contentType = contentType == null ? ContentTypeUtils.detectContent( url ) : contentType;
Expand Down