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
2 changes: 1 addition & 1 deletion .github/workflows/maven-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on: [push]
jobs:
build:
name: Build and push
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
env:
MAVEN_OPTS: "-Xmx4096m -Xms2048m -XX:MaxMetaspaceSize=4096m -Xss8m"
SKIP_NPM_CONFIG: false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ on: [pull_request]
jobs:
verify:
name: verify with maven
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
if: ${{ github.event_name != 'push' }}
env:
MAVEN_OPTS: "-Xmx4096m -Xms2048m -XX:MaxMetaspaceSize=4096m -Xss8m"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.commonjava.maven.galley.model.Location;
import org.commonjava.maven.galley.model.Transfer;
import org.commonjava.maven.galley.model.TransferOperation;
import org.commonjava.maven.galley.proxy.NoOpProxySitesCache;
import org.commonjava.maven.galley.transport.htcli.internal.HttpDownload;
import org.commonjava.maven.galley.transport.htcli.model.SimpleHttpLocation;
import org.commonjava.o11yphant.metrics.DefaultMetricRegistry;
Expand Down Expand Up @@ -154,7 +155,7 @@ private Transfer getTestHttpTransfer(final String path, final String content) th
assertThat( transfer.exists(), equalTo( false ) );

HttpDownload dl = new HttpDownload( url, location, transfer, new HashMap<>(), new EventMetadata(),
fixture.getHttp().getHttp(), new ObjectMapper(), true, metricRegistry, metricConfig );
fixture.getHttp().getHttp(), new ObjectMapper(), true, metricRegistry, metricConfig, new NoOpProxySitesCache() );

return dl.call().getTransfer();
}
Expand Down
9 changes: 9 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@
<groupId>org.commonjava.indy</groupId>
<artifactId>indy-schedule-common</artifactId>
</dependency>
<dependency>
<groupId>org.commonjava.indy</groupId>
<artifactId>indy-subsys-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<scope>compile</scope>
</dependency>

</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.commonjava.indy.subsys.infinispan.BasicCacheHandle;
import org.commonjava.indy.subsys.infinispan.CacheProducer;
import org.commonjava.maven.galley.spi.nfc.NotFoundCache;
import org.commonjava.maven.galley.spi.proxy.ProxySitesCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -61,6 +62,8 @@ public class CoreProvider

private IndyObjectMapper objectMapper;

private ProxySitesCache proxySitesCache;

