Skip to content

Commit

Permalink
Switched to use managed executor
Browse files Browse the repository at this point in the history
  • Loading branch information
sswguo committed Jan 29, 2024
1 parent 6393b03 commit 0dcc2c8
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 54 deletions.
10 changes: 4 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<httpcoreVersion>4.4.9</httpcoreVersion>
<httpclientVersion>4.5.13</httpclientVersion>
<indyModelVersion>1.5-SNAPSHOT</indyModelVersion>
<weftVersion>1.22</weftVersion>
<keycloakVersion>22.0.3</keycloakVersion>
<quarkus.package.type>uber-jar</quarkus.package.type>
<infinispanVersion>14.0.21.Final</infinispanVersion>
Expand Down Expand Up @@ -128,11 +127,6 @@
<artifactId>indy-model-core-java</artifactId>
<version>${indyModelVersion}</version>
</dependency>
<dependency>
<groupId>org.commonjava.cdi.util</groupId>
<artifactId>weft</artifactId>
<version>${weftVersion}</version>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
Expand Down Expand Up @@ -184,6 +178,10 @@
<artifactId>guava</artifactId>
<version>23.6-jre</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public class ProxyConfiguration

private static final String DEFAULT_STORAGE_PATH_STYLE = PathStyle.hashed.name();

private static final int DEFAULT_EXECUTOR_MAX_ASYNC = 50;

private static final int DEFAULT_EXECUTOR_MAX_QUEUED = 20;

@ConfigProperty(name = "proxy.port")
Optional<Integer> port;

Expand Down Expand Up @@ -81,6 +85,12 @@ public class ProxyConfiguration
@ConfigProperty(name="storage.path.style")
public String storagePathStyle;

@ConfigProperty(name="executor.mitm-transfers.max-async")
public Integer mitmMaxAsync;

@ConfigProperty(name="executor.mitm-transfers.max-queued")
public Integer mitmMaxQueued;

public Integer getPort() {
return port.orElse(8081);
}
Expand Down Expand Up @@ -204,4 +214,20 @@ public Integer getHighWater() {
public void setHighWater(Integer highWater) {
this.highWater = highWater;
}

public Integer getMitmMaxAsync() {
return mitmMaxAsync == null ? DEFAULT_EXECUTOR_MAX_ASYNC : mitmMaxAsync;
}

public void setMitmMaxAsync(Integer mitmMaxAsync) {
this.mitmMaxAsync = mitmMaxAsync;
}

public Integer getMitmMaxQueued() {
return mitmMaxQueued == null ? DEFAULT_EXECUTOR_MAX_QUEUED : mitmMaxQueued;
}

public void setMitmMaxQueued(Integer mitmMaxQueued) {
this.mitmMaxQueued = mitmMaxQueued;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.commonjava.indy.service.httprox.handler;

import io.opentelemetry.api.trace.Span;
import jakarta.inject.Named;
import org.commonjava.indy.model.core.io.IndyObjectMapper;
import org.commonjava.indy.service.httprox.client.content.ContentRetrievalService;
import org.commonjava.indy.service.httprox.client.repository.RepositoryService;
Expand Down Expand Up @@ -61,6 +62,7 @@ public class ProxyAcceptHandler implements ChannelListener<AcceptingChannel<Stre
KeycloakProxyAuthenticator proxyAuthenticator;

@Inject
@Named("mitm-transfers")
ManagedExecutor proxyExecutor;

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.opentelemetry.api.trace.Span;
import org.apache.http.HttpRequest;
import org.apache.http.RequestLine;
import org.commonjava.cdi.util.weft.WeftExecutorService;
import org.commonjava.indy.model.core.ArtifactStore;
import org.commonjava.indy.model.core.io.IndyObjectMapper;
import org.commonjava.indy.service.httprox.client.content.ContentRetrievalService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,28 @@
*/
package org.commonjava.indy.service.httprox.handler;

import jakarta.inject.Named;
import jakarta.ws.rs.Produces;
import org.commonjava.cdi.util.weft.ExecutorConfig;
import org.commonjava.cdi.util.weft.WeftExecutorService;
import org.commonjava.cdi.util.weft.WeftManaged;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.ws.rs.Produces;
import org.commonjava.indy.service.httprox.config.ProxyConfiguration;
import org.eclipse.microprofile.context.ManagedExecutor;

import static org.commonjava.cdi.util.weft.ExecutorConfig.BooleanLiteral.FALSE;


public class ProxyTransfersExecutor {

@Inject
ProxyConfiguration config;

@Named("mitm-transfers")
@ApplicationScoped
@Produces
public ManagedExecutor getExecutor()
{

return ManagedExecutor.builder().maxAsync(100)
.maxQueued(200)
.build();
return ManagedExecutor.builder()
.maxAsync( config.getMitmMaxAsync() )
.maxQueued( config.getMitmMaxQueued() )
.build();
}
}
5 changes: 5 additions & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ service_proxy:
port: 8080
path-pattern: /api/.+

executor:
mitm-transfers:
max-async: 100
max-queued: 50

## [MITM]
MITM:
enabled: true
Expand Down

0 comments on commit 0dcc2c8

Please sign in to comment.