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
26 changes: 11 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-mutiny</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx</artifactId>
Expand All @@ -128,25 +127,28 @@
<artifactId>indy-model-core-java</artifactId>
<version>${indyModelVersion}</version>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<version>${keycloakVersion}</version>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-adapter-core</artifactId>
<version>${keycloakVersion}</version>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-micrometer-registry-prometheus</artifactId>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-sdk</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-opentelemetry-exporter-otlp</artifactId>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
<dependency>
<groupId>io.opentelemetry</groupId>
<artifactId>opentelemetry-semconv</artifactId>
</dependency>

<dependency>
Expand All @@ -170,14 +172,8 @@
</dependency>

<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-core-jakarta</artifactId>
<version>${infinispanVersion}</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-commons-jakarta</artifactId>
<version>${infinispanVersion}</version>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,39 @@
*/
package org.commonjava.indy.service.httprox.util;

import org.infinispan.Cache;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import jakarta.annotation.PostConstruct;
import jakarta.enterprise.context.ApplicationScoped;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;

@ApplicationScoped
public class CacheProducer
{

private EmbeddedCacheManager cacheManager;

private Map<String, Cache> caches = new ConcurrentHashMap<>();

@PostConstruct
public void start()
{
startEmbeddedManager();
}

private void startEmbeddedManager()
{
cacheManager = new DefaultCacheManager();
}

public synchronized <K, V> Cache<K, V> getCache( String named )
{
return caches.computeIfAbsent( named, ( k ) -> buildCache(named));
return caches.computeIfAbsent( named, ( k ) -> buildCache());
}

private Cache buildCache(String named)
private Cache buildCache()
{
cacheManager.defineConfiguration( named, new ConfigurationBuilder().build() );
return cacheManager.getCache(named, Boolean.TRUE);
Cache<String, String> cache = Caffeine.newBuilder()
.maximumSize( 50 )
.expireAfterAccess(15, TimeUnit.MINUTES)
.build();
return cache;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import org.commonjava.indy.service.httprox.handler.ProxyCreationResult;
import org.commonjava.indy.service.httprox.handler.ProxyRepositoryCreator;
import org.commonjava.indy.service.httprox.model.TrackingKey;
import org.infinispan.Cache;
import com.github.benmanes.caffeine.cache.Cache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -151,9 +151,9 @@ private ArtifactStore doGetArtifactStore(String trackingId, final URL url )

if ( trackingId != null )
{
if ( cache.get( groupName ) != null )
if ( cache.getIfPresent( groupName ) != null )
{
return (ArtifactStore) cache.get( groupName );
return (ArtifactStore) cache.getIfPresent( groupName );
}

Group group = null;
Expand All @@ -165,7 +165,7 @@ private ArtifactStore doGetArtifactStore(String trackingId, final URL url )
if ( response != null && response.getStatus() == HttpStatus.SC_OK )
{
group = (Group)response.readEntity(ArtifactStore.class);
cache.put(groupName, group, 15, TimeUnit.MINUTES);
cache.put(groupName, group);
}
}
catch ( WebApplicationException e )
Expand All @@ -176,7 +176,7 @@ private ArtifactStore doGetArtifactStore(String trackingId, final URL url )
url, trackingId );
ProxyCreationResult result = createRepo( trackingId, url, null );
group = result.getGroup();
cache.put(groupName, group, 15, TimeUnit.MINUTES);
cache.put(groupName, group);
return group;
}
else
Expand Down
Loading