public CoreProvider()
{
}
Expand All @@ -69,6 +72,7 @@ public CoreProvider()
public void init()
{
this.objectMapper = new IndyObjectMapper( objectMapperModules, objectMapperModuleSets );
this.proxySitesCache = new MemoryProxySitesCache();

String nfcProvider = indyConfiguration.getNfcProvider();
logger.info( "Apply nfc provider: {}", nfcProvider );
Expand Down Expand Up @@ -98,4 +102,11 @@ public IndyObjectMapper getIndyObjectMapper()
@Default
public NotFoundCache getNotFoundCache() { return notFoundCache; }

@Produces
@Default
public ProxySitesCache getProxySitesCache()
{
return proxySitesCache;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (C) 2011-2023 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.core.inject;

import org.commonjava.maven.galley.spi.proxy.ProxySitesCache;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Alternative;
import java.util.HashSet;
import java.util.Set;

@ApplicationScoped
@Alternative
public class MemoryProxySitesCache
implements ProxySitesCache
{

protected Set<String> proxySitesCache = new HashSet<>();

@Override
public Set<String> getProxySites()
{
return proxySitesCache;
}

@Override
public boolean isProxySite( String site )
{
return proxySitesCache.contains( site );
}

@Override
public void saveProxySite( String site )
{
proxySitesCache.add( site );
}

@Override
public void deleteProxySite( String site )
{
proxySitesCache.remove( site );
}

@Override
public void deleteAllProxySites()
{
proxySitesCache.clear();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* Copyright (C) 2011-2023 Red Hat, Inc. (https://github.com/Commonjava/indy)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.commonjava.indy.core.jaxrs;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.commonjava.indy.bind.jaxrs.IndyResources;
import org.commonjava.indy.bind.jaxrs.util.REST;
import org.commonjava.maven.galley.spi.proxy.ProxySitesCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput;
import javax.ws.rs.core.UriInfo;
import java.util.Set;

@Api( value = "Proxy Site Cache Access and Storage" )
@Path( "/api/proxysite" )
@ApplicationScoped
@REST
public class ProxySiteAccessResource
implements IndyResources
{
protected final Logger logger = LoggerFactory.getLogger( getClass() );

@Inject
ProxySitesCache proxySitesCache;

@ApiOperation( "Retrieve All Proxy Sites." )
@ApiResponses( { @ApiResponse( code = 404, message = "Site is not available" ),
@ApiResponse( code = 200, response = StreamingOutput.class, message = "Site stream" ), } )
@Produces( "application/json" )
@Path( "/all" )
@GET
public Response doGet( @Context final UriInfo uriInfo, @Context final HttpServletRequest request )
{
Set<String> result = proxySitesCache.getProxySites();
logger.info( "Proxy Site Cache list: {}", result );
return ( result == null || result.isEmpty() ) ?
Response.status( Response.Status.NOT_FOUND ).build() :
Response.ok( result ).build();
}

@ApiOperation( "Store Proxy Site." )
@ApiResponses( { @ApiResponse( code = 201, message = "Site was stored successfully" ) } )
@PUT
@Path( "/{site}" )
public Response doCreate( @PathParam( "site" ) final String site, @Context final HttpServletRequest request,
@Context final UriInfo uriInfo )
{
proxySitesCache.saveProxySite( site );
return Response.created( uriInfo.getRequestUri() ).build();
}

@ApiOperation( "Delete Proxy Site." )
@ApiResponse( code = 200, message = "Delete complete." )
@Path( "/{site}" )
@DELETE
public Response doDelete( @PathParam( "site" ) final String site )
{
proxySitesCache.deleteProxySite( site );
return Response.ok().build();
}

@ApiOperation( "Delete All Proxy Sites." )
@ApiResponse( code = 200, message = "Delete complete." )
@Path( "/all" )
@DELETE
public Response doDeleteAll()
{
proxySitesCache.deleteAllProxySites();
return Response.ok().build();
}

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<indyModelVersion>1.5</indyModelVersion>
<indyClientVersion>3.4.0</indyClientVersion>
<atlasVersion>1.1.4</atlasVersion>
<galleyVersion>1.17</galleyVersion>
<galleyVersion>1.18-SNAPSHOT</galleyVersion>
<weftVersion>1.24</weftVersion>
<webdavVersion>3.2.1</webdavVersion>
<!-- TODO: partyline is still needed for standalone mode, may be removed in future -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,21 @@
import org.commonjava.maven.galley.io.NoOpTransferDecorator;
import org.commonjava.maven.galley.io.TransferDecoratorManager;
import org.commonjava.maven.galley.nfc.MemoryNotFoundCache;
import org.commonjava.maven.galley.proxy.NoOpProxySitesCache;
import org.commonjava.maven.galley.spi.cache.CacheProvider;
import org.commonjava.maven.galley.spi.event.FileEventManager;
import org.commonjava.maven.galley.spi.nfc.NotFoundCache;
import org.commonjava.maven.galley.spi.proxy.ProxySitesCache;
import org.commonjava.maven.galley.transport.htcli.conf.GlobalHttpConfiguration;
import org.commonjava.maven.galley.transport.htcli.conf.GlobalProxyConfig;
import org.junit.rules.TemporaryFolder;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Alternative;
import javax.enterprise.inject.Default;
import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import static org.junit.Assert.fail;

Expand All @@ -65,6 +63,8 @@ public class TestProvider

private NotFoundCache nfc;

private ProxySitesCache proxySitesCache;

private StoreDataManager storeDataManager;

private ObjectMapper objectMapper;
Expand Down Expand Up @@ -94,6 +94,7 @@ public void setup()
{
storeDataManager = new MemoryStoreDataManager( true );
nfc = new MemoryNotFoundCache();
proxySitesCache = new NoOpProxySitesCache();
objectMapper = new IndyObjectMapper( false );
fileEventManager = new NoOpFileEventManager();
transferDecorator = new NoOpTransferDecorator();
Expand Down Expand Up @@ -135,6 +136,12 @@ public NotFoundCache getNfc()
return nfc;
}

@Produces
public ProxySitesCache getProxySitesCache()
{
return proxySitesCache;
}

@Produces
@Standalone
@Default
Expand Down