Skip to content

Commit

Permalink
Removed connection evictor threads
Browse files Browse the repository at this point in the history
  • Loading branch information
namedgraph committed Dec 1, 2024
1 parent ed9a23d commit 4750c48
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions src/main/java/com/atomgraph/linkeddatahub/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.ClientRequestFilter;
import java.util.concurrent.ScheduledExecutorService;
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamSource;
import net.jodah.expiringmap.ExpiringMap;
Expand Down Expand Up @@ -1387,22 +1386,6 @@ public void releaseConnection(final HttpClientConnection managedConn, final Obje
if (maxTotalConn != null) conman.setMaxTotal(maxTotalConn);
conman.setValidateAfterInactivity(30000); // check connections idle for more than Varnish's idle_timeout which is 5s

Integer idleConnTimeout = 4000;
// create monitor thread that evicts idle connections: https://hc.apache.org/httpcomponents-client-4.5.x/current/tutorial/html/connmgmt.html#d5e418
ScheduledExecutorService idleConnectionMonitor = Executors.newSingleThreadScheduledExecutor();
idleConnectionMonitor.scheduleAtFixedRate(() ->
{
try
{
if (log.isDebugEnabled()) log.debug("Evicting idle HTTP connections (every {} ms)", idleConnTimeout);
conman.closeIdleConnections(idleConnTimeout, TimeUnit.MILLISECONDS);
}
catch (Exception ex)
{
if (log.isErrorEnabled()) log.error("Error closing idle connections: {}", ex);
}
}, 0, idleConnTimeout, java.util.concurrent.TimeUnit.MILLISECONDS);

ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
config.register(MultiPartFeature.class);
Expand Down Expand Up @@ -1483,22 +1466,6 @@ public void releaseConnection(final HttpClientConnection managedConn, final Obje
if (maxConnPerRoute != null) conman.setDefaultMaxPerRoute(maxConnPerRoute);
if (maxTotalConn != null) conman.setMaxTotal(maxTotalConn);
conman.setValidateAfterInactivity(30000); // check connections idle for more than Varnish's idle_timeout which is 5s

Integer idleConnTimeout = 4000;
// create monitor thread that evicts idle connections: https://hc.apache.org/httpcomponents-client-4.5.x/current/tutorial/html/connmgmt.html#d5e418
ScheduledExecutorService idleConnectionMonitor = Executors.newSingleThreadScheduledExecutor();
idleConnectionMonitor.scheduleAtFixedRate(() ->
{
try
{
if (log.isDebugEnabled()) log.debug("Evicting idle HTTP connections (every {} ms)", idleConnTimeout);
conman.closeIdleConnections(idleConnTimeout, TimeUnit.MILLISECONDS);
}
catch (Exception ex)
{
if (log.isErrorEnabled()) log.error("Error closing idle connections: {}", ex);
}
}, 0, idleConnTimeout, java.util.concurrent.TimeUnit.MILLISECONDS);

ClientConfig config = new ClientConfig();
config.connectorProvider(new ApacheConnectorProvider());
Expand Down

0 comments on commit 4750c48

Please sign in to comment.