From e626b18e4c83d170729f73c77582d6427c38c709 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 22 May 2024 16:52:24 +0200 Subject: Switch to new CascadedThreadPool --- .../org/openslx/imagemaster/serverconnection/ConnectionHandler.java | 6 +++--- .../java/org/openslx/imagemaster/thrift/server/HttpListener.java | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java b/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java index 8b6d197..f3831b0 100644 --- a/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java +++ b/src/main/java/org/openslx/imagemaster/serverconnection/ConnectionHandler.java @@ -33,7 +33,7 @@ import org.openslx.filetransfer.Uploader; import org.openslx.imagemaster.Globals; import org.openslx.imagemaster.db.mappers.DbImage; import org.openslx.thrifthelper.ImagePublishDataEx; -import org.openslx.util.GrowingThreadPoolExecutor; +import org.openslx.util.CascadedThreadPoolExecutor; import org.openslx.util.QuickTimer; import org.openslx.util.QuickTimer.Task; @@ -53,9 +53,9 @@ public class ConnectionHandler implements IncomingEvent private static Map outgoingTransfers = new ConcurrentHashMap<>(); private static IncomingEvent eventHandler = new ConnectionHandler(); - private final ExecutorService transferPool = new GrowingThreadPoolExecutor( 1, MAX_TRANSFERS * 2, 1, TimeUnit.MINUTES, + private final ExecutorService transferPool = new CascadedThreadPoolExecutor( 1, MAX_TRANSFERS * 2, 1, TimeUnit.MINUTES, new SynchronousQueue(), - new PrioThreadFactory( "TransferPool", Thread.NORM_PRIORITY - 2 ) ); + new PrioThreadFactory( "TransferPool", Thread.NORM_PRIORITY - 2 ), null ); private static final Listener plainListener; private static final Listener sslListener; diff --git a/src/main/java/org/openslx/imagemaster/thrift/server/HttpListener.java b/src/main/java/org/openslx/imagemaster/thrift/server/HttpListener.java index b56f64e..b39d993 100644 --- a/src/main/java/org/openslx/imagemaster/thrift/server/HttpListener.java +++ b/src/main/java/org/openslx/imagemaster/thrift/server/HttpListener.java @@ -2,6 +2,7 @@ package org.openslx.imagemaster.thrift.server; import java.io.IOException; import java.util.Arrays; +import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -9,6 +10,7 @@ import org.apache.thrift.protocol.TJSONProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TMemoryBuffer; import org.openslx.bwlp.thrift.iface.MasterServer; +import org.openslx.util.CascadedThreadPoolExecutor; import org.openslx.util.Util; import fi.iki.elonen.NanoHTTPD; @@ -23,7 +25,7 @@ public class HttpListener extends NanoHTTPD public HttpListener( String hostname, int port ) throws IOException { - super( hostname, port, 64, 16 ); + super( hostname, port, new CascadedThreadPoolExecutor( 4, 32, 1, TimeUnit.MINUTES, 2, "HTTP" ) ); this.maxRequestSize = 1_000_000; } -- cgit v1.2.3-55-g7